[nautilus] Move notebook from window into pane



commit e1fe45ddde92aece9aafdeb2febcfe76178e48b1
Author: Holger Berndt <berndth gmx de>
Date:   Sun May 24 01:00:57 2009 +0200

    Move notebook from window into pane
    
    This is another refactorisation commit. A notebook is also pane
    specific, not window specific. In particular, the following function
    logic has been moved:
    
    notebook_popup_menu_move_left_cb
    notebook_popup_menu_move_right_cb
    notebook_popup_menu_close_cb
    notebook_popup_menu_show
    notebook_tab_close_requested
    notebook_button_press_cb
    notebook_popup_menu_cb
    notebook_switch_page_cb
    nautilus_navigation_window_pane_setup_notebook
    
    The following functions have been renamed:
    
    nautilus_navigation_window_initialize_tabs_menu to nautilus_navigation_window_pane_initialize_tabs_menu
     (also made public)
    
    nautilus_window_get_slot_for_content_box to nautilus_window_pane_get_slot_for_content_box

 src/nautilus-navigation-window-menus.c |  123 ++++++++++--------
 src/nautilus-navigation-window-pane.c  |  214 +++++++++++++++++++++++++++++++
 src/nautilus-navigation-window-pane.h  |   16 ++-
 src/nautilus-navigation-window-slot.c  |    6 +-
 src/nautilus-navigation-window.c       |  220 ++------------------------------
 src/nautilus-navigation-window.h       |    1 -
 src/nautilus-notebook.c                |    3 +-
 src/nautilus-window-pane.c             |   63 +++++++++
 src/nautilus-window-pane.h             |    3 +
 src/nautilus-window-private.h          |   15 +-
 src/nautilus-window.c                  |  111 +++++-----------
 11 files changed, 421 insertions(+), 354 deletions(-)
---
diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c
index e2a00be..f78eab0 100644
--- a/src/nautilus-navigation-window-menus.c
+++ b/src/nautilus-navigation-window-menus.c
@@ -461,17 +461,20 @@ nautilus_navigation_window_initialize_go_menu (NautilusNavigationWindow *window)
 }
 
 static void
