[Nautilus-list] toolbar icons patch



Hello,

this patch makes the up, back and forward toolbar icons work again if the
theme doesn't provide custom icons (eg. with the gnome scheme).

For the standard up button it's enough to adapt the new gtk naming scheme.
The setup function for special toolbar buttons (like back and forward)
falls back to the gtk stock icons if the theme doesn't provide own icons.
Unfourtunately this would require renaming the Back|Up|Forward.png theme
images to Go-Back|Go-Up|Go-Forward.png. Again, this is to be compatible
with the new gtk naming scheme.

Is it ok to commit the patch in this form?

Regards,

   Jens

-- 
"Wer die Freiheit aufgibt, um Sicherheit zu gewinnen, wird am Ende beides
verlieren." -- Benjamin Franklin

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5003
diff -u -p -r1.5003 ChangeLog
--- ChangeLog	2002/02/20 02:50:39	1.5003
+++ ChangeLog	2002/02/20 08:14:54
@@ -1,3 +1,11 @@
+2002-02-20  Jens Finke <jens triq net>
+
+	* src/nautilus-window-toolbars.c (set_up_special_bonobo_button):
+	Consider gtk stock items if there is no image with such a
+	filename.
+	(set_up_toolbar_images): Use Go-Up, Go-Back and Go-Forward as icon
+	names to fit into the new gtk stock naming scheme.
+	
 2002-02-19  Bastien Nocera  <hadess hadess net>
 
 	* src/nautilus-window-manage-views.c:
Index: src/nautilus-window-toolbars.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-toolbars.c,v
retrieving revision 1.92
diff -u -p -r1.92 nautilus-window-toolbars.c
--- src/nautilus-window-toolbars.c	2002/02/14 23:21:58	1.92
+++ src/nautilus-window-toolbars.c	2002/02/20 08:14:55
@@ -254,20 +254,36 @@ set_up_special_bonobo_button (NautilusWi
 			      const char                *control_path,
 			      const char                *icon_name)
 {
-	char *icon_file_name;
-	GdkPixbuf *pixbuf;	
+	char *icon_file_name = NULL;
+	gpointer image;
+	char *stock_id;
+	GtkStockItem stock_item;
 
 	icon_file_name = get_file_name_from_icon_name (icon_name, FALSE);
 
 	if (icon_file_name == NULL) {
-		return;
+		
+		stock_id = g_strconcat ("gtk-", icon_name, NULL);
+		g_strdown (stock_id);
+
+		if (gtk_stock_lookup (stock_id, &stock_item)) {
+			image = gtk_image_new_from_stock (stock_id, 
+							  GTK_ICON_SIZE_BUTTON);
+			if (image == NULL) { 
+				g_free (stock_id);
+				return;
+			}
+			g_object_ref (image);
+		}
+		g_free (stock_id);
 	}
-
-	pixbuf = gdk_pixbuf_new_from_file (icon_file_name, NULL);
-	g_free (icon_file_name);
+	else {
+		image = gdk_pixbuf_new_from_file (icon_file_name, NULL);
+		g_free (icon_file_name);
+	}
 	
-	bonobo_ui_toolbar_button_item_set_image (item, pixbuf);
-	g_object_unref (pixbuf);
+	bonobo_ui_toolbar_button_item_set_image (item, image);
+	g_object_unref (image);
 }			      
 
 static void
@@ -277,10 +293,10 @@ set_up_toolbar_images (NautilusWindow *w
 
 	bonobo_ui_component_freeze (window->details->shell_ui, NULL);
 
-	set_up_special_bonobo_button (window, window->details->back_button_item, "/Toolbar/BackWrapper", "Back");
-	set_up_special_bonobo_button (window, window->details->forward_button_item, "/Toolbar/ForwardWrapper", "Forward");
+	set_up_special_bonobo_button (window, window->details->back_button_item, "/Toolbar/BackWrapper", "Go-Back");
+	set_up_special_bonobo_button (window, window->details->forward_button_item, "/Toolbar/ForwardWrapper", "Go-Forward");
 	
-	set_up_standard_bonobo_button (window, "/Toolbar/Up", "Up", FALSE);
+	set_up_standard_bonobo_button (window, "/Toolbar/Up", "Go-Up", FALSE);
 	set_up_standard_bonobo_button (window, "/Toolbar/Home", "Home", FALSE);
 	set_up_standard_bonobo_button (window, "/Toolbar/Reload", "Refresh", FALSE);
 	set_up_standard_bonobo_button (window, "/Toolbar/Toggle Find Mode", "Search", FALSE);


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