[nautilus] Associate basic slot functions to panes instead of windows.



commit e1db3d61f6510a8f6cc063ba84b5fa26bebf6189
Author: Alexander Larsson <alexl redhat com>
Date:   Mon Dec 7 22:20:08 2009 +0100

    Associate basic slot functions to panes instead of windows.

 src/nautilus-application.c             |    4 +-
 src/nautilus-navigation-window-menus.c |    4 +-
 src/nautilus-navigation-window.c       |   23 +++++++--------
 src/nautilus-spatial-window.c          |   16 +++++-----
 src/nautilus-window-manage-views.c     |    4 +-
 src/nautilus-window-manage-views.h     |    5 ++-
 src/nautilus-window-pane.h             |    1 -
 src/nautilus-window-private.h          |    6 ++--
 src/nautilus-window.c                  |   48 ++++++++++++++++++--------------
 src/nautilus-window.h                  |    8 +++--
 10 files changed, 63 insertions(+), 56 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 8b57a83..d638624 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -2001,14 +2001,14 @@ nautilus_application_load_session (NautilusApplication *application)
 								if (i == 0) {
 									slot = window->details->active_pane->active_slot;
 								} else {
-									slot = nautilus_window_open_slot (window, NAUTILUS_WINDOW_OPEN_SLOT_APPEND);
+									slot = nautilus_window_open_slot (window->details->active_pane, NAUTILUS_WINDOW_OPEN_SLOT_APPEND);
 								}
 								
 								location = g_file_new_for_uri (slot_uri);
 								nautilus_window_slot_open_location (slot, location, FALSE);
 								
 								if (xmlHasProp (slot_node, "active")) {
-									nautilus_window_set_active_slot (window, slot);
+									nautilus_window_set_active_slot (slot->pane, slot);
 								}
 								
 								i++;
diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c
index d00b87a..305c16e 100644
--- a/src/nautilus-navigation-window-menus.c
+++ b/src/nautilus-navigation-window-menus.c
@@ -702,8 +702,8 @@ action_new_tab_callback (GtkAction *action,
 		}
 		g_free (scheme);
 
-		new_slot = nautilus_window_open_slot (window, flags);
-		nautilus_window_set_active_slot (window, new_slot);
+		new_slot = nautilus_window_open_slot (current_slot->pane, flags);
+		nautilus_window_set_active_slot (new_slot->pane, new_slot);
 		nautilus_window_slot_go_to (new_slot, location, FALSE);
 		g_object_unref (location);
 	}
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c
index c7207c5..4525991 100644
--- a/src/nautilus-navigation-window.c
+++ b/src/nautilus-navigation-window.c
@@ -203,7 +203,7 @@ notebook_switch_page_cb (GtkNotebook *notebook,
 	slot = nautilus_window_get_slot_for_content_box (nautilus_window, widget);
 	g_assert (slot != NULL);
 
-	nautilus_window_set_active_slot (nautilus_window, slot);
+	nautilus_window_set_active_slot (slot->pane, slot);
 
 	return FALSE;
 }
@@ -1847,23 +1847,22 @@ real_get_default_size (NautilusWindow *window,
 }
 
 static NautilusWindowSlot *
-real_open_slot (NautilusWindow *window,
+real_open_slot (NautilusWindowPane *pane,
 		NautilusWindowOpenSlotFlags flags)
 {
 	NautilusNavigationWindow *navigation_window;
 	NautilusWindowSlot *slot;
 	NautilusNotebook *notebook;
 
-	navigation_window = NAUTILUS_NAVIGATION_WINDOW (window);
+	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 = window->details->active_pane;
+	slot->pane = pane;
 
 	g_signal_handlers_block_by_func (notebook,
 					 G_CALLBACK (notebook_switch_page_cb),
-					 window);
+					 pane->window);
 	nautilus_notebook_add_tab (notebook,
 				   slot,
 				   (flags & NAUTILUS_WINDOW_OPEN_SLOT_APPEND) != 0 ?
@@ -1872,21 +1871,21 @@ real_open_slot (NautilusWindow *window,
 				   FALSE);
 	g_signal_handlers_unblock_by_func (notebook,
 					   G_CALLBACK (notebook_switch_page_cb),
-					   window);
+					   pane->window);
 	gtk_widget_show (slot->content_box);
 
 	return slot;
 }
 
 static void