-update_tab_action_sensitivity (NautilusNavigationWindow *window)
+update_tab_action_sensitivity (NautilusNavigationWindowPane *pane)
 {
 	GtkActionGroup *action_group;
 	GtkAction *action;
 	NautilusNotebook *notebook;
 	gboolean sensitive;
 	int tab_num;
+    NautilusNavigationWindow *window;
 
-	g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
+	g_assert (NAUTILUS_IS_NAVIGATION_WINDOW_PANE (pane));
 
-	notebook = NAUTILUS_NOTEBOOK (window->notebook);
+    window = NAUTILUS_NAVIGATION_WINDOW (NAUTILUS_WINDOW_PANE (pane)->window);
+    
+	notebook = NAUTILUS_NOTEBOOK (pane->notebook);
 	action_group = window->details->navigation_action_group;
 
 	action = gtk_action_group_get_action (action_group, "TabsPrevious");
@@ -490,7 +493,7 @@ update_tab_action_sensitivity (NautilusNavigationWindow *window)
 	sensitive = nautilus_notebook_can_reorder_current_child_relative (notebook, 1);
 	g_object_set (action, "sensitive", sensitive, NULL);
 
-	action_group = window->details->tabs_menu_action_group;
+	action_group = pane->tabs_menu_action_group;
 	tab_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
 	action = gtk_action_group_get_action (action_group, "Tab0");
 	if (tab_num >= 0 && action != NULL) {
@@ -504,10 +507,10 @@ tab_menu_action_activate_callback (GtkAction *action,
 {
 	int num;
 	GtkWidget *notebook;
-	NautilusNavigationWindow *window;
+	NautilusNavigationWindowPane *pane;
 
-	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
-	notebook = window->notebook;
+	pane = NAUTILUS_NAVIGATION_WINDOW_PANE (user_data);
+	notebook = pane->notebook;
 
 	num = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
 
@@ -515,7 +518,7 @@ tab_menu_action_activate_callback (GtkAction *action,
 }
 
 static void
-reload_tab_menu (NautilusNavigationWindow *window)
+reload_tab_menu (NautilusNavigationWindowPane *pane)
 {
 	GtkRadioAction *action;
 	GtkUIManager *ui_manager;
@@ -526,41 +529,46 @@ reload_tab_menu (NautilusNavigationWindow *window)
 	GSList *radio_group;
 	NautilusWindowSlot *slot;
 	GtkNotebook *notebook;
+	NautilusWindow *window;
+	NautilusNavigationWindow *nav_window;
 	
-	g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
+	g_assert (NAUTILUS_IS_NAVIGATION_WINDOW_PANE (pane));
+
+	window = NAUTILUS_WINDOW_PANE (pane)->window;
+	nav_window = NAUTILUS_NAVIGATION_WINDOW (window);
 
 	/* Remove old tab menu items */
-	ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window));
-	if (window->details->tabs_menu_merge_id != 0) {
+	ui_manager = nautilus_window_get_ui_manager (window);
+	if (pane->tabs_menu_merge_id != 0) {
 		gtk_ui_manager_remove_ui (ui_manager,
-					  window->details->tabs_menu_merge_id);
-		window->details->tabs_menu_merge_id = 0;
+					  pane->tabs_menu_merge_id);
+		pane->tabs_menu_merge_id = 0;
 	}
-	if (window->details->tabs_menu_action_group != NULL) {
+	if (pane->tabs_menu_action_group != NULL) {
 		gtk_ui_manager_remove_action_group (ui_manager,
-						    window->details->tabs_menu_action_group);
-		window->details->tabs_menu_action_group = NULL;
+						    pane->tabs_menu_action_group);
+		pane->tabs_menu_action_group = NULL;
 	}
 
 	/* Add new tab menu items */
-	window->details->tabs_menu_merge_id = gtk_ui_manager_new_merge_id (ui_manager);
-	window->details->tabs_menu_action_group = gtk_action_group_new ("TabsMenuGroup");
+	pane->tabs_menu_merge_id = gtk_ui_manager_new_merge_id (ui_manager);
+	pane->tabs_menu_action_group = gtk_action_group_new ("TabsMenuGroup");
 
-	g_signal_connect (window->details->tabs_menu_action_group, "connect-proxy",
+	g_signal_connect (pane->tabs_menu_action_group, "connect-proxy",
 			  G_CALLBACK (connect_proxy_cb), NULL);
 	
 	gtk_ui_manager_insert_action_group (ui_manager,
-					    window->details->tabs_menu_action_group,
+					    pane->tabs_menu_action_group,
 					    -1);
-	g_object_unref (window->details->tabs_menu_action_group);
+	g_object_unref (pane->tabs_menu_action_group);
 
-	notebook = GTK_NOTEBOOK (window->notebook);
+	notebook = GTK_NOTEBOOK (pane->notebook);
 	radio_group = NULL;
 	for (i = 0; i < gtk_notebook_get_n_pages (notebook); i++) {
 
 		snprintf(action_name, sizeof (action_name), "Tab%d", i);
 
-		slot = nautilus_window_get_slot_for_content_box (NAUTILUS_WINDOW (window),
+		slot = nautilus_window_pane_get_slot_for_content_box (NAUTILUS_WINDOW_PANE (pane),
 								 gtk_notebook_get_nth_page (notebook, i));
 		if (slot) {
 			action_label = g_strdup (slot->title);
@@ -581,7 +589,7 @@ reload_tab_menu (NautilusNavigationWindow *window)
 		
 		g_signal_connect (action, "activate", 
 				  G_CALLBACK (tab_menu_action_activate_callback),
-				  window);
+				  pane);
 
 		/* Use Alt+(Number) keyboard accelerators for first 10 tabs */
 		if (i < 10) {
@@ -589,14 +597,14 @@ reload_tab_menu (NautilusNavigationWindow *window)
 		} else {
 			accelerator[0] = '\0';
 		}
-		gtk_action_group_add_action_with_accel (window->details->tabs_menu_action_group, 
+		gtk_action_group_add_action_with_accel (pane->tabs_menu_action_group, 
 							GTK_ACTION (action),
 							accelerator);
 		
 		g_object_unref (action);
 		
 		gtk_ui_manager_add_ui (ui_manager, 
-				       window->details->tabs_menu_merge_id,
+				       pane->tabs_menu_merge_id,
 				       MENU_PATH_TABS_PLACEHOLDER,
 				       action_name,
 				       action_name,
@@ -604,29 +612,29 @@ reload_tab_menu (NautilusNavigationWindow *window)
 				       FALSE);
 	}
 
-	update_tab_action_sensitivity (window);
+	update_tab_action_sensitivity (pane);
 }
 
-static void 
-nautilus_navigation_window_initialize_tabs_menu (NautilusNavigationWindow *window)
+void 
+nautilus_navigation_window_pane_initialize_tabs_menu (NautilusNavigationWindowPane *pane)
 {
-	g_signal_connect_object (window->notebook, "page-added",
-				 G_CALLBACK (reload_tab_menu), window, G_CONNECT_SWAPPED);
-	g_signal_connect_object (window->notebook, "page-removed",
-				 G_CALLBACK (reload_tab_menu), window, G_CONNECT_SWAPPED);
-	g_signal_connect_object (window->notebook, "page-reordered",
-				 G_CALLBACK (reload_tab_menu), window, G_CONNECT_SWAPPED);
-	g_signal_connect_object (window->notebook, "switch-page",
-				 G_CALLBACK (update_tab_action_sensitivity), window,
+	g_signal_connect_object (pane->notebook, "page-added",
+				 G_CALLBACK (reload_tab_menu), pane, G_CONNECT_SWAPPED);
+	g_signal_connect_object (pane->notebook, "page-removed",
+				 G_CALLBACK (reload_tab_menu), pane, G_CONNECT_SWAPPED);
+	g_signal_connect_object (pane->notebook, "page-reordered",
+				 G_CALLBACK (reload_tab_menu), pane, G_CONNECT_SWAPPED);
+	g_signal_connect_object (pane->notebook, "switch-page",
+				 G_CALLBACK (update_tab_action_sensitivity), pane,
 				 G_CONNECT_SWAPPED | G_CONNECT_AFTER);
 
-	reload_tab_menu (window);
+	reload_tab_menu (pane);
 }
 
 /* Update the label displayed in the "Tabs" menu. This is called when the title of
  * a slot changes. */
 void
-nautilus_navigation_window_sync_tab_menu_title (NautilusNavigationWindow *window,
+nautilus_navigation_window_pane_sync_tab_menu_title (NautilusNavigationWindowPane *pane,
 						NautilusWindowSlot *slot)
 {
 	int tab_num;
@@ -635,7 +643,7 @@ nautilus_navigation_window_sync_tab_menu_title (NautilusNavigationWindow *window
 	GtkActionGroup *action_group;
 	char action_name[80];
 
-	notebook = GTK_NOTEBOOK (window->notebook);
+	notebook = GTK_NOTEBOOK (pane->notebook);
 
 	/* Find the tab number for that slot. It should (almost?) always be the current
 	 * tab, so check that first in order to avoid searching through the entire tab 
@@ -648,7 +656,7 @@ nautilus_navigation_window_sync_tab_menu_title (NautilusNavigationWindow *window
 	g_return_if_fail (tab_num >= 0);
 
 	/* Find the action associated with that tab */
-	action_group = window->details->tabs_menu_action_group;
+	action_group = pane->tabs_menu_action_group;
 	snprintf (action_name, sizeof (action_name), "Tab%d", tab_num);
 	action = gtk_action_group_get_action (action_group, action_name);
 
@@ -820,40 +828,40 @@ static void
 action_tabs_previous_callback (GtkAction *action,
 			       gpointer user_data)
 {
-	NautilusNavigationWindow *window;
+	NautilusNavigationWindowPane *pane;
 
-	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
-	nautilus_notebook_set_current_page_relative (NAUTILUS_NOTEBOOK (window->notebook), -1);
+	pane = NAUTILUS_NAVIGATION_WINDOW_PANE (NAUTILUS_WINDOW (user_data)->details->active_pane);
+	nautilus_notebook_set_current_page_relative (NAUTILUS_NOTEBOOK (pane->notebook), -1);
 }
 
 static void
 action_tabs_next_callback (GtkAction *action,
 			   gpointer user_data)
 {
-	NautilusNavigationWindow *window;
+	NautilusNavigationWindowPane *pane;
 
-	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
-	nautilus_notebook_set_current_page_relative (NAUTILUS_NOTEBOOK (window->notebook), 1);
+	pane = NAUTILUS_NAVIGATION_WINDOW_PANE (NAUTILUS_WINDOW (user_data)->details->active_pane);
+	nautilus_notebook_set_current_page_relative (NAUTILUS_NOTEBOOK (pane->notebook), 1);
 }
 
 static void
 action_tabs_move_left_callback (GtkAction *action,
 				gpointer user_data)
 {
-	NautilusNavigationWindow *window;
+	NautilusNavigationWindowPane *pane;
 
-	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
-	nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (window->notebook), -1);
+	pane = NAUTILUS_NAVIGATION_WINDOW_PANE (NAUTILUS_WINDOW (user_data)->details->active_pane);
+	nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (pane->notebook), -1);
 }
 
 static void
 action_tabs_move_right_callback (GtkAction *action,
 				 gpointer user_data)
 {
-	NautilusNavigationWindow *window;
+	NautilusNavigationWindowPane *pane;
 
-	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
-	nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (window->notebook), 1);
+	pane = NAUTILUS_NAVIGATION_WINDOW_PANE (NAUTILUS_WINDOW (user_data)->details->active_pane);
+	nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (pane->notebook), 1);
 }
 
 static const GtkActionEntry navigation_entries[] = {
@@ -1013,6 +1021,8 @@ nautilus_navigation_window_initialize_actions (NautilusNavigationWindow *window)
 
 	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
 	g_object_unref (action_group); /* owned by ui_manager */
+    
+    /* hhb: updates for split view needed here */
 }
 
 
@@ -1027,6 +1037,7 @@ nautilus_navigation_window_initialize_menus (NautilusNavigationWindow *window)
 {
 	GtkUIManager *ui_manager;
 	const char *ui;
+    GList *walk;
 
 	ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window));
 
@@ -1038,6 +1049,8 @@ nautilus_navigation_window_initialize_menus (NautilusNavigationWindow *window)
 	nautilus_navigation_window_update_tab_menu_item_visibility (window);
 
         nautilus_navigation_window_initialize_go_menu (window);
-        nautilus_navigation_window_initialize_tabs_menu (window);
-}
 
+        for (walk = NAUTILUS_WINDOW(window)->details->panes; walk; walk = walk->next) {
+        	nautilus_navigation_window_pane_initialize_tabs_menu (walk->data);
+        }
+}
diff --git a/src/nautilus-navigation-window-pane.c b/src/nautilus-navigation-window-pane.c
index 9e55d1d..b3edc8a 100644
--- a/src/nautilus-navigation-window-pane.c
+++ b/src/nautilus-navigation-window-pane.c
@@ -27,6 +27,7 @@
 #include "nautilus-navigation-bar.h"
 #include "nautilus-pathbar.h"
 #include "nautilus-location-bar.h"
+#include "nautilus-notebook.h"
 
 #include <libnautilus-private/nautilus-global-preferences.h>
 #include <libnautilus-private/nautilus-window-slot-info.h>
@@ -360,6 +361,219 @@ path_bar_path_set_callback (GtkWidget *widget,
 	g_list_free (children);
 }
 
+static void
+notebook_popup_menu_move_left_cb (GtkMenuItem *menuitem,
+				  gpointer user_data)
+{
+    	NautilusNavigationWindowPane *pane;
+
+	pane = NAUTILUS_NAVIGATION_WINDOW_PANE (user_data);
+	nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (pane->notebook), -1);
+}
+
+static void
+notebook_popup_menu_move_right_cb (GtkMenuItem *menuitem,
+				   gpointer user_data)
+{
+    	NautilusNavigationWindowPane *pane;
+
+	pane = NAUTILUS_NAVIGATION_WINDOW_PANE (user_data);
+	nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (pane->notebook), 1);
+}
+
+static void
+notebook_popup_menu_close_cb (GtkMenuItem *menuitem,
+			      gpointer user_data)
+{
+    	NautilusWindowPane *pane;
+	NautilusWindowSlot *slot;
+
+	pane = NAUTILUS_WINDOW_PANE (user_data);
+	slot = pane->active_slot;
+	nautilus_window_slot_close (slot);
+}
+
+static void
+notebook_popup_menu_show (NautilusNavigationWindowPane *pane,
+			  GdkEventButton *event)
+{
+	GtkWidget *popup;
+	GtkWidget *item;
+	GtkWidget *image;
+	int button, event_time;
+	gboolean can_move_left, can_move_right;
+	NautilusNotebook *notebook;
+	
+	notebook = NAUTILUS_NOTEBOOK (pane->notebook);
+
+	can_move_left = nautilus_notebook_can_reorder_current_child_relative (notebook, -1);
+	can_move_right = nautilus_notebook_can_reorder_current_child_relative (notebook, 1);
+
+	popup = gtk_menu_new();
+
+	item = gtk_menu_item_new_with_mnemonic (_("Move Tab _Left"));
+	g_signal_connect (item, "activate", 
+			  G_CALLBACK (notebook_popup_menu_move_left_cb), 
+			  pane);
+	gtk_menu_shell_append (GTK_MENU_SHELL (popup), 
+		               item);
+	gtk_widget_set_sensitive (item, can_move_left);
+
+	item = gtk_menu_item_new_with_mnemonic (_("Move Tab _Right"));
+	g_signal_connect (item, "activate", 
+			  G_CALLBACK (notebook_popup_menu_move_right_cb), 
+			  pane);
+	gtk_menu_shell_append (GTK_MENU_SHELL (popup), 
+		               item);
+	gtk_widget_set_sensitive (item, can_move_right);
+
+	gtk_menu_shell_append (GTK_MENU_SHELL (popup),
+			       gtk_separator_menu_item_new ());
+
+	item = gtk_image_menu_item_new_with_mnemonic (_("_Close Tab"));
+	image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+	g_signal_connect (item, "activate", 
+			  G_CALLBACK (notebook_popup_menu_close_cb), pane);
+	gtk_menu_shell_append (GTK_MENU_SHELL (popup), 
+		               item);
+
+	gtk_widget_show_all (popup);
+
+	if (event) {
+		button = event->button;
+		event_time = event->time;
+	} else {
+		button = 0;
+		event_time = gtk_get_current_event_time ();
+	}
+	
+	/* TODO is this correct? */
+	gtk_menu_attach_to_widget (GTK_MENU (popup), 
+				   pane->notebook, 
+				   NULL); 
+
+	gtk_menu_popup (GTK_MENU (popup), NULL, NULL, NULL, NULL, 
+			button, event_time);
+}
+
+/* emitted when the user clicks the "close" button of tabs */
+static void
+notebook_tab_close_requested (NautilusNotebook *notebook,
+			      NautilusWindowSlot *slot,
+			      NautilusWindowPane *pane)
+{
+	nautilus_window_pane_slot_close (pane, slot);
+}
+
+static gboolean
+notebook_button_press_cb (GtkWidget *widget,
+			  GdkEventButton *event,
+			  gpointer user_data)
+{
+	NautilusNavigationWindowPane *pane;
+
+	pane = NAUTILUS_NAVIGATION_WINDOW_PANE (user_data);
+	if (GDK_BUTTON_PRESS == event->type && 3 == event->button) {
+		notebook_popup_menu_show (pane, event);
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+static gboolean
+notebook_popup_menu_cb (GtkWidget *widget,
+			gpointer user_data)
+{
+	NautilusNavigationWindowPane *pane;
+
+	pane = NAUTILUS_NAVIGATION_WINDOW_PANE (user_data);
+	notebook_popup_menu_show (pane, NULL);
+	return TRUE;
+}
+
+static gboolean
+notebook_switch_page_cb (GtkNotebook *notebook,
+			 GtkNotebookPage *page,
+			 unsigned int page_num,
+			 NautilusNavigationWindowPane *pane)
+{
+	NautilusWindowSlot *slot;
+	GtkWidget *widget;
+
+	widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (pane->notebook), page_num);
+	g_assert (widget != NULL);
+
+	/* find slot corresponding to the target page */
+	slot = nautilus_window_pane_get_slot_for_content_box (NAUTILUS_WINDOW_PANE (pane), widget);
+	g_assert (slot != NULL);
+
+	nautilus_window_set_active_slot (slot->pane->window, slot);
+
+	return FALSE;
+}
+
+void
+nautilus_navigation_window_pane_setup_notebook (NautilusNavigationWindowPane *pane)
+{
+	pane->notebook = g_object_new (NAUTILUS_TYPE_NOTEBOOK, NULL);
+	g_signal_connect (pane->notebook,
+			  "tab-close-request",
+			  G_CALLBACK (notebook_tab_close_requested),
+			  pane);
+	g_signal_connect_after (pane->notebook,
+				"button_press_event",
+				G_CALLBACK (notebook_button_press_cb),
+				pane);
+	g_signal_connect (pane->notebook, "popup-menu",
+			  G_CALLBACK (notebook_popup_menu_cb),
+			  pane);
+	g_signal_connect (pane->notebook,
+			  "switch-page",
+			  G_CALLBACK (notebook_switch_page_cb),
+			  pane);
+	
+	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (pane->notebook), FALSE);
+	gtk_notebook_set_show_border (GTK_NOTEBOOK (pane->notebook), FALSE);
+	gtk_widget_show (pane->notebook);
+}
+
+void
+nautilus_navigation_window_pane_remove_page (NautilusNavigationWindowPane *pane, int page_num)
+{
+	GtkNotebook *notebook;
+	notebook = GTK_NOTEBOOK (pane->notebook);
+
+	g_signal_handlers_block_by_func (notebook,
+					 G_CALLBACK (notebook_switch_page_cb),
+					 pane);
+	gtk_notebook_remove_page (notebook, page_num);
+	g_signal_handlers_unblock_by_func (notebook,
+					   G_CALLBACK (notebook_switch_page_cb),
+					   pane);
+}
+
+void 
+nautilus_navigation_window_pane_add_slot_in_tab (NautilusNavigationWindowPane *pane, NautilusWindowSlot *slot, NautilusWindowOpenSlotFlags flags)
+{
+	NautilusNotebook *notebook;
+	
+	notebook = NAUTILUS_NOTEBOOK (pane->notebook);
+	g_signal_handlers_block_by_func (notebook,
+					 G_CALLBACK (notebook_switch_page_cb),
+					 pane);
+	nautilus_notebook_add_tab (notebook,
+				   slot,
+				   (flags & NAUTILUS_WINDOW_OPEN_SLOT_APPEND) != 0 ?
+				   -1 :
+				   gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)) + 1,
+				   FALSE);
+	g_signal_handlers_unblock_by_func (notebook,
+					   G_CALLBACK (notebook_switch_page_cb),
+					   pane);
+}
+
 void
 nautilus_navigation_window_pane_sync_location_widgets (NautilusNavigationWindowPane *pane)
 {
diff --git a/src/nautilus-navigation-window-pane.h b/src/nautilus-navigation-window-pane.h
index c22fcb7..e5f4f29 100644
--- a/src/nautilus-navigation-window-pane.h
+++ b/src/nautilus-navigation-window-pane.h
@@ -53,10 +53,16 @@ struct _NautilusNavigationWindowPane {
     GtkWidget *path_bar;
     GtkWidget *search_bar;
 
-    /* Location bar */
     gboolean temporary_navigation_bar;
     gboolean temporary_location_bar;
-    gboolean temporary_search_bar;    
+    gboolean temporary_search_bar;
+    
+    /* notebook */
+    GtkWidget *notebook;
+    
+	/* tab menu */
+	GtkActionGroup *tabs_menu_action_group;
+	guint tabs_menu_merge_id;    
 };
 
 GType    nautilus_navigation_window_pane_get_type (void);
@@ -80,7 +86,9 @@ void     nautilus_navigation_window_pane_always_use_location_entry (NautilusNavi
 gboolean nautilus_navigation_window_pane_hide_temporary_bars (NautilusNavigationWindowPane *pane);
 void     nautilus_navigation_window_pane_sync_location_widgets (NautilusNavigationWindowPane *pane);
 void     nautilus_navigation_window_pane_set_active (NautilusNavigationWindowPane *pane, gboolean is_active);
-
-NautilusNavigationWindowPane* nautilus_navigation_window_pane_new (NautilusWindow *window);
+/* notebook */
+void     nautilus_navigation_window_pane_setup_notebook (NautilusNavigationWindowPane *pane);
+void     nautilus_navigation_window_pane_add_slot_in_tab (NautilusNavigationWindowPane *pane, NautilusWindowSlot *slot, NautilusWindowOpenSlotFlags flags);
+void     nautilus_navigation_window_pane_remove_page (NautilusNavigationWindowPane *pane, int page_num);
 
 #endif /* NAUTILUS_NAVIGATION_WINDOW_PANE_H */
diff --git a/src/nautilus-navigation-window-slot.c b/src/nautilus-navigation-window-slot.c
index bdfeae3..65bcfb5 100644
--- a/src/nautilus-navigation-window-slot.c
+++ b/src/nautilus-navigation-window-slot.c
@@ -173,16 +173,18 @@ nautilus_navigation_window_slot_active (NautilusWindowSlot *slot)
 {
 	NautilusNavigationWindow *window;
 	NautilusNavigationWindowSlot *navigation_slot;
+    NautilusNavigationWindowPane *pane;
 	int page_num;
 
 	navigation_slot = NAUTILUS_NAVIGATION_WINDOW_SLOT (slot);
+    pane = NAUTILUS_NAVIGATION_WINDOW_PANE (slot->pane);
 	window = NAUTILUS_NAVIGATION_WINDOW (slot->pane->window);
 
-	page_num = gtk_notebook_page_num (GTK_NOTEBOOK (window->notebook),
+	page_num = gtk_notebook_page_num (GTK_NOTEBOOK (pane->notebook),
 					  slot->content_box);
 	g_assert (page_num >= 0);
 
-	gtk_notebook_set_current_page (GTK_NOTEBOOK (window->notebook), page_num);
+	gtk_notebook_set_current_page (GTK_NOTEBOOK (pane->notebook), page_num);
 
 	EEL_CALL_PARENT (NAUTILUS_WINDOW_SLOT_CLASS, active, (slot));
 
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c
index ca9d4a0..f0f3a7f 100644
--- a/src/nautilus-navigation-window.c
+++ b/src/nautilus-navigation-window.c
@@ -133,160 +133,6 @@ nautilus_navigation_window_hide_temporary_bars (NautilusNavigationWindow *window
 	return any;
 }
 
-static gboolean
-notebook_switch_page_cb (GtkNotebook *notebook,
-			 GtkNotebookPage *page,
-			 unsigned int page_num,
-			 NautilusNavigationWindow *window)
-{
-	NautilusWindow *nautilus_window;
-	NautilusWindowSlot *slot;
-	GtkWidget *widget;
-
-	nautilus_window = NAUTILUS_WINDOW (window);
-
-	widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (window->notebook), page_num);
-	g_assert (widget != NULL);
-
-	/* find slot corresponding to the target page */
-	slot = nautilus_window_get_slot_for_content_box (nautilus_window, widget);
-	g_assert (slot != NULL);
-
-	nautilus_window_set_active_slot (slot->pane->window, slot);
-
-	return FALSE;
-}
-
-/* emitted when the user clicks the "close" button of tabs */
-static void
-notebook_tab_close_requested (NautilusNotebook *notebook,
-			      NautilusWindowSlot *slot,
-			      NautilusWindow *window)
-{
-	g_assert (slot->pane->window == window);
-	nautilus_window_slot_close (slot);
-}
-
-static void
-notebook_popup_menu_move_left_cb (GtkMenuItem *menuitem,
-				  gpointer user_data)
-{
-    	NautilusNavigationWindow *window;
-
-	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
-	nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (window->notebook), -1);
-}
-
-static void
-notebook_popup_menu_move_right_cb (GtkMenuItem *menuitem,
-				   gpointer user_data)
-{
-    	NautilusNavigationWindow *window;
-
-	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
-	nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (window->notebook), 1);
-}
-
-static void
-notebook_popup_menu_close_cb (GtkMenuItem *menuitem,
-			      gpointer user_data)
-{
-    	NautilusNavigationWindow *window;
-	NautilusWindowSlot *slot;
-
-	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
-	slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (window));
-	nautilus_window_slot_close (slot);
-}
-
-static void
-notebook_popup_menu_show (NautilusNavigationWindow *window,
-			  GdkEventButton *event)
-{
-	GtkWidget *popup;
-	GtkWidget *item;
-	GtkWidget *image;
-	int button, event_time;
-	gboolean can_move_left, can_move_right;
-
-	can_move_left = nautilus_notebook_can_reorder_current_child_relative (NAUTILUS_NOTEBOOK (window->notebook), -1);
-	can_move_right = nautilus_notebook_can_reorder_current_child_relative (NAUTILUS_NOTEBOOK (window->notebook), 1);
-
-	popup = gtk_menu_new();
-
-	item = gtk_menu_item_new_with_mnemonic (_("Move Tab _Left"));
-	g_signal_connect (item, "activate", 
-			  G_CALLBACK (notebook_popup_menu_move_left_cb), 
-			  window);
-	gtk_menu_shell_append (GTK_MENU_SHELL (popup), 
-		               item);
-	gtk_widget_set_sensitive (item, can_move_left);
-
-	item = gtk_menu_item_new_with_mnemonic (_("Move Tab _Right"));
-	g_signal_connect (item, "activate", 
-			  G_CALLBACK (notebook_popup_menu_move_right_cb), 
-			  window);
-	gtk_menu_shell_append (GTK_MENU_SHELL (popup), 
-		               item);
-	gtk_widget_set_sensitive (item, can_move_right);
-
-	gtk_menu_shell_append (GTK_MENU_SHELL (popup),
-			       gtk_separator_menu_item_new ());
-
-	item = gtk_image_menu_item_new_with_mnemonic (_("_Close Tab"));
-	image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
-	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-	g_signal_connect (item, "activate", 
-			  G_CALLBACK (notebook_popup_menu_close_cb), window);
-	gtk_menu_shell_append (GTK_MENU_SHELL (popup), 
-		               item);
-
-	gtk_widget_show_all (popup);
-
-	if (event) {
-		button = event->button;
-		event_time = event->time;
-	} else {
-		button = 0;
-		event_time = gtk_get_current_event_time ();
-	}
-	
-	/* TODO is this correct? */
-	gtk_menu_attach_to_widget (GTK_MENU (popup), 
-				   GTK_WIDGET (window->notebook), 
-				   NULL); 
-
-	gtk_menu_popup (GTK_MENU (popup), NULL, NULL, NULL, NULL, 
-			button, event_time);
-}
-
-static gboolean
-notebook_popup_menu_cb (GtkWidget *widget,
-			gpointer user_data)
-{
-	NautilusNavigationWindow *window;
-
-	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
-	notebook_popup_menu_show (window, NULL);
-	return TRUE;
-}
-
-static gboolean
-notebook_button_press_cb (GtkWidget *widget,
-			  GdkEventButton *event,
-			  gpointer user_data)
-{
-	NautilusNavigationWindow *window;
-
-	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
-	if (GDK_BUTTON_PRESS == event->type && 3 == event->button) {
-		notebook_popup_menu_show (window, event);
-		return TRUE;
-	}
-
-	return FALSE;
-}
-
 static void
 nautilus_navigation_window_init (NautilusNavigationWindow *window)
 {
@@ -311,31 +157,15 @@ nautilus_navigation_window_init (NautilusNavigationWindow *window)
 			  0,                                  0);
 	gtk_widget_show (window->details->content_paned);
 
