diff -r ef01d2c90128 -r 473954dc6b74 ui/gtk/image.c --- a/ui/gtk/image.c Mon Jun 17 21:20:58 2024 +0200 +++ b/ui/gtk/image.c Sun Sep 29 13:32:51 2024 +0200 @@ -39,10 +39,16 @@ static GtkIconTheme *icon_theme; +#if GTK_MAJOR_VERSION >= 4 +#define ICONTHEME_GET_DEFAULT() gtk_icon_theme_get_for_display(gdk_display_get_default()) +#else +#define ICONTHEME_GET_DEFAULT() gtk_icon_theme_get_default() +#endif + void ui_image_init(void) { image_map = cxHashMapCreateSimple(CX_STORE_POINTERS); - icon_theme = gtk_icon_theme_get_default(); + icon_theme = ICONTHEME_GET_DEFAULT(); } // **** deprecated functions **** @@ -62,7 +68,9 @@ // **** deprecated2**** static UiIcon* get_icon(const char *name, int size, int scale) { -#ifdef UI_SUPPORTS_SCALE +#if GTK_MAJOR_VERSION >= 4 + GtkIconPaintable *info = gtk_icon_theme_lookup_icon(icon_theme, name, NULL, size, scale, GTK_TEXT_DIR_LTR, GTK_ICON_LOOKUP_FORCE_REGULAR); +#elif defined(UI_SUPPORTS_SCALE) GtkIconInfo *info = gtk_icon_theme_lookup_icon_for_scale(icon_theme, name, size, scale, 0); #else GtkIconInfo *info = gtk_icon_theme_lookup_icon(icon_theme, name, size, 0); @@ -116,6 +124,16 @@ return get_icon(name, size, 1); } +#if GTK_MAJOR_VERSION >= 4 +GdkPixbuf* ui_icon_pixbuf(UiIcon *icon) { + if(!icon->pixbuf) { + GFile *file = gtk_icon_paintable_get_file(icon->info); + GError *error = NULL; + icon->pixbuf = gdk_pixbuf_new_from_file(g_file_get_path(file), &error); + } + return icon->pixbuf; +} +#else GdkPixbuf* ui_icon_pixbuf(UiIcon *icon) { if(!icon->pixbuf) { GError *error = NULL; @@ -123,7 +141,9 @@ } return icon->pixbuf; } +#endif +/* UiImage* ui_icon_image(UiIcon *icon) { GError *error = NULL; GdkPixbuf *pixbuf = gtk_icon_info_load_icon(icon->info, &error); @@ -134,6 +154,7 @@ } return NULL; } +*/ /* UiImage* ui_image(const char *filename) {