37 |
37 |
38 static CxMap *image_map; |
38 static CxMap *image_map; |
39 |
39 |
40 static GtkIconTheme *icon_theme; |
40 static GtkIconTheme *icon_theme; |
41 |
41 |
|
42 #if GTK_MAJOR_VERSION >= 4 |
|
43 #define ICONTHEME_GET_DEFAULT() gtk_icon_theme_get_for_display(gdk_display_get_default()) |
|
44 #else |
|
45 #define ICONTHEME_GET_DEFAULT() gtk_icon_theme_get_default() |
|
46 #endif |
|
47 |
42 void ui_image_init(void) { |
48 void ui_image_init(void) { |
43 image_map = cxHashMapCreateSimple(CX_STORE_POINTERS); |
49 image_map = cxHashMapCreateSimple(CX_STORE_POINTERS); |
44 |
50 |
45 icon_theme = gtk_icon_theme_get_default(); |
51 icon_theme = ICONTHEME_GET_DEFAULT(); |
46 } |
52 } |
47 |
53 |
48 // **** deprecated functions **** |
54 // **** deprecated functions **** |
49 |
55 |
50 GdkPixbuf* ui_get_image(const char *name) { |
56 GdkPixbuf* ui_get_image(const char *name) { |
61 |
67 |
62 // **** deprecated2**** |
68 // **** deprecated2**** |
63 |
69 |
64 static UiIcon* get_icon(const char *name, int size, int scale) { |
70 static UiIcon* get_icon(const char *name, int size, int scale) { |
65 #if GTK_MAJOR_VERSION >= 4 |
71 #if GTK_MAJOR_VERSION >= 4 |
66 GtkIconPaintable *info = gtk_icon_theme_lookup_icon(icon_theme, NULL, size, scale, GTK_TEXT_DIR_LTR, GTK_ICON_LOOKUP_FORCE_REGULAR); |
72 GtkIconPaintable *info = gtk_icon_theme_lookup_icon(icon_theme, name, NULL, size, scale, GTK_TEXT_DIR_LTR, GTK_ICON_LOOKUP_FORCE_REGULAR); |
67 #elif defined(UI_SUPPORTS_SCALE) |
73 #elif defined(UI_SUPPORTS_SCALE) |
68 GtkIconInfo *info = gtk_icon_theme_lookup_icon_for_scale(icon_theme, name, size, scale, 0); |
74 GtkIconInfo *info = gtk_icon_theme_lookup_icon_for_scale(icon_theme, name, size, scale, 0); |
69 #else |
75 #else |
70 GtkIconInfo *info = gtk_icon_theme_lookup_icon(icon_theme, name, size, 0); |
76 GtkIconInfo *info = gtk_icon_theme_lookup_icon(icon_theme, name, size, 0); |
71 #endif |
77 #endif |
116 |
122 |
117 UiIcon* ui_icon_unscaled(const char *name, int size) { |
123 UiIcon* ui_icon_unscaled(const char *name, int size) { |
118 return get_icon(name, size, 1); |
124 return get_icon(name, size, 1); |
119 } |
125 } |
120 |
126 |
|
127 #if GTK_MAJOR_VERSION >= 4 |
|
128 GdkPixbuf* ui_icon_pixbuf(UiIcon *icon) { |
|
129 return NULL; // TODO |
|
130 } |
|
131 #else |
121 GdkPixbuf* ui_icon_pixbuf(UiIcon *icon) { |
132 GdkPixbuf* ui_icon_pixbuf(UiIcon *icon) { |
122 if(!icon->pixbuf) { |
133 if(!icon->pixbuf) { |
123 GError *error = NULL; |
134 GError *error = NULL; |
124 icon->pixbuf = gtk_icon_info_load_icon(icon->info, &error); |
135 icon->pixbuf = gtk_icon_info_load_icon(icon->info, &error); |
125 } |
136 } |
126 return icon->pixbuf; |
137 return icon->pixbuf; |
127 } |
138 } |
|
139 #endif |
128 |
140 |
|
141 /* |
129 UiImage* ui_icon_image(UiIcon *icon) { |
142 UiImage* ui_icon_image(UiIcon *icon) { |
130 GError *error = NULL; |
143 GError *error = NULL; |
131 GdkPixbuf *pixbuf = gtk_icon_info_load_icon(icon->info, &error); |
144 GdkPixbuf *pixbuf = gtk_icon_info_load_icon(icon->info, &error); |
132 if(pixbuf) { |
145 if(pixbuf) { |
133 UiImage *img = malloc(sizeof(UiImage)); |
146 UiImage *img = malloc(sizeof(UiImage)); |
134 img->pixbuf = pixbuf; |
147 img->pixbuf = pixbuf; |
135 return img; |
148 return img; |
136 } |
149 } |
137 return NULL; |
150 return NULL; |
138 } |
151 } |
|
152 */ |
139 |
153 |
140 /* |
154 /* |
141 UiImage* ui_image(const char *filename) { |
155 UiImage* ui_image(const char *filename) { |
142 return ui_named_image(filename, NULL); |
156 return ui_named_image(filename, NULL); |
143 } |
157 } |