-	window->notebook = g_object_new (NAUTILUS_TYPE_NOTEBOOK, NULL);
-	g_signal_connect (window->notebook,
-			  "tab-close-request",
-			  G_CALLBACK (notebook_tab_close_requested),
-			  window);
-	g_signal_connect_after (window->notebook,
-				"button_press_event",
-				G_CALLBACK (notebook_button_press_cb),
-				window);
-	g_signal_connect (window->notebook, "popup-menu",
-			  G_CALLBACK (notebook_popup_menu_cb),
-			  window);
-	nautilus_horizontal_splitter_pack2 (
+    nautilus_navigation_window_pane_setup_notebook (pane);
+	
+    nautilus_horizontal_splitter_pack2 (
 		NAUTILUS_HORIZONTAL_SPLITTER (window->details->content_paned),
-		window->notebook);
-	g_signal_connect (window->notebook,
-			  "switch-page",
-			  G_CALLBACK (notebook_switch_page_cb),
-			  window);
-	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->notebook), FALSE);
-	gtk_notebook_set_show_border (GTK_NOTEBOOK (window->notebook), FALSE);
-	gtk_widget_show (window->notebook);
+		pane->notebook);
 
     nautilus_navigation_window_pane_setup_location_bar(pane);
     gtk_widget_show (pane->location_bar);
