Re: [Nautilus-list] toolbar icons patch



On Wed, 20 Feb 2002, Darin Adler wrote:
> > I've leaved the need for renaming the icons in the patch. For the
> > Up.png image its neccessary and for the sake of consistency I think it's a
> > good idea to rename the other both too.
>
> Breaking compatibility for old Nautilus themes doesn't seem worth it to me.
> It's not like these names are identical to the gtk stock ones.
>
> Please don't make the change that requires theme authors to rename the
> icons.

This patch is much more nicer now, since it explicitly defines the
appropriate gtk stock item for each toolbar button. No renaming needed.

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.5008
diff -u -p -r1.5008 ChangeLog
--- ChangeLog	2002/02/20 23:15:26	1.5008
+++ ChangeLog	2002/02/20 23:32:57
@@ -1,3 +1,11 @@
+2002-02-20  Jens Finke <jens triq net>
+
+	* src/nautilus-window-toolbars.c
+	(set_up_standard_bonobo_button),
+	(set_up_special_bonobo_button): Added gtk stock item fallback
+	which is used if a custom icon wasn't found.
+	(set_up_toolbar_images): Define proper stock item replacements.
+
 2002-02-20  David Emory Watson  <dwatson cs ucr edu>
 
 	* src/file-manager/fm-directory-view.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 23:32:57
@@ -224,11 +224,11 @@ static void
 set_up_standard_bonobo_button (NautilusWindow *window, 
 			       const char *item_path, 
 			       const char *icon_name,
-			       gboolean is_custom)
+			       const char *stock_item_fallback)
 {
 	char *file_name;
 
-	file_name = get_file_name_from_icon_name (icon_name, is_custom);
+	file_name = get_file_name_from_icon_name (icon_name, (stock_item_fallback == NULL));
 		
 	/* set up the toolbar component with the new image */
 	bonobo_ui_component_set_prop (window->details->shell_ui, 
@@ -239,7 +239,7 @@ set_up_standard_bonobo_button (NautilusW
 	bonobo_ui_component_set_prop (window->details->shell_ui, 
 				      item_path,
 				      "pixname",
-				      file_name == NULL ? icon_name : file_name,
+				      file_name == NULL ? stock_item_fallback : file_name,
 			      	      NULL);
 
 	g_free (file_name);
@@ -252,22 +252,32 @@ static void
 set_up_special_bonobo_button (NautilusWindow            *window,
 			      BonoboUIToolbarButtonItem *item,
 			      const char                *control_path,
-			      const char                *icon_name)
+			      const char                *icon_name,
+			      const char                *stock_item_fallback)
 {
-	char *icon_file_name;
-	GdkPixbuf *pixbuf;	
+	char *icon_file_name = NULL;
+	gpointer image;
+	GtkStockItem stock_item;
 
 	icon_file_name = get_file_name_from_icon_name (icon_name, FALSE);
 
 	if (icon_file_name == NULL) {
-		return;
+		
+		if (gtk_stock_lookup (stock_item_fallback, &stock_item)) {
+			image = gtk_image_new_from_stock (stock_item_fallback, 
+							  GTK_ICON_SIZE_BUTTON);
+			if (image == NULL) return;
+			g_object_ref (image);
+		} else {
+			return;
+		}
+	} else {
+		image = gdk_pixbuf_new_from_file (icon_file_name, NULL);
+		g_free (icon_file_name);
 	}
-
-	pixbuf = 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,15 +287,17 @@ 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", "Back", GTK_STOCK_GO_BACK);
+	set_up_special_bonobo_button (window, window->details->forward_button_item, 
+				      "/Toolbar/ForwardWrapper", "Forward", GTK_STOCK_GO_FORWARD);
 	
-	set_up_standard_bonobo_button (window, "/Toolbar/Up", "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);
-	set_up_standard_bonobo_button (window, "/Toolbar/Go to Web Search", "SearchWeb", TRUE);
-	set_up_standard_bonobo_button (window, "/Toolbar/Stop", "Stop", FALSE);
+	set_up_standard_bonobo_button (window, "/Toolbar/Up", "Up", GTK_STOCK_GO_UP);
+	set_up_standard_bonobo_button (window, "/Toolbar/Home", "Home", GTK_STOCK_HOME);
+	set_up_standard_bonobo_button (window, "/Toolbar/Reload", "Refresh", GTK_STOCK_REFRESH);
+	set_up_standard_bonobo_button (window, "/Toolbar/Toggle Find Mode", "Search", GTK_STOCK_FIND);
+	set_up_standard_bonobo_button (window, "/Toolbar/Go to Web Search", "SearchWeb", NULL);
+	set_up_standard_bonobo_button (window, "/Toolbar/Stop", "Stop", GTK_STOCK_STOP);
 
 	bonobo_ui_component_thaw (window->details->shell_ui, NULL);
 


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