[nautilus] window: simplify code a bit



commit 4abf11d07e8d8bc86523e105db9c6c76f29e9643
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Feb 6 14:57:30 2012 -0500

    window: simplify code a bit
    
    Don't export nautilus_window_update_split_view_actions_sensitivity(),
    but alwauys call it from nautilus_window_update_show_hide_menu_items(),
    since that's what the code always does.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=669189

 src/nautilus-window-menus.c   |   92 ++++++++++++++++++++--------------------
 src/nautilus-window-private.h |    1 -
 src/nautilus-window.c         |    2 -
 3 files changed, 46 insertions(+), 49 deletions(-)
---
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index 149ba2a..bd1d279 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -639,6 +639,51 @@ action_split_view_callback (GtkAction *action,
 	}
 }
 
+static void
+nautilus_window_update_split_view_actions_sensitivity (NautilusWindow *window)
+{
+	GtkActionGroup *action_group;
+	GtkAction *action;
+	gboolean have_multiple_panes;
+	gboolean next_pane_is_in_same_location;
+	GFile *active_pane_location;
+	GFile *next_pane_location;
+	NautilusWindowPane *next_pane;
+	NautilusWindowSlot *active_slot;
+
+	active_slot = nautilus_window_get_active_slot (window);
+	action_group = nautilus_window_get_main_action_group (window);
+
+	/* collect information */
+	have_multiple_panes = nautilus_window_split_view_showing (window);
+	if (active_slot != NULL) {
+		active_pane_location = nautilus_window_slot_get_location (active_slot);
+	} else {
+		active_pane_location = NULL;
+	}
+
+	next_pane = nautilus_window_get_next_pane (window);
+	if (next_pane && next_pane->active_slot) {
+		next_pane_location = nautilus_window_slot_get_location (next_pane->active_slot);
+		next_pane_is_in_same_location = (active_pane_location && next_pane_location &&
+						 g_file_equal (active_pane_location, next_pane_location));
+	} else {
+		next_pane_location = NULL;
+		next_pane_is_in_same_location = FALSE;
+	}
+
+	/* switch to next pane */
+	action = gtk_action_group_get_action (action_group, "SplitViewNextPane");
+	gtk_action_set_sensitive (action, have_multiple_panes);
+
+	/* same location */
+	action = gtk_action_group_get_action (action_group, "SplitViewSameLocation");
+	gtk_action_set_sensitive (action, have_multiple_panes && !next_pane_is_in_same_location);
+
+	/* clean up */
+	g_clear_object (&active_pane_location);
+	g_clear_object (&next_pane_location);
+}
 
 /* TODO: bind all of this with g_settings_bind and GBinding */
 static guint
@@ -665,6 +710,7 @@ nautilus_window_update_show_hide_menu_items (NautilusWindow *window)
 					      NAUTILUS_ACTION_SHOW_HIDE_EXTRA_PANE);
 	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
 				      nautilus_window_split_view_showing (window));
+	nautilus_window_update_split_view_actions_sensitivity (window);
 
 	action = gtk_action_group_get_action (action_group,
 					      "Sidebar Places");
@@ -742,52 +788,6 @@ nautilus_window_initialize_go_menu (NautilusWindow *window)
 	}
 }
 
-void
-nautilus_window_update_split_view_actions_sensitivity (NautilusWindow *window)
-{
-	GtkActionGroup *action_group;
-	GtkAction *action;
-	gboolean have_multiple_panes;
-	gboolean next_pane_is_in_same_location;
-	GFile *active_pane_location;
-	GFile *next_pane_location;
-	NautilusWindowPane *next_pane;
-	NautilusWindowSlot *active_slot;
-
-	active_slot = nautilus_window_get_active_slot (window);
-	action_group = nautilus_window_get_main_action_group (window);
-
-	/* collect information */
-	have_multiple_panes = nautilus_window_split_view_showing (window);
-	if (active_slot != NULL) {
-		active_pane_location = nautilus_window_slot_get_location (active_slot);
-	} else {
-		active_pane_location = NULL;
-	}
-
-	next_pane = nautilus_window_get_next_pane (window);
-	if (next_pane && next_pane->active_slot) {
-		next_pane_location = nautilus_window_slot_get_location (next_pane->active_slot);
-		next_pane_is_in_same_location = (active_pane_location && next_pane_location &&
-						 g_file_equal (active_pane_location, next_pane_location));
-	} else {
-		next_pane_location = NULL;
-		next_pane_is_in_same_location = FALSE;
-	}
-
-	/* switch to next pane */
-	action = gtk_action_group_get_action (action_group, "SplitViewNextPane");
-	gtk_action_set_sensitive (action, have_multiple_panes);
-
-	/* same location */
-	action = gtk_action_group_get_action (action_group, "SplitViewSameLocation");
-	gtk_action_set_sensitive (action, have_multiple_panes && !next_pane_is_in_same_location);
-
-	/* clean up */
-	g_clear_object (&active_pane_location);
-	g_clear_object (&next_pane_location);
-}
-
 static void
 action_new_window_callback (GtkAction *action,
 			    gpointer user_data)
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index 1cdd96a..e20d835 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -163,6 +163,5 @@ void               nautilus_window_update_show_hide_menu_items           (Nautil
 /* window toolbar */
 void               nautilus_window_close_pane                            (NautilusWindow    *window,
                                                                           NautilusWindowPane *pane);
-void               nautilus_window_update_split_view_actions_sensitivity (NautilusWindow    *window);
 
 #endif /* NAUTILUS_WINDOW_PRIVATE_H */
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 1803afe..1bd9531 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -2075,8 +2075,6 @@ nautilus_window_split_view_off (NautilusWindow *window)
 					      active_pane->action_group);
 
 	nautilus_window_update_show_hide_menu_items (window);
-	nautilus_window_update_split_view_actions_sensitivity (window);
-
 	window_set_search_action_text (window, TRUE);
 }
 



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