+
 	gtk_table_attach (GTK_TABLE (NAUTILUS_WINDOW (window)->details->table),
 			  pane->location_bar,
 			  /* X direction */                    /* Y direction */
@@ -917,10 +747,10 @@ real_sync_title (NautilusWindow *window,
 		g_free (full_title);
 	}
 
-	notebook = NAUTILUS_NOTEBOOK (navigation_window->notebook);
+	notebook = NAUTILUS_NOTEBOOK (NAUTILUS_NAVIGATION_WINDOW_PANE (slot->pane)->notebook);
 	nautilus_notebook_sync_tab_label (notebook, slot);
 
-	nautilus_navigation_window_sync_tab_menu_title (navigation_window, slot);
+	nautilus_navigation_window_pane_sync_tab_menu_title (NAUTILUS_NAVIGATION_WINDOW_PANE (nautilus_window_get_pane_from_slot (window, slot)), slot);
 }
 
 static NautilusIconInfo *
@@ -940,7 +770,7 @@ real_sync_allow_stop (NautilusWindow *window,
 	navigation_window = NAUTILUS_NAVIGATION_WINDOW (window);
 	nautilus_navigation_window_set_throbber_active (navigation_window, slot->allow_stop);
 
-	notebook = NAUTILUS_NOTEBOOK (navigation_window->notebook);
+	notebook = NAUTILUS_NOTEBOOK (NAUTILUS_NAVIGATION_WINDOW_PANE (slot->pane)->notebook);
 	nautilus_notebook_sync_loading (notebook, slot);
 }
 
