[nautilus] Implement "Switch to other pane" menu item.



commit a0bd4bc51d556a44ada296b3d3ec22e6c19f04f4
Author: Holger Berndt <berndth gmx de>
Date:   Sat Jun 13 15:45:43 2009 +0200

    Implement "Switch to other pane" menu item.

 src/nautilus-navigation-window-menus.c |   59 ++++++++++++++++++++++++++++++++
 src/nautilus-navigation-window-ui.xml  |    2 +
 src/nautilus-window-pane.c             |   14 +++++++
 src/nautilus-window-pane.h             |    1 +
 src/nautilus-window-private.h          |    1 +
 5 files changed, 77 insertions(+), 0 deletions(-)
---
diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c
index 50b1a04..c766913 100644
--- a/src/nautilus-navigation-window-menus.c
+++ b/src/nautilus-navigation-window-menus.c
@@ -147,6 +147,13 @@ action_clear_history_callback (GtkAction *action,
 }
 
 static void
+action_split_view_switch_next_pane_callback(GtkAction *action, 
+					    gpointer user_data)
+{
+	nautilus_window_pane_switch_to (nautilus_window_get_next_pane (NAUTILUS_WINDOW (user_data)));
+}
+
+static void
 action_show_hide_toolbar_callback (GtkAction *action, 
 				   gpointer user_data)
 {
@@ -475,6 +482,55 @@ nautilus_navigation_window_initialize_go_menu (NautilusNavigationWindow *window)
 				 G_CALLBACK (schedule_refresh_go_menu), window, G_CONNECT_SWAPPED);
 }
 
+void
+nautilus_navigation_window_update_split_view_actions_sensitivity (NautilusNavigationWindow *window)
+{
+	NautilusWindow *win;
+	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;
+
+	g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
+
+	action_group = window->details->navigation_action_group;
+	win = NAUTILUS_WINDOW (window);
+
+	/* collect information */
+	have_multiple_panes = (win->details->panes && win->details->panes->next);
+	if (win->details->active_pane->active_slot) {
+		active_pane_location = nautilus_window_slot_get_location (win->details->active_pane->active_slot);
+	}
+	else {
+		active_pane_location = NULL;
+	}
+	next_pane = nautilus_window_get_next_pane (win);
+	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);
+
+	/* clean up */
+	if (active_pane_location) {
+		g_object_unref (active_pane_location);
+	}
+	if (next_pane_location) {
+		g_object_unref (next_pane_location);
+	}
+}
+
 static void
 update_tab_action_sensitivity (NautilusNavigationWindowPane *pane)
 {
@@ -906,6 +962,9 @@ static const GtkActionEntry navigation_entries[] = {
   /* name, stock id, label */  { "Clear History", NULL, N_("Clea_r History"),
                                  NULL, N_("Clear contents of Go menu and Back/Forward lists"),
                                  G_CALLBACK (action_clear_history_callback) },
+  /* name, stock id, label */  { "SplitViewNextPane", NULL, N_("Switch to other pane"),
+				 NULL, N_("Move focus to the other pane in a split view window"),
+				 G_CALLBACK (action_split_view_switch_next_pane_callback) },                                 
   /* name, stock id, label */  { "Add Bookmark", GTK_STOCK_ADD, N_("_Add Bookmark"),
                                  "<control>d", N_("Add a bookmark for the current location to this menu"),
                                  G_CALLBACK (action_add_bookmark_callback) },
diff --git a/src/nautilus-navigation-window-ui.xml b/src/nautilus-navigation-window-ui.xml
index ca934e7..a77f509 100644
--- a/src/nautilus-navigation-window-ui.xml
+++ b/src/nautilus-navigation-window-ui.xml
@@ -40,6 +40,8 @@
 			<separator/>
 			<menuitem name="Clear History" action="Clear History"/>
 			<separator/>
+            <menuitem name="SplitViewNextPaneMenu" action="SplitViewNextPane"/>
+            <separator/>
 			<placeholder name="History Placeholder"/>
 		</menu>
 		<menu action="Bookmarks">
diff --git a/src/nautilus-window-pane.c b/src/nautilus-window-pane.c
index 1bdeb5c..25cc528 100644
--- a/src/nautilus-window-pane.c
+++ b/src/nautilus-window-pane.c
@@ -171,6 +171,20 @@ nautilus_window_pane_sync_location_widgets (NautilusWindowPane *pane)
 	}
 }
 
+void
+nautilus_window_pane_switch_to (NautilusWindowPane *pane)
+{
+	if (NAUTILUS_IS_WINDOW_PANE (pane)) {
+		GList *children;
+
+		children = gtk_container_get_children (GTK_CONTAINER (pane->active_slot->content_view));
+		if (children) {
+			gtk_widget_grab_focus (GTK_WIDGET (children->data));		
+			g_list_free (children);
+		}
+	}	
+}
+
 static void
 nautilus_window_pane_init (NautilusWindowPane *pane)
 {
diff --git a/src/nautilus-window-pane.h b/src/nautilus-window-pane.h
index 7eb70ab..e73a2fe 100644
--- a/src/nautilus-window-pane.h
+++ b/src/nautilus-window-pane.h
@@ -79,5 +79,6 @@ void nautilus_window_pane_set_active (NautilusWindowPane *pane, gboolean is_acti
 void nautilus_window_pane_slot_close (NautilusWindowPane *pane, NautilusWindowSlot *slot);
 
 NautilusWindowSlot* nautilus_window_pane_get_slot_for_content_box (NautilusWindowPane *pane, GtkWidget *content_box);
+void nautilus_window_pane_switch_to (NautilusWindowPane *pane);
 
 #endif /* NAUTILUS_WINDOW_PANE_H */
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index 9b9cea0..e9e01d7 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -244,5 +244,6 @@ void               nautilus_navigation_window_set_throbber_active
 void               nautilus_navigation_window_go_back                               (NautilusNavigationWindow    *window);
 void               nautilus_navigation_window_go_forward                            (NautilusNavigationWindow    *window);
 void               nautilus_window_close_pane                                       (NautilusWindowPane *pane);
+void               nautilus_navigation_window_update_split_view_actions_sensitivity (NautilusNavigationWindow    *window);
 
 #endif /* NAUTILUS_WINDOW_PRIVATE_H */



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