[nautilus] Add a NautilusWindowPane to all windows



commit adc0b289f6f92751bd40a6005375eae2a79439c3
Author: Alexander Larsson <alexl redhat com>
Date:   Mon Dec 7 15:17:09 2009 +0100

    Add a NautilusWindowPane to all windows

 src/nautilus-navigation-window.c |    9 ++++++
 src/nautilus-spatial-window.c    |    8 +++++
 src/nautilus-window-private.h    |    2 +-
 src/nautilus-window.c            |   58 ++++++++++++++++++++++++++++++--------
 4 files changed, 64 insertions(+), 13 deletions(-)
---
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c
index 42913bd..eea719a 100644
--- a/src/nautilus-navigation-window.c
+++ b/src/nautilus-navigation-window.c
@@ -346,9 +346,16 @@ nautilus_navigation_window_init (NautilusNavigationWindow *window)
 	GtkWidget *location_bar;
 	GtkToolItem *item;
 	GtkWidget *hbox;
+	NautilusWindow *win;
+	NautilusWindowPane *pane;
+
+	win = NAUTILUS_WINDOW (window);
 
 	window->details = G_TYPE_INSTANCE_GET_PRIVATE (window, NAUTILUS_TYPE_NAVIGATION_WINDOW, NautilusNavigationWindowDetails);
 
+	pane = nautilus_window_pane_new (win);
+	win->details->panes = g_list_prepend (win->details->panes, pane);
+
 	window->details->content_paned = nautilus_horizontal_splitter_new ();
 	gtk_table_attach (GTK_TABLE (NAUTILUS_WINDOW (window)->details->table),
 			  window->details->content_paned,
@@ -469,6 +476,8 @@ nautilus_navigation_window_init (NautilusNavigationWindow *window)
 			  GTK_EXPAND | GTK_FILL | GTK_SHRINK,  0,
 			  0,                                   0);
 
+	nautilus_window_set_active_pane (win, NAUTILUS_WINDOW_PANE (pane));
+
 	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY,
 						  always_use_location_entry_changed,
 						  window, G_OBJECT (window));
diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c
index 3e28954..1d1603b 100644
--- a/src/nautilus-spatial-window.c
+++ b/src/nautilus-spatial-window.c
@@ -963,11 +963,18 @@ nautilus_spatial_window_init (NautilusSpatialWindow *window)
 	const char *ui;
 	int i;
 	GtkWidget *menuitem;
+	NautilusWindow *win;
+	NautilusWindowPane *pane;
 
 	window->details = G_TYPE_INSTANCE_GET_PRIVATE (window,
 						       NAUTILUS_TYPE_SPATIAL_WINDOW,
 						       NautilusSpatialWindowDetails);
 
+	win = NAUTILUS_WINDOW (window);
+
+	pane = nautilus_window_pane_new (win);
+	win->details->panes = g_list_prepend (win->details->panes, pane);
+
 	window->affect_spatial_window_on_next_location_change = TRUE;
 
 	vbox = gtk_vbox_new (FALSE, 0);
@@ -1059,6 +1066,7 @@ nautilus_spatial_window_init (NautilusSpatialWindow *window)
 		menuitem = gtk_ui_manager_get_widget (ui_manager, icon_entries[i]);
 		gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
 	}
+	nautilus_window_set_active_pane (win, pane);
 }
 
 static void
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index 062775a..b344060 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -255,6 +255,6 @@ void               nautilus_navigation_window_set_throbber_active
                                                                                      gboolean                     active);
 void               nautilus_navigation_window_go_back                               (NautilusNavigationWindow    *window);
 void               nautilus_navigation_window_go_forward                            (NautilusNavigationWindow    *window);
-
+void               nautilus_window_close_pane                                       (NautilusWindowPane *pane);
 
 #endif /* NAUTILUS_WINDOW_PRIVATE_H */
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 8acca39..ccc44f7 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -150,6 +150,9 @@ nautilus_window_init (NautilusWindow *window)
 
 	window->details = G_TYPE_INSTANCE_GET_PRIVATE (window, NAUTILUS_TYPE_WINDOW, NautilusWindowDetails);
 
+	window->details->panes = NULL;
+	window->details->active_pane = NULL;
+
 	window->details->show_hidden_files_mode = NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT;
 	
 	/* Set initial window title */
@@ -596,20 +599,17 @@ static void
 nautilus_window_destroy (GtkObject *object)
 {
 	NautilusWindow *window;
-	NautilusWindowSlot *slot;
-	GList *l, *slots;
+	GList *panes_copy;
 
 	window = NAUTILUS_WINDOW (object);
 
-	nautilus_window_set_active_slot (window, NULL);
+	/* close all panes safely */
+	panes_copy = g_list_copy (window->details->panes);
+	g_list_foreach (panes_copy, (GFunc) nautilus_window_close_pane, NULL);
+	g_list_free (panes_copy);
 
-	/* close all slots */
-	slots = g_list_copy (window->details->slots);
-	for (l = slots; l != NULL; l = l->next) {
-		slot = NAUTILUS_WINDOW_SLOT (l->data);
-		nautilus_window_close_slot (window, slot);
-	}
-	g_list_free (slots);
+	/* the panes list should now be empty */
+	g_assert (window->details->panes == NULL);
 
 	GTK_OBJECT_CLASS (nautilus_window_parent_class)->destroy (object);
 }
@@ -707,13 +707,46 @@ nautilus_window_open_slot (NautilusWindow *window,
 						  open_slot, (window, flags));
 
 	g_assert (NAUTILUS_IS_WINDOW_SLOT (slot));
-	g_assert (window == slot->window);
+	g_assert (window == slot->pane->window);
 
 	window->details->slots = g_list_append (window->details->slots, slot);
 
 	return slot;
 }
 
+void
+nautilus_window_close_pane (NautilusWindowPane *pane)
+{
+	NautilusWindow *window;
+	GList *slots_copy;
+
+	g_assert (NAUTILUS_IS_WINDOW_PANE (pane));
+	g_assert (NAUTILUS_IS_WINDOW (pane->window));
+	g_assert (g_list_find (pane->window->details->panes, pane) != NULL);
+
+	window = pane->window;
+
+	/* close all slots safely */
+	slots_copy = g_list_copy (pane->slots);
+	g_list_foreach (slots_copy, (GFunc) nautilus_window_close_slot, NULL);
+	g_list_free (slots_copy);
+
+	/* the slots list should now be empty */
+	g_assert (pane->slots == NULL);
+
+	/* if the pane was active, select the next one, or NULL */
+	if (window->details->active_pane == pane) {
+		if (window->details->panes) {
+			window->details->active_pane = window->details->panes->data;
+		} else {
+			window->details->active_pane = NULL;
+		}
+	}
+
+	window->details->panes = g_list_remove (window->details->panes, pane);
+	g_object_unref (pane);
+}
+
 static void
 real_close_slot (NautilusWindow *window,
 		 NautilusWindowSlot *slot)
@@ -751,7 +784,8 @@ void
 nautilus_window_set_active_pane (NautilusWindow *window,
 				 NautilusWindowPane *new_pane)
 {
-	/* hhb: TODO: not yet implemented */
+	/* hhb: TODO: temporary implementaion */
+	window->details->active_pane = new_pane;
 }
 
 void



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