diff --git a/ChangeLog b/ChangeLog index d095548a99..01019bb0b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-06-19 Matthias Clasen + + * gtk/gtkrecentmanager.c (get_icon_for_mime_type): Use GIO + for this. + 2008-06-19 Johan Dahlin * gtk/gtkprintbackend.c: Fix a typo in a comment diff --git a/gtk/gtkrecentmanager.c b/gtk/gtkrecentmanager.c index 39a3242e9d..1b24425384 100644 --- a/gtk/gtkrecentmanager.c +++ b/gtk/gtkrecentmanager.c @@ -1881,52 +1881,24 @@ get_icon_for_mime_type (const char *mime_type, gint pixel_size) { GtkIconTheme *icon_theme; - const char *separator; - GString *icon_name; + char *content_type; + GIcon *icon; + GtkIconInfo *info; GdkPixbuf *pixbuf; - separator = strchr (mime_type, '/'); - if (!separator) - return NULL; - icon_theme = gtk_icon_theme_get_default (); - /* try with the three icon name variants for MIME types */ + content_type = g_content_type_from_mime_type (mime_type); + icon = g_content_type_get_icon (content_type); + info = gtk_icon_theme_lookup_by_gicon (icon_theme, + icon, + pixel_size, + GTK_ICON_LOOKUP_USE_BUILTIN); + pixbuf = gtk_icon_info_load_icon (info, NULL); - /* canonicalize MIME type: foo/x-bar -> foo-x-bar */ - icon_name = g_string_new (NULL); - g_string_append_len (icon_name, mime_type, separator - mime_type); - g_string_append_c (icon_name, '-'); - g_string_append (icon_name, separator + 1); - pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name->str, - pixel_size, - 0, - NULL); - g_string_free (icon_name, TRUE); - if (pixbuf) - return pixbuf; - - /* canonicalize MIME type, and prepend "gnome-mime-" */ - icon_name = g_string_new ("gnome-mime-"); - g_string_append_len (icon_name, mime_type, separator - mime_type); - g_string_append_c (icon_name, '-'); - g_string_append (icon_name, separator + 1); - pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name->str, - pixel_size, - 0, - NULL); - g_string_free (icon_name, TRUE); - if (pixbuf) - return pixbuf; - - /* try the MIME family icon */ - icon_name = g_string_new ("gnome-mime-"); - g_string_append_len (icon_name, mime_type, separator - mime_type); - pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name->str, - pixel_size, - 0, - NULL); - g_string_free (icon_name, TRUE); + g_free (content_type); + g_object_unref (icon); + gtk_icon_info_free (info); return pixbuf; }