[gnome-control-center/extensible-shell] Support more types of Icon in .desktop files



commit d7c4f6d50917460f162185061ad50d5adaec2bb8
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Jan 19 13:57:59 2010 +0000

    Support more types of Icon in .desktop files
    
    Properly load desktop files that contain either absolute file paths,
    or the name of a file with a suffix.
    
    Also print out the error message properly when failing to load
    an icon.

 shell/control-center.c |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/shell/control-center.c b/shell/control-center.c
index 12eb086..8fa5c22 100644
--- a/shell/control-center.c
+++ b/shell/control-center.c
@@ -279,18 +279,33 @@ fill_model (ShellData *data)
                   const gchar *id = gmenu_tree_entry_get_desktop_file_id (f->data);
                   const gchar *exec = gmenu_tree_entry_get_exec (f->data);
                   GdkPixbuf *pixbuf = NULL;
+                  char *icon2 = NULL;
 
-                  pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
-                                                     icon, 32,
-                                                     GTK_ICON_LOOKUP_FORCE_SIZE,
-                                                     NULL);
+                  if (icon != NULL && *icon == '/')
+                    {
+                      pixbuf = gdk_pixbuf_new_from_file_at_scale (icon,
+                                                                        32, 32, TRUE, &err);
+                    }
+                  else
+                    {
+                      if (icon2 == NULL && icon != NULL && g_str_has_suffix (icon, ".png"))
+                        icon2 = g_strndup (icon, strlen (icon) - strlen (".png"));
+
+                      pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                                         icon2 ? icon2 : icon, 32,
+                                                         GTK_ICON_LOOKUP_FORCE_SIZE,
+                                                         &err);
+                    }
 
                   if (err)
                     {
-                      g_warning ("Could not load icon: %s", err->message);
+                      g_warning ("Could not load icon '%s': %s", icon2 ? icon2 : icon,
+                                       err->message);
                       g_error_free (err);
                     }
 
+                  g_free (icon2);
+
                   gtk_list_store_insert_with_values (store, NULL, 0,
                                                      0, name,
                                                      1, exec,



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