[PATCH] Use custom image as location button icon, fix leak



Proposed patch attached, which fixes bug 311394 and a leak.

[1] http://bugzilla.gnome.org/show_bug.cgi?id=311394

-- 
Christian Neumair <chris gnome-de org>
Index: src/nautilus-spatial-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-spatial-window.c,v
retrieving revision 1.451
diff -u -p -r1.451 nautilus-spatial-window.c
--- src/nautilus-spatial-window.c	17 Oct 2005 17:43:57 -0000	1.451
+++ src/nautilus-spatial-window.c	17 Oct 2005 18:03:20 -0000
@@ -442,13 +442,22 @@ got_file_info_for_location_menu_callback
 {	
 	GtkWidget *icon;
 	GtkWidget *menu_item = callback_data;
+	GdkPixbuf *pixbuf;
 	char *icon_name;
 
 	g_return_if_fail (NAUTILUS_IS_FILE (file));
 
+	pixbuf = NULL;
+
 	icon_name = nautilus_icon_factory_get_icon_for_file (file, FALSE);
-	if (icon_name) {
-		icon = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
+	if (icon_name != NULL) {
+		pixbuf = nautilus_icon_factory_get_pixbuf_from_name_with_stock_size (icon_name, NULL, GTK_ICON_SIZE_MENU, NULL);
+		g_free (icon_name);
+	}
+
+	if (pixbuf != NULL) {
+		icon = gtk_image_new_from_pixbuf (pixbuf);
+		gdk_pixbuf_unref (pixbuf);
 	} else {
 		icon = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
 	}
@@ -674,12 +683,19 @@ nautilus_spatial_window_set_location_but
 		vfs_result_code = nautilus_file_get_file_info_result (file);
 		if (vfs_result_code == GNOME_VFS_OK) {
 			char *icon_name;
+			GdkPixbuf *pixbuf;
+
+			pixbuf = NULL;
 
 			icon_name = nautilus_icon_factory_get_icon_for_file (file, FALSE);		
-			if (icon_name) {
-				gtk_image_set_from_icon_name (GTK_IMAGE (window->details->location_icon), 
-							      icon_name, GTK_ICON_SIZE_MENU);
+			if (icon_name != NULL) {
+				pixbuf = nautilus_icon_factory_get_pixbuf_from_name_with_stock_size (icon_name, NULL, GTK_ICON_SIZE_MENU, NULL);
 				g_free (icon_name);
+			}
+
+			if (pixbuf != NULL) {
+				gtk_image_set_from_pixbuf (GTK_IMAGE (window->details->location_icon),  pixbuf);
+				gdk_pixbuf_unref (pixbuf);
 			} else {
 				gtk_image_set_from_stock (GTK_IMAGE (window->details->location_icon),
 							  GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil



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