[geany/geany] 9767f7: Improve ui_get_mime_icon()

Jiří Techet git-noreply at xxxxx
Tue Feb 10 16:23:26 UTC 2015


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Tue, 20 Jan 2015 18:33:06 UTC
Commit:      9767f79e50408911508577cb68906658872afe3b
             https://github.com/geany/geany/commit/9767f79e50408911508577cb68906658872afe3b

Log Message:
-----------
Improve ui_get_mime_icon()

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.


Modified Paths:
--------------
    src/ui_utils.c

Modified: src/ui_utils.c
20 lines changed, 17 insertions(+), 3 deletions(-)
===================================================================
@@ -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);
+		}
+
 		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";
 
-		icon = g_themed_icon_new(stock_id);
+		icon = g_themed_icon_new(icon_name);
 	}
 	return icon;
 }



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list