ui/gtk/image.c

branch
newapi
changeset 299
48763a9d19a7
parent 296
a362c76dbf99
child 312
3f2b3d15668b
--- a/ui/gtk/image.c	Mon Sep 16 22:09:32 2024 +0200
+++ b/ui/gtk/image.c	Tue Sep 17 22:00:07 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 ****
@@ -63,7 +69,7 @@
 
 static UiIcon* get_icon(const char *name, int size, int scale) {
 #if GTK_MAJOR_VERSION >= 4
-    GtkIconPaintable *info = gtk_icon_theme_lookup_icon(icon_theme, NULL, size, scale, GTK_TEXT_DIR_LTR, GTK_ICON_LOOKUP_FORCE_REGULAR);
+    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
@@ -118,6 +124,11 @@
     return get_icon(name, size, 1);
 }
 
+#if GTK_MAJOR_VERSION >= 4
+GdkPixbuf* ui_icon_pixbuf(UiIcon *icon) {
+    return NULL; // TODO
+}
+#else
 GdkPixbuf* ui_icon_pixbuf(UiIcon *icon) {
     if(!icon->pixbuf) {
         GError *error = NULL;
@@ -125,7 +136,9 @@
     }
     return icon->pixbuf;
 }
+#endif
 
+/*
 UiImage* ui_icon_image(UiIcon *icon) {
     GError *error = NULL;
     GdkPixbuf *pixbuf = gtk_icon_info_load_icon(icon->info, &error);
@@ -136,6 +149,7 @@
     }
     return NULL;
 }
+*/
 
 /*
 UiImage* ui_image(const char *filename) {

mercurial