Commit
It may happen that even though we get GIcon, the actual icon dosen't exist (typically on Windows and OS X). Check if we can find the actual icon. In addition, use "icon name" instead of "stock id" - the latter doesn't work on OS X / Windows for some reason.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2893,18 +2893,32 @@ GIcon *ui_get_mime_icon(const gchar *mime_type) | |
if (ctype) | ||
{ | ||
icon = g_content_type_get_icon(ctype); | ||
if (icon) | ||
{ | ||
GtkIconInfo *icon_info; | ||
|
||
icon_info = gtk_icon_theme_lookup_by_gicon(gtk_icon_theme_get_default(), icon, 16, 0); | ||
if (!icon_info) | ||
{ | ||
g_object_unref(icon); | ||
icon = NULL; | ||
} | ||
else | ||
gtk_icon_info_free(icon_info); | ||
} | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
techee
via email
Author
Owner
|
||
g_free(ctype); | ||
} | ||
|
||
/* fallback if icon lookup failed, like it might happen on Windows (?) */ | ||
if (! icon) | ||
{ | ||
const gchar *stock_id = GTK_STOCK_FILE; | ||
const gchar *icon_name = "text-x-generic"; | ||
|
||
if (strstr(mime_type, "directory")) | ||
stock_id = GTK_STOCK_DIRECTORY; | ||
icon_name = "folder"; | ||
This comment has been minimized.
Sorry, something went wrong.
b4n
|
||
|
||
icon = g_themed_icon_new(stock_id); | ||
icon = g_themed_icon_new(icon_name); | ||
} | ||
return icon; | ||
} | ||
|
2 comments
on commit 7880c0f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
72 columns in commit messages is better ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum… what is the problem with a non-NULL but non-working GIcon? does it render something like broken icon instead of not rendering anything at all?