ui/gtk/image.c

branch
newapi
changeset 334
00be546d3b38
parent 327
216d8912714c
equal deleted inserted replaced
333:634e3ce80afe 334:00be546d3b38
115 UiIcon* ui_foldericon(size_t size) { 115 UiIcon* ui_foldericon(size_t size) {
116 return ui_icon("folder", size); 116 return ui_icon("folder", size);
117 } 117 }
118 118
119 UiIcon* ui_fileicon(size_t size) { 119 UiIcon* ui_fileicon(size_t size) {
120 return ui_icon("file", size); 120 UiIcon *icon = ui_icon("file", size);
121 #if GTK_MAJOR_VERSION >= 4
122 GFile *file = gtk_icon_paintable_get_file(icon->info);
123 char *path = g_file_get_path(file);
124 if(!path) {
125 icon = ui_icon("application-x-generic", size);
126 }
127 #endif
128 return icon;
121 } 129 }
122 130
123 UiIcon* ui_icon_unscaled(const char *name, int size) { 131 UiIcon* ui_icon_unscaled(const char *name, int size) {
124 return get_icon(name, size, 1); 132 return get_icon(name, size, 1);
125 } 133 }
127 #if GTK_MAJOR_VERSION >= 4 135 #if GTK_MAJOR_VERSION >= 4
128 GdkPixbuf* ui_icon_pixbuf(UiIcon *icon) { 136 GdkPixbuf* ui_icon_pixbuf(UiIcon *icon) {
129 if(!icon->pixbuf) { 137 if(!icon->pixbuf) {
130 GFile *file = gtk_icon_paintable_get_file(icon->info); 138 GFile *file = gtk_icon_paintable_get_file(icon->info);
131 GError *error = NULL; 139 GError *error = NULL;
132 icon->pixbuf = gdk_pixbuf_new_from_file(g_file_get_path(file), &error); 140 char *path = g_file_get_path(file);
141 icon->pixbuf = gdk_pixbuf_new_from_file(path, &error);
133 } 142 }
134 return icon->pixbuf; 143 return icon->pixbuf;
135 } 144 }
136 #else 145 #else
137 GdkPixbuf* ui_icon_pixbuf(UiIcon *icon) { 146 GdkPixbuf* ui_icon_pixbuf(UiIcon *icon) {

mercurial