-real_close_slot (NautilusWindow *window,
+real_close_slot (NautilusWindowPane *pane,
 		 NautilusWindowSlot *slot)
 {
 	NautilusNavigationWindow *navigation_window;
 	GtkNotebook *notebook;
 	int page_num;
 
-	navigation_window = NAUTILUS_NAVIGATION_WINDOW (window);
+	navigation_window = NAUTILUS_NAVIGATION_WINDOW (pane->window);
 	notebook = GTK_NOTEBOOK (navigation_window->notebook);
 
 	page_num = gtk_notebook_page_num (notebook, slot->content_box);
@@ -1894,17 +1893,17 @@ real_close_slot (NautilusWindow *window,
 
 	g_signal_handlers_block_by_func (notebook,
 					 G_CALLBACK (notebook_switch_page_cb),
-					 window);
+					 pane->window);
 	gtk_notebook_remove_page (notebook, page_num);
 	g_signal_handlers_unblock_by_func (notebook,
 					   G_CALLBACK (notebook_switch_page_cb),
-					   window);
+					   pane->window);
 
 	gtk_notebook_set_show_tabs (notebook,
 				    gtk_notebook_get_n_pages (notebook) > 1);
 
 	EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS,
-			 close_slot, (window, slot));
+			 close_slot, (pane, slot));
 }
 
 static void
diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c
index af2aa58..ba36b03 100644
--- a/src/nautilus-spatial-window.c
+++ b/src/nautilus-spatial-window.c
@@ -445,21 +445,21 @@ real_set_allow_up (NautilusWindow *window, gboolean allow)
 }
 
 static NautilusWindowSlot *