@@ -1348,28 +1178,12 @@ static NautilusWindowSlot *
 real_open_slot (NautilusWindowPane *pane,
 		NautilusWindowOpenSlotFlags flags)
 {
-	NautilusNavigationWindow *navigation_window;
 	NautilusWindowSlot *slot;
-	NautilusNotebook *notebook;
-
-	navigation_window = NAUTILUS_NAVIGATION_WINDOW (pane->window);
-	notebook = NAUTILUS_NOTEBOOK (navigation_window->notebook);
 
 	slot = (NautilusWindowSlot *) g_object_new (NAUTILUS_TYPE_NAVIGATION_WINDOW_SLOT, NULL);
 	slot->pane = pane;
 
-	g_signal_handlers_block_by_func (notebook,
-					 G_CALLBACK (notebook_switch_page_cb),
-					 pane->window);
-	nautilus_notebook_add_tab (notebook,
-				   slot,
-				   (flags & NAUTILUS_WINDOW_OPEN_SLOT_APPEND) != 0 ?
-				   -1 :
-				   gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)) + 1,
-				   FALSE);
-	g_signal_handlers_unblock_by_func (notebook,
-					   G_CALLBACK (notebook_switch_page_cb),
-					   pane->window);
+	nautilus_navigation_window_pane_add_slot_in_tab (NAUTILUS_NAVIGATION_WINDOW_PANE (pane), slot, flags);
 	gtk_widget_show (slot->content_box);
 
 	return slot;
