[Xfce4-commits] <xfce4-screenshooter:master> Simplify the icon handling in the combobox.

Jérôme Guelfucci noreply at xfce.org
Mon Dec 28 17:06:01 CET 2009


Updating branch refs/heads/master
         to 02a13603076badc8d323b3db6d4f2351f1cdb977 (commit)
       from 1938669ea8ac46a2c2af6b193918ecf7cc8c92ac (commit)

commit 02a13603076badc8d323b3db6d4f2351f1cdb977
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Mon Dec 28 17:01:53 2009 +0100

    Simplify the icon handling in the combobox.

 lib/screenshooter-dialogs.c |   37 +++++++------------------------------
 1 files changed, 7 insertions(+), 30 deletions(-)

diff --git a/lib/screenshooter-dialogs.c b/lib/screenshooter-dialogs.c
index 2d040bb..d79d23a 100644
--- a/lib/screenshooter-dialogs.c
+++ b/lib/screenshooter-dialogs.c
@@ -306,38 +306,14 @@ static void add_item (GAppInfo *app_info, GtkWidget *liststore)
   GIcon *icon = g_app_info_get_icon (app_info);
   GdkPixbuf *pixbuf = NULL;
   GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
+  GtkIconInfo *icon_info;
 
-  /* Get the icon */
-  if (G_IS_LOADABLE_ICON (icon))
-    {
-      GFile *file = g_file_icon_get_file (G_FILE_ICON (icon));
-      gchar *path = g_file_get_path (file);
-
-      pixbuf =
-        gdk_pixbuf_new_from_file_at_size (path, ICON_SIZE,
-                                          ICON_SIZE, NULL);
+  icon_info =
+    gtk_icon_theme_lookup_by_gicon (icon_theme, icon,
+                                    ICON_SIZE,
+                                    GTK_ICON_LOOKUP_GENERIC_FALLBACK);
 
-      g_free (path);
-      g_object_unref (file);
-    }
-  else
-    {
-      gchar **names = NULL;
-
-      g_object_get (G_OBJECT (icon), "names", &names, NULL);
-
-      if (G_LIKELY (names != NULL))
-        {
-          if (names[0] != NULL)
-            pixbuf = gtk_icon_theme_load_icon (icon_theme,
-                                               names[0],
-                                               ICON_SIZE,
-                                               GTK_ICON_LOOKUP_GENERIC_FALLBACK,
-                                               NULL);
-
-          g_strfreev (names);
-        }
-    }
+  pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
 
   if (G_UNLIKELY (pixbuf == NULL))
     {
@@ -360,6 +336,7 @@ static void add_item (GAppInfo *app_info, GtkWidget *liststore)
   g_free (name);
   g_object_unref (pixbuf);
   g_object_unref (icon);
+  gtk_icon_info_free (icon_info);
 }
 
 



More information about the Xfce4-commits mailing list