From: Jose Dapena Paz Date: Thu, 3 Dec 2009 18:47:32 +0000 (+0100) Subject: Implement modest_platform_get_icon for gtk X-Git-Tag: jdapena-ppa-3.90.4-modest0~113 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=b259b966785dd1488714225b0fcda810d09d8fa9 Implement modest_platform_get_icon for gtk --- diff --git a/src/gtk/modest-platform.c b/src/gtk/modest-platform.c index cc58f1e..40b26ee 100644 --- a/src/gtk/modest-platform.c +++ b/src/gtk/modest-platform.c @@ -176,11 +176,40 @@ gchar* modest_platform_get_file_icon_name (const gchar* name, const gchar* mime_type, gchar **effective_mime_type) { + gchar *icon_name = NULL; + gchar *content_type; + GIcon *icon; + gchar **icon_names, **cursor; + + if (!mime_type || g_ascii_strcasecmp (mime_type, "application/octet-stream") == 0) + content_type = g_content_type_guess (name, NULL, 0, NULL); + else { + content_type = g_content_type_from_mime_type (mime_type); + } - g_warning ("Not implemented %s", __FUNCTION__); + if (!content_type) { + content_type = g_content_type_from_mime_type ("application/octet-stream"); + } + icon = g_content_type_get_icon (content_type); + if (!G_THEMED_ICON (icon)) + return NULL; + + g_object_get (G_OBJECT (icon), "names", &icon_names, NULL); + + for (cursor = icon_names; cursor; ++cursor) { + if (!g_ascii_strcasecmp (*cursor, "gnome-mime-message") || + !g_ascii_strcasecmp (*cursor, "gnome-mime-message-rfc822")) { + icon_name = g_strdup ("qgn_list_messagin"); + break; + } else if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default(), *cursor)) { + icon_name = g_strdup (*cursor); + break; + } + } + g_strfreev (icon_names); + + return icon_name; - return NULL; - }