Re: [PATCH] Add icon to "New Document->Empty File" action



Am Dienstag, den 28.06.2005, 15:26 +0200 schrieb Alexander Larsson:
> On Tue, 2005-06-28 at 12:22 +0200, Christian Neumair wrote:
> > I don't remember where it was requested, but somebody asked for an icon
> > for the "New Empty File" action in the New Document menu. The attached
> > patch adds it.
> 
> +
> +       if (strcmp (gtk_action_get_name (action),
> FM_ACTION_NEW_EMPTY_FILE) != 0 ||
> +           !GTK_IS_IMAGE_MENU_ITEM (proxy)) {
> +               return;
> +       }
> +
> 
> Do this check the other way instead.

Done.


-- 
Christian Neumair <chris gnome-de org>
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.696
diff -u -p -r1.696 fm-directory-view.c
--- src/file-manager/fm-directory-view.c	20 Jun 2005 14:36:19 -0000	1.696
+++ src/file-manager/fm-directory-view.c	29 Jun 2005 10:29:34 -0000
@@ -50,6 +50,8 @@
 #include <eel/eel-marshal.h>
 #include <gtk/gtkcheckmenuitem.h>
 #include <gtk/gtkclipboard.h>
+#include <gtk/gtkiconfactory.h>
+#include <gtk/gtkimagemenuitem.h>
 #include <gtk/gtkmain.h>
 #include <gtk/gtkmenu.h>
 #include <gtk/gtkselection.h>
@@ -6225,6 +6227,29 @@ static const GtkToggleActionEntry direct
 };
 
 static void
+connect_proxy (FMDirectoryView *view,
+	       GtkAction *action,
+	       GtkWidget *proxy,
+	       GtkActionGroup *action_group)
+{
+	GdkPixbuf *pixbuf;
+	GtkWidget *image;
+
+	if (strcmp (gtk_action_get_name (action), FM_ACTION_NEW_EMPTY_FILE) == 0 &&
+	    GTK_IS_IMAGE_MENU_ITEM (proxy)) {
+		pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+						   "gnome-fs-regular",
+						   NAUTILUS_ICON_SIZE_FOR_MENUS,
+						   0, NULL);
+
+		image = gtk_image_new_from_pixbuf (pixbuf);
+		gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), image);
+
+		gdk_pixbuf_unref (pixbuf);
+	}
+}
+
+static void
 real_merge_menus (FMDirectoryView *view)
 {
 	GtkActionGroup *action_group;
@@ -6255,6 +6280,10 @@ real_merge_menus (FMDirectoryView *view)
 	action = gtk_action_group_get_action (action_group, FM_ACTION_NO_TEMPLATES);
 	gtk_action_set_sensitive (action, FALSE);
 
+	g_signal_connect_object (action_group, "connect-proxy",
+				 G_CALLBACK (connect_proxy), G_OBJECT (view),
+				 G_CONNECT_SWAPPED);
+
 	/* Insert action group at end so clipboard action group ends up before it */
 	gtk_ui_manager_insert_action_group (ui_manager, action_group, -1);
 	g_object_unref (action_group); /* owned by ui manager */

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



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