Re: [PATCH] Only show "Close Parent Windows" if we're not displaying a toplevel URI



Am Dienstag, den 17.05.2005, 10:46 +0200 schrieb Alexander Larsson:
> On Mon, 2005-05-16 at 18:17 +0200, Christian Neumair wrote:
> > Am Montag, den 16.05.2005, 17:26 +0200 schrieb Alexander Larsson:
> > > On Thu, 2005-05-12 at 14:02 +0200, Christian Neumair wrote:
> > > > >From http://bugzilla.gnome.org/show_bug.cgi?id=149287:
> > > > 
> > > > 
> > > > Proposed patch (against HEAD).
> > > > 
> > > > - adds nautilus_file_has_parent
> > > > - adds nautilus_window_(info_)update_menus, which is called when updating the
> > > > menus and implemented by all subclasses of NautilusWindow
> > > 
> > > the NautilusWindow menu only needs updating when the location changes.
> > 
> > Ouch, I've overlooked that. Thanks for pointing it out.
> > 
> > > The right thing to make the spatial window always update the sensitivity
> > > when you change the location. Fortunately we already track all this for
> > > the "up" button in navigational mode. So you just need to hook off
> > > nautilus_window_allow_up().
> > 
> > Nice. Proposed patch #2 attached. Do you like the way the methods are
> > invoked?
> 
> That looks ok, but you don't need nautilus_file_has_parent, just use the
> "allowed" boolean that gets passed to set_allow_up.

Right, next attempt... .

-- 
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.439
diff -u -r1.439 nautilus-spatial-window.c
--- src/nautilus-spatial-window.c	17 Apr 2005 16:55:23 -0000	1.439
+++ src/nautilus-spatial-window.c	17 May 2005 09:48:13 -0000
@@ -81,6 +81,11 @@
 
 #define MAX_TITLE_LENGTH 180
 
+#define SPATIAL_ACTION_PLACES               "Places"
+#define SPATIAL_ACTION_GO_TO_LOCATION       "Go to Location"
+#define SPATIAL_ACTION_CLOSE_PARENT_FOLDERS "Close Parent Folders"
+#define SPATIAL_ACTION_CLOSE_ALL_FOLDERS    "Close All Folders"
+
 struct _NautilusSpatialWindowDetails {
         GtkActionGroup *spatial_action_group; /* owned by ui_manager */
 	char *last_geometry;	
@@ -407,6 +412,20 @@
 	}
 }
 
+static void
+real_set_allow_up (NautilusWindow *window, gboolean allow)
+{
+	NautilusSpatialWindow *spatial;
+	GtkAction *action;
+
+	spatial = NAUTILUS_SPATIAL_WINDOW (window);
+
+	action = gtk_action_group_get_action (spatial->details->spatial_action_group,
+					      SPATIAL_ACTION_CLOSE_PARENT_FOLDERS);
+	gtk_action_set_sensitive (action, allow);
+
+	NAUTILUS_WINDOW_CLASS (parent_class)->set_allow_up (window, allow);
+}
 
 static void
 location_menu_item_activated_callback (GtkWidget *menu_item,
@@ -660,14 +695,14 @@
 }			   
 
 static GtkActionEntry spatial_entries[] = {
-  { "Places", NULL, N_("_Places") },               /* name, stock id, label */
-  { "Go to Location", NULL, N_("Open _Location..."), /* name, stock id, label */
+  { SPATIAL_ACTION_PLACES, NULL, N_("_Places") },               /* name, stock id, label */
+  { SPATIAL_ACTION_GO_TO_LOCATION, NULL, N_("Open _Location..."), /* name, stock id, label */
     "<control>L", N_("Specify a location to open"),
     G_CALLBACK (action_go_to_location_callback) },
-  { "Close Parent Folders", NULL, N_("Close P_arent Folders"), /* name, stock id, label */
+  { SPATIAL_ACTION_CLOSE_PARENT_FOLDERS, NULL, N_("Close P_arent Folders"), /* name, stock id, label */
     "<control><shift>W", N_("Close this folder's parents"),
     G_CALLBACK (action_close_parent_folders_callback) },
-  { "Close All Folders", NULL, N_("Clos_e All Folders"), /* name, stock id, label */
+  { SPATIAL_ACTION_CLOSE_ALL_FOLDERS, NULL, N_("Clos_e All Folders"), /* name, stock id, label */
     "<control>Q", N_("Close all folder windows"),
     G_CALLBACK (action_close_all_folders_callback) },
 };
@@ -706,7 +745,6 @@
 				 rc_style);
 
 	gtk_widget_show (window->details->location_button);
-
 	hbox = gtk_hbox_new (FALSE, 3);
 	gtk_container_add (GTK_CONTAINER (window->details->location_button), 
 			   hbox);
@@ -792,7 +830,8 @@
 
 	NAUTILUS_WINDOW_CLASS(class)->set_throbber_active =
 		real_set_throbber_active;
-
+	NAUTILUS_WINDOW_CLASS(class)->set_allow_up =
+		real_set_allow_up;
 
 	binding_set = gtk_binding_set_by_class (class);
 	gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, GDK_SHIFT_MASK,
Index: src/nautilus-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window.c,v
retrieving revision 1.445
diff -u -r1.445 nautilus-window.c
--- src/nautilus-window.c	19 Apr 2005 12:01:16 -0000	1.445
+++ src/nautilus-window.c	17 May 2005 09:48:14 -0000
@@ -274,8 +274,9 @@
 	eel_g_list_free_deep (selection);
 }
 
-void
-nautilus_window_allow_up (NautilusWindow *window, gboolean allow)
+static void
+real_set_allow_up (NautilusWindow *window,
+		   gboolean        allow)
 {
 	GtkAction *action;
 	
@@ -290,6 +291,13 @@
 }
 
 void
+nautilus_window_allow_up (NautilusWindow *window, gboolean allow)
+{
+	EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
+			 set_allow_up, (window, allow));
+}
+
+void
 nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
 {
 	GtkAction *action;
@@ -1445,6 +1453,7 @@
 	class->set_title = real_set_title;
 	class->set_content_view_widget = real_set_content_view_widget;
 	class->load_view_as_menu = real_load_view_as_menu;
+	class->set_allow_up = real_set_allow_up;
 
 	g_object_class_install_property (G_OBJECT_CLASS (class),
 					 ARG_APP,
Index: src/nautilus-window.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window.h,v
retrieving revision 1.118
diff -u -r1.118 nautilus-window.h
--- src/nautilus-window.h	22 Mar 2005 09:22:23 -0000	1.118
+++ src/nautilus-window.h	17 May 2005 09:48:14 -0000
@@ -72,6 +72,7 @@
                                             NautilusView *new_view);
         void   (* set_throbber_active) (NautilusWindow *window,
                                         gboolean active);
+	void   (* set_allow_up) (NautilusWindow *window, gboolean allow);
         void   (* prompt_for_location) (NautilusWindow *window);
         void   (* get_default_size) (NautilusWindow *window, guint *default_width, guint *default_height);
         void   (* show_window)  (NautilusWindow *window);


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