-real_open_slot (NautilusWindow *window,
+real_open_slot (NautilusWindowPane *pane,
 		NautilusWindowOpenSlotFlags flags)
 {
 	NautilusWindowSlot *slot;
 	GList *slots;
 
-	g_assert (nautilus_window_get_active_slot (window) == NULL);
+	g_assert (nautilus_window_get_active_slot (pane->window) == NULL);
 
-	slots = nautilus_window_get_slots (window);
+	slots = nautilus_window_get_slots (pane->window);
 	g_assert (slots == NULL);
 	g_list_free (slots);
 
 	slot = g_object_new (NAUTILUS_TYPE_WINDOW_SLOT, NULL);
-	slot->pane = window->details->active_pane;
-	gtk_container_add (GTK_CONTAINER (NAUTILUS_SPATIAL_WINDOW (window)->details->content_box),
+	slot->pane = pane;
+	gtk_container_add (GTK_CONTAINER (NAUTILUS_SPATIAL_WINDOW (pane->window)->details->content_box),
 			   slot->content_box);
 	gtk_widget_show (slot->content_box);
 	return slot;
@@ -474,16 +474,16 @@ save_spatial_data (NautilusWindowSlot *slot)
 }
 
 static void
-real_close_slot (NautilusWindow *window,
+real_close_slot (NautilusWindowPane *pane,
 		 NautilusWindowSlot *slot)
 {
 	/* Save spatial data for close if we didn't already */
-	if (!NAUTILUS_SPATIAL_WINDOW (window)->details->saved_data_on_close) {
+	if (!NAUTILUS_SPATIAL_WINDOW (pane->window)->details->saved_data_on_close) {
 		save_spatial_data (slot);
 	}
 
 	EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS,
-			 close_slot, (window, slot));
+			 close_slot, (pane, slot));
 }
 
 static void
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 9321f80..df6d7e6 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -589,7 +589,7 @@ nautilus_window_slot_open_location_full (NautilusWindowSlot *slot,
 			slot_flags = NAUTILUS_WINDOW_OPEN_SLOT_APPEND;
 		}
 
-		target_slot = nautilus_window_open_slot (window, slot_flags);
+		target_slot = nautilus_window_open_slot (window->details->active_pane, slot_flags);
 	}
 
         if ((flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0) {
@@ -2031,7 +2031,7 @@ nautilus_window_slot_set_content_view (NautilusWindowSlot *slot,
 }
 
 void
-nautilus_window_manage_views_close_slot (NautilusWindow *window,
+nautilus_window_manage_views_close_slot (NautilusWindowPane *pane,
 					 NautilusWindowSlot *slot)
 {
 	if (slot->content_view != NULL) {
diff --git a/src/nautilus-window-manage-views.h b/src/nautilus-window-manage-views.h
index 875edc7..d2a9290 100644
--- a/src/nautilus-window-manage-views.h
+++ b/src/nautilus-window-manage-views.h
@@ -28,10 +28,11 @@
 #define NAUTILUS_WINDOW_MANAGE_VIEWS_H
 
 #include "nautilus-window.h"
+#include "nautilus-window-pane.h"
 #include "nautilus-navigation-window.h"
 
-void                    nautilus_window_manage_views_close_slot       (NautilusWindow           *window,
-								       NautilusWindowSlot       *slot);
+void nautilus_window_manage_views_close_slot (NautilusWindowPane *pane,
+                                              NautilusWindowSlot *slot);
 
 
 /* NautilusWindowInfo implementation: */
diff --git a/src/nautilus-window-pane.h b/src/nautilus-window-pane.h
index 5a370d4..5c205ec 100644
--- a/src/nautilus-window-pane.h
+++ b/src/nautilus-window-pane.h
@@ -35,7 +35,6 @@
 #define NAUTILUS_WINDOW_PANE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NAUTILUS_TYPE_WINDOW_PANE, NautilusWindowPaneClass))
 
 typedef struct _NautilusWindowPaneClass NautilusWindowPaneClass;
-typedef struct _NautilusWindowPane      NautilusWindowPane;
 
 struct _NautilusWindowPaneClass {
 	GObjectClass parent_class;
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index c0e6b66..46531d0 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -185,9 +185,9 @@ void               nautilus_window_zoom_to_level                         (Nautil
                                                                           NautilusZoomLevel  level);
 void               nautilus_window_zoom_to_default                       (NautilusWindow    *window);
 
-NautilusWindowSlot *nautilus_window_open_slot                            (NautilusWindow     *window,
+NautilusWindowSlot *nautilus_window_open_slot                            (NautilusWindowPane *pane,
 									  NautilusWindowOpenSlotFlags flags);
-void                nautilus_window_close_slot                           (NautilusWindow     *window,
+void                nautilus_window_close_slot                           (NautilusWindowPane *pane,
 									  NautilusWindowSlot *slot);
 
 NautilusWindowSlot *nautilus_window_get_slot_for_view                    (NautilusWindow *window,
@@ -197,7 +197,7 @@ NautilusWindowSlot *nautilus_window_get_slot_for_content_box             (Nautil
 
 GList *              nautilus_window_get_slots                           (NautilusWindow    *window);
 NautilusWindowSlot * nautilus_window_get_active_slot                     (NautilusWindow    *window);
-void                 nautilus_window_set_active_slot                     (NautilusWindow     *window,
+void                 nautilus_window_set_active_slot                     (NautilusWindowPane *pane,
 									  NautilusWindowSlot *slot);
 void                 nautilus_window_set_active_pane                     (NautilusWindow *window,
                                                                           NautilusWindowPane *new_pane);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 9e3dfe9..124141f 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -650,8 +650,8 @@ nautilus_window_constructor (GType type,
 
 	window = NAUTILUS_WINDOW (object);
 
-	slot = nautilus_window_open_slot (window, 0);
-	nautilus_window_set_active_slot (window, slot);
+	slot = nautilus_window_open_slot (window->details->active_pane, 0);
+	nautilus_window_set_active_slot (window->details->active_pane, slot);
 
 	return object;
 }
@@ -700,20 +700,21 @@ nautilus_window_close (NautilusWindow *window)
 }
 
 NautilusWindowSlot *
-nautilus_window_open_slot (NautilusWindow *window,
+nautilus_window_open_slot (NautilusWindowPane *pane,
 			   NautilusWindowOpenSlotFlags flags)
 {
 	NautilusWindowSlot *slot;
 
-	g_assert (NAUTILUS_IS_WINDOW (window));
+	g_assert (NAUTILUS_IS_WINDOW_PANE (pane));
+	g_assert (NAUTILUS_IS_WINDOW (pane->window));
 
-	slot = EEL_CALL_METHOD_WITH_RETURN_VALUE (NAUTILUS_WINDOW_CLASS, window,
-						  open_slot, (window, flags));
+	slot = EEL_CALL_METHOD_WITH_RETURN_VALUE (NAUTILUS_WINDOW_CLASS, pane->window,
+						  open_slot, (pane, flags));
 
 	g_assert (NAUTILUS_IS_WINDOW_SLOT (slot));
-	g_assert (window == slot->pane->window);
+	g_assert (pane->window == slot->pane->window);
 
-	window->details->active_pane->slots = g_list_append (window->details->active_pane->slots, slot);
+	pane->slots = g_list_append (pane->slots, slot);
 
 	return slot;
 }
@@ -750,28 +751,29 @@ nautilus_window_close_pane (NautilusWindowPane *pane)
 }
 
 static void
-real_close_slot (NautilusWindow *window,
+real_close_slot (NautilusWindowPane *pane,
 		 NautilusWindowSlot *slot)
 {
-	nautilus_window_manage_views_close_slot (window, slot);
+	nautilus_window_manage_views_close_slot (pane, slot);
 	cancel_view_as_callback (slot);
 	g_object_unref (slot);
 }
 
 void
-nautilus_window_close_slot (NautilusWindow *window,
+nautilus_window_close_slot (NautilusWindowPane *pane,
 			    NautilusWindowSlot *slot)
 {
-	g_assert (NAUTILUS_IS_WINDOW (window));
+	g_assert (NAUTILUS_IS_WINDOW_PANE(pane));
+	g_assert (NAUTILUS_IS_WINDOW (pane->window));
 	g_assert (NAUTILUS_IS_WINDOW_SLOT (slot));
-	g_assert (window == slot->pane->window);
-	g_assert (g_list_find (window->details->active_pane->slots, slot) != NULL);
+	g_assert (pane->window == slot->pane->window);
+	g_assert (g_list_find (pane->slots, slot) != NULL);
 
-	EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
-			 close_slot, (window, slot));
+	EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, pane->window,
+			 close_slot, (pane, slot));
 
-	window->details->active_pane->slots = g_list_remove (window->details->active_pane->slots, slot);
-	window->details->active_pane->active_slots = g_list_remove (window->details->active_pane->active_slots, slot);
+	pane->slots = g_list_remove (pane->slots, slot);
+	pane->active_slots = g_list_remove (pane->active_slots, slot);
 
 }
 
@@ -791,13 +793,17 @@ nautilus_window_set_active_pane (NautilusWindow *window,
 }
 
 void
-nautilus_window_set_active_slot (NautilusWindow *window,
+nautilus_window_set_active_slot (NautilusWindowPane *pane,
 				 NautilusWindowSlot *new_slot)
 {
+	NautilusWindow *window;
 	NautilusWindowSlot *old_slot;
 	NautilusWindowPane *new_pane;
 	GList *walk;
 
+	g_assert (NAUTILUS_IS_WINDOW_PANE (pane));
+
+	window = pane->window;
 	g_assert (NAUTILUS_IS_WINDOW (window));
 
 	/* find the pane that contains the new slot */
@@ -891,11 +897,11 @@ nautilus_window_slot_close (NautilusWindowSlot *slot)
 					next_slot = get_first_inactive_slot (pane);
 				}
 
-				nautilus_window_set_active_slot (pane->window, next_slot);
+				nautilus_window_set_active_slot (pane, next_slot);
 			}
 		}
 
-		nautilus_window_close_slot (window, slot);
+		nautilus_window_close_slot (slot->pane, slot);
 
 		if (g_list_length (window->details->active_pane->slots) == 0) {
 			nautilus_window_close (window);
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index 52ea2d5..3b53f8e 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -60,6 +60,8 @@ typedef struct NautilusWindow NautilusWindow;
 typedef struct NautilusWindowSlot NautilusWindowSlot;
 #endif
 
+typedef struct _NautilusWindowPane      NautilusWindowPane;
+
 typedef struct NautilusWindowSlotClass NautilusWindowSlotClass;
 typedef enum NautilusWindowOpenSlotFlags NautilusWindowOpenSlotFlags;
 
@@ -102,11 +104,11 @@ typedef struct {
         void   (* show_window)  (NautilusWindow *window);
         void   (* close) (NautilusWindow *window);
 
-        NautilusWindowSlot * (* open_slot) (NautilusWindow *window,
+        NautilusWindowSlot * (* open_slot) (NautilusWindowPane *pane,
 					    NautilusWindowOpenSlotFlags flags);
-        void                 (* close_slot) (NautilusWindow *window,
+        void                 (* close_slot) (NautilusWindowPane *pane,
 					     NautilusWindowSlot *slot);
-        void                 (* set_active_slot) (NautilusWindow *window,
+        void                 (* set_active_slot) (NautilusWindowPane *pane,
 						  NautilusWindowSlot *slot);
 
         /* Signals used only for keybindings */



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