Re: GEmblemedIcons help



On Wed, 2009-02-11 at 15:11 +0100, Nicolò Chieffo wrote:
> Hello, I'm writing a patch to show emblemed icons for user special
> directories (documents, music, etc.)
> I'm patching GIO so that nautilus automatically gets the icon.
> 
> I have a question because when I execute nautilus, they don't get the
> correct icon, but the standard file icon (not the dir icon, the file
> icon, so my attempt is not completely wrong)

I can confirm that this is a bug in Nautilus as I'm seeing the same
problem when a GDrive, GVolume or GMount returns a GEmblemedIcon.

The attached patch fixes it for me.

    David

Index: libnautilus-private/nautilus-icon-info.c
===================================================================
--- libnautilus-private/nautilus-icon-info.c	(revision 14933)
+++ libnautilus-private/nautilus-icon-info.c	(working copy)
@@ -410,8 +410,23 @@
 		gtk_icon_info_free (gtkicon_info);
 
 		return g_object_ref (icon_info);
-	} 
-	return nautilus_icon_info_new_for_pixbuf (NULL);
+	} else {
+                GdkPixbuf *pixbuf;
+                GtkIconInfo *gtk_icon_info;
+
+                gtk_icon_info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (),
+                                                                icon,
+                                                                size,
+                                                                GTK_ICON_LOOKUP_GENERIC_FALLBACK);
+                if (gtk_icon_info != NULL) {
+                        pixbuf = gtk_icon_info_load_icon (gtk_icon_info, NULL);
+                        gtk_icon_info_free (gtk_icon_info);
+                } else {
+                        pixbuf = NULL;
+                }
+
+                return nautilus_icon_info_new_for_pixbuf (pixbuf);
+        }
 }
 
 NautilusIconInfo *


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