@@ -1379,23 +1193,15 @@ static void
 real_close_slot (NautilusWindowPane *pane,
 		 NautilusWindowSlot *slot)
 {
-	NautilusNavigationWindow *navigation_window;
-	GtkNotebook *notebook;
 	int page_num;
+	GtkNotebook *notebook;
 
-	navigation_window = NAUTILUS_NAVIGATION_WINDOW (pane->window);
-	notebook = GTK_NOTEBOOK (navigation_window->notebook);
+	notebook = GTK_NOTEBOOK (NAUTILUS_NAVIGATION_WINDOW_PANE (pane)->notebook);
 
 	page_num = gtk_notebook_page_num (notebook, slot->content_box);
 	g_assert (page_num >= 0);
-
-	g_signal_handlers_block_by_func (notebook,
-					 G_CALLBACK (notebook_switch_page_cb),
-					 pane->window);
-	gtk_notebook_remove_page (notebook, page_num);
-	g_signal_handlers_unblock_by_func (notebook,
-					   G_CALLBACK (notebook_switch_page_cb),
-					   pane->window);
+	
+	nautilus_navigation_window_pane_remove_page (NAUTILUS_NAVIGATION_WINDOW_PANE (pane), page_num);
 
 	gtk_notebook_set_show_tabs (notebook,
 				    gtk_notebook_get_n_pages (notebook) > 1);
diff --git a/src/nautilus-navigation-window.h b/src/nautilus-navigation-window.h
index 25476f4..42bef4f 100644
--- a/src/nautilus-navigation-window.h
+++ b/src/nautilus-navigation-window.h
@@ -63,7 +63,6 @@ struct _NautilusNavigationWindow {
         
         /** UI stuff **/
         NautilusSidePane *sidebar;
-        GtkWidget *notebook;
 
         /* Current views stuff */
         GList *sidebar_panels;
diff --git a/src/nautilus-notebook.c b/src/nautilus-notebook.c
index 9a67ae5..7ee7396 100644
--- a/src/nautilus-notebook.c
+++ b/src/nautilus-notebook.c
@@ -32,6 +32,7 @@
 #include "nautilus-window-private.h"
 #include "nautilus-window-slot.h"
 #include "ephy-spinner.h"
+#include "nautilus-navigation-window-pane.h"
 #include <libnautilus-private/nautilus-dnd.h>
 
 #include <glib/gi18n.h>
@@ -128,7 +129,7 @@ find_notebook_at_pointer (gint abs_x, gint abs_y)
 	/* toplevel should be an NautilusWindow */
 	if (toplevel != NULL && NAUTILUS_IS_NAVIGATION_WINDOW (toplevel))
 	{
-		return NAUTILUS_NOTEBOOK (NAUTILUS_NAVIGATION_WINDOW (toplevel)->notebook);
+		return NAUTILUS_NOTEBOOK (NAUTILUS_NAVIGATION_WINDOW_PANE (NAUTILUS_WINDOW (toplevel)->details->active_pane)->notebook);
 	}
 
 	return NULL;
diff --git a/src/nautilus-window-pane.c b/src/nautilus-window-pane.c
index 43ef05b..e853906 100644
--- a/src/nautilus-window-pane.c
+++ b/src/nautilus-window-pane.c
@@ -36,6 +36,23 @@ G_DEFINE_TYPE (NautilusWindowPane,
 	       G_TYPE_OBJECT)
 #define parent_class nautilus_window_pane_parent_class
 
+
+static inline NautilusWindowSlot *
+get_first_inactive_slot (NautilusWindowPane *pane)
+{
+	GList *l;
+	NautilusWindowSlot *slot;
+
+	for (l = pane->slots; l != NULL; l = l->next) {
+		slot = NAUTILUS_WINDOW_SLOT (l->data);
+		if (slot != pane->active_slot) {
+			return slot;
+		}
+	}
+
+	return NULL;
+}
+
 void
 nautilus_window_pane_zoom_in (NautilusWindowPane *pane)
 {
@@ -98,6 +115,35 @@ nautilus_window_pane_zoom_to_default (NautilusWindowPane *pane)
 }
 
 void
+nautilus_window_pane_slot_close (NautilusWindowPane *pane, NautilusWindowSlot *slot)
+{
+	NautilusWindowSlot *next_slot;
+
+	if (pane->window) {
+		if (pane->active_slot == slot) {
+			g_assert (pane->active_slots != NULL);
+			g_assert (pane->active_slots->data == slot);
+
+			next_slot = NULL;
+			if (pane->active_slots->next != NULL) {
+				next_slot = NAUTILUS_WINDOW_SLOT (pane->active_slots->next->data);
+			}
+
+			if (next_slot == NULL) {
+				next_slot = get_first_inactive_slot (NAUTILUS_WINDOW_PANE (pane));
+			}
+
+			nautilus_window_set_active_slot (pane->window, next_slot);
+		}
+		nautilus_window_close_slot (slot);
+
+		if (g_list_length (pane->window->details->active_pane->slots) == 0) {
+			nautilus_window_close (pane->window);
+		}
+	}
+}
+
+void
 nautilus_window_pane_sync_location_widgets (NautilusWindowPane *pane)
 {
 	if (NAUTILUS_IS_NAVIGATION_WINDOW_PANE (pane)) {
@@ -170,3 +216,20 @@ nautilus_window_pane_new (NautilusWindow *window)
 	pane->window = window;
 	return pane;
 }
+
+NautilusWindowSlot *
+nautilus_window_pane_get_slot_for_content_box (NautilusWindowPane *pane,
+					       GtkWidget *content_box)
+{
+	NautilusWindowSlot *slot;
+	GList *l;
+
+	for (l = pane->slots; l != NULL; l = l->next) {
+		slot = NAUTILUS_WINDOW_SLOT (l->data);
+
+		if (slot->content_box == content_box) {
+			return slot;
+		}
+	}
+	return NULL;
+}
diff --git a/src/nautilus-window-pane.h b/src/nautilus-window-pane.h
index a5424ff..7c72b3d 100644
--- a/src/nautilus-window-pane.h
+++ b/src/nautilus-window-pane.h
@@ -76,5 +76,8 @@ void nautilus_window_pane_zoom_out (NautilusWindowPane *pane);
 void nautilus_window_pane_zoom_to_default (NautilusWindowPane *pane);
 void nautilus_window_pane_sync_location_widgets (NautilusWindowPane *pane);
 void nautilus_window_pane_set_active (NautilusWindowPane *pane, gboolean is_active);
+void nautilus_window_pane_slot_close (NautilusWindowPane *pane, NautilusWindowSlot *slot);
+
+NautilusWindowSlot* nautilus_window_pane_get_slot_for_content_box (NautilusWindowPane *pane, GtkWidget *content_box);
 
 #endif /* NAUTILUS_WINDOW_PANE_H */
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index 3afc9ff..ef9aaa3 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -36,6 +36,8 @@
 
 #include <libnautilus-private/nautilus-directory.h>
 
+struct _NautilusNavigationWindowPane;
+
 /* FIXME bugzilla.gnome.org 42575: Migrate more fields into here. */
 struct NautilusWindowDetails
 {
@@ -95,9 +97,6 @@ struct _NautilusNavigationWindowDetails {
 	guint refresh_go_menu_idle_id;
         guint go_menu_merge_id;
         
-	GtkActionGroup *tabs_menu_action_group;
-	guint tabs_menu_merge_id;
-
         /* Toolbar */
         GtkWidget *toolbar;
 
@@ -157,6 +156,7 @@ void               nautilus_window_set_status                            (Nautil
 void               nautilus_window_load_view_as_menus                    (NautilusWindow    *window);
 void               nautilus_window_load_extension_menus                  (NautilusWindow    *window);
 void               nautilus_window_initialize_menus                      (NautilusWindow    *window);
+void               nautilus_navigation_window_pane_initialize_tabs_menu  (struct _NautilusNavigationWindowPane *pane);
 void               nautilus_window_remove_trash_monitor_callback         (NautilusWindow    *window);
 void               nautilus_menus_append_bookmark_to_menu                (NautilusWindow    *window, 
                                                                           NautilusBookmark  *bookmark, 
@@ -179,13 +179,10 @@ void               nautilus_window_zoom_to_default                       (Nautil
 
 NautilusWindowSlot *nautilus_window_open_slot                            (NautilusWindowPane *pane,
 									  NautilusWindowOpenSlotFlags flags);
-void                nautilus_window_close_slot                           (NautilusWindowPane *pane,
-									  NautilusWindowSlot *slot);
+void                nautilus_window_close_slot                           (NautilusWindowSlot *slot);
 
 NautilusWindowSlot *nautilus_window_get_slot_for_view                    (NautilusWindow *window,
 									  NautilusView   *view);
-NautilusWindowSlot *nautilus_window_get_slot_for_content_box             (NautilusWindow *window,
-									  GtkWidget *content_box);
 
 GList *              nautilus_window_get_slots                           (NautilusWindow    *window);
 NautilusWindowSlot * nautilus_window_get_active_slot                     (NautilusWindow    *window);
@@ -205,6 +202,8 @@ gboolean           nautilus_add_to_history_list_no_notify                (GFile
 GList *            nautilus_get_history_list                             (void);
 void               nautilus_window_bookmarks_preference_changed_callback (gpointer           user_data);
 void               nautilus_window_constructed                           (NautilusWindow    *window);
+NautilusWindowPane* nautilus_window_get_pane_from_slot                   (NautilusWindow *window,
+									  NautilusWindowSlot *slot);
 
 
 /* sync window GUI with current slot. Used when changing slots,
@@ -227,7 +226,7 @@ void               nautilus_navigation_window_remove_bookmarks_menu_items
 void               nautilus_navigation_window_update_show_hide_menu_items           (NautilusNavigationWindow     *window);
 void               nautilus_navigation_window_update_spatial_menu_item              (NautilusNavigationWindow     *window);
 void               nautilus_navigation_window_update_tab_menu_item_visibility       (NautilusNavigationWindow     *window);
-void               nautilus_navigation_window_sync_tab_menu_title                   (NautilusNavigationWindow     *window,
+void               nautilus_navigation_window_pane_sync_tab_menu_title              (struct _NautilusNavigationWindowPane *pane,
 										     NautilusWindowSlot           *slot);
 void               nautilus_navigation_window_remove_go_menu_callback    (NautilusNavigationWindow    *window);
 void               nautilus_navigation_window_remove_go_menu_items       (NautilusNavigationWindow    *window);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 8a5e2ee..ce2bf84 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -712,7 +712,7 @@ nautilus_window_close_pane (NautilusWindowPane *pane)
 	while (pane->slots != NULL) {
 		NautilusWindowSlot *slot = pane->slots->data;
 
-		nautilus_window_close_slot (pane, slot);
+		nautilus_window_close_slot (slot);
 	}
 
 	window = pane->window;
@@ -741,17 +741,19 @@ real_close_slot (NautilusWindowPane *pane,
 }
 
 void
-nautilus_window_close_slot (NautilusWindowPane *pane,
-			    NautilusWindowSlot *slot)
+nautilus_window_close_slot (NautilusWindowSlot *slot)
 {
-	g_assert (NAUTILUS_IS_WINDOW_PANE(pane));
-	g_assert (NAUTILUS_IS_WINDOW (pane->window));
+	NautilusWindowPane *pane;
+	
 	g_assert (NAUTILUS_IS_WINDOW_SLOT (slot));
-	g_assert (pane->window == slot->pane->window);
-	g_assert (g_list_find (pane->slots, slot) != NULL);
+	g_assert (NAUTILUS_IS_WINDOW_PANE(slot->pane));
+	g_assert (g_list_find (slot->pane->slots, slot) != NULL);
 
-	EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, pane->window,
-			 close_slot, (pane, slot));
+	/* save pane because slot is not valid anymore after this call */
+	pane = slot->pane;
+	
+	EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, slot->pane->window,
+			 close_slot, (slot->pane, slot));
 
 	pane->slots = g_list_remove (pane->slots, slot);
 	pane->active_slots = g_list_remove (pane->active_slots, slot);
@@ -871,55 +873,10 @@ nautilus_window_set_active_slot (NautilusWindow *window, NautilusWindowSlot *new
 	}
 }
 
-static inline NautilusWindowSlot *
-get_first_inactive_slot (NautilusWindowPane *pane)
-{
-	GList *l;
-	NautilusWindowSlot *slot;
-
-	for (l = pane->slots; l != NULL; l = l->next) {
-		slot = NAUTILUS_WINDOW_SLOT (l->data);
-		if (slot != pane->active_slot) {
-			return slot;
-		}
-	}
-
-	return NULL;
-}
-
 void
 nautilus_window_slot_close (NautilusWindowSlot *slot)
 {
-	NautilusWindow *window;
-	NautilusWindowSlot *next_slot;
-	GList *walk;
-
-	window = slot->pane->window;
-	if (window != NULL) {
-		for (walk = window->details->panes; walk; walk = walk->next) {
-			NautilusWindowPane *pane = walk->data;
-			if (pane->active_slot == slot) {
-				g_assert (pane->active_slots != NULL);
-
-				next_slot = NULL;
-				if (pane->active_slots->next != NULL) {
-					next_slot = NAUTILUS_WINDOW_SLOT (pane->active_slots->next->data);
-				}
-
-				if (next_slot == NULL) {
-					next_slot = get_first_inactive_slot (pane);
-				}
-
-				nautilus_window_set_active_slot (pane->window, next_slot);
-			}
-		}
-
-		nautilus_window_close_slot (slot->pane, slot);
-
-		if (g_list_length (window->details->active_pane->slots) == 0) {
-			nautilus_window_close (window);
-		}
-	}
+    nautilus_window_pane_slot_close (slot->pane, slot);
 }
 
 static void
@@ -1697,27 +1654,6 @@ nautilus_window_get_slot_for_view (NautilusWindow *window,
 	return NULL;
 }
 
-NautilusWindowSlot *
-nautilus_window_get_slot_for_content_box (NautilusWindow *window,
-					  GtkWidget *content_box)
-{
-	NautilusWindowSlot *slot;
-	GList *l, *walk;
-
-	for (walk = window->details->panes; walk; walk = walk->next) {
-		NautilusWindowPane *pane = walk->data;
-		for (l = pane->slots; l != NULL; l = l->next) {
-			slot = NAUTILUS_WINDOW_SLOT (l->data);
-
-			if (slot->content_box == content_box) {
-				return slot;
-			}
-		}
-	}
-
-	return NULL;
-}
-
 void
 nautilus_forget_history (void) 
 {
@@ -1857,6 +1793,29 @@ nautilus_window_get_bookmark_list (NautilusWindowInfo *window)
   return nautilus_get_bookmark_list ();
 }
 
+NautilusWindowPane*
+nautilus_window_get_pane_from_slot (NautilusWindow *window, NautilusWindowSlot *slot)
+{
+	GList *walk, *wSlot;
+	
+	/* check active slot on active pane first */
+	if (slot == window->details->active_pane->active_slot) {
+		return window->details->active_pane;
+	}
+	for (walk = window->details->panes; walk; walk = walk->next) {
+		NautilusWindowPane *pane = walk->data;
+		if (pane->active_slot == slot) {
+			return pane;
+		}
+		for (wSlot = pane->slots; wSlot; wSlot = wSlot->next) {
+			if (wSlot->data == slot) {
+				return pane;
+			}
+		}
+	}
+	return NULL;
+}
+
 static char *
 nautilus_window_get_cached_title (NautilusWindow *window)
 {



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