gtk+ r20472 - in trunk: . gtk



Author: matthiasc
Date: Thu Jun 19 19:04:22 2008
New Revision: 20472
URL: http://svn.gnome.org/viewvc/gtk+?rev=20472&view=rev

Log:
        * gtk/gtkrecentmanager.c (get_icon_for_mime_type): Use GIO
        for this.


Modified:
   trunk/ChangeLog
   trunk/gtk/gtkrecentmanager.c

Modified: trunk/gtk/gtkrecentmanager.c
==============================================================================
--- trunk/gtk/gtkrecentmanager.c	(original)
+++ trunk/gtk/gtkrecentmanager.c	Thu Jun 19 19:04:22 2008
@@ -1881,52 +1881,24 @@
 			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 */
-
-  /* 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);
+  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);
+
+  g_free (content_type);
+  g_object_unref (icon);
+  gtk_icon_info_free (info);
 
   return pixbuf;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]