[nautilus] Let <control>w close the extra pane



commit fc18d0bfc4f6001be311be63993a90129f02520a
Author: Holger Berndt <hb gnome org>
Date:   Tue Apr 6 21:07:36 2010 -0400

    Let <control>w close the extra pane
    
    The keybinding <control>w closes the active slot until no slot is
    remaining, in which case it closes the window. This commit includes
    the extra pane layer in this chain.
    
    Fixes bug 615593

 src/nautilus-window-pane.c |   23 ++++++++++++++++++++---
 src/nautilus-window.c      |   16 +++++++---------
 2 files changed, 27 insertions(+), 12 deletions(-)
---
diff --git a/src/nautilus-window-pane.c b/src/nautilus-window-pane.c
index acb8657..ecb9308 100644
--- a/src/nautilus-window-pane.c
+++ b/src/nautilus-window-pane.c
@@ -129,6 +129,8 @@ nautilus_window_pane_slot_close (NautilusWindowPane *pane, NautilusWindowSlot *s
 	NautilusWindowSlot *next_slot;
 
 	if (pane->window) {
+		NautilusWindow *window;
+		window = pane->window;
 		if (pane->active_slot == slot) {
 			g_assert (pane->active_slots != NULL);
 			g_assert (pane->active_slots->data == slot);
@@ -142,12 +144,27 @@ nautilus_window_pane_slot_close (NautilusWindowPane *pane, NautilusWindowSlot *s
 				next_slot = get_first_inactive_slot (NAUTILUS_WINDOW_PANE (pane));
 			}
 
-			nautilus_window_set_active_slot (pane->window, next_slot);
+			nautilus_window_set_active_slot (window, next_slot);
 		}
 		nautilus_window_close_slot (slot);
 
-		if (g_list_length (pane->window->details->active_pane->slots) == 0) {
-			nautilus_window_close (pane->window);
+		/* If that was the last slot in the active pane, close the pane or even the whole window. */
+		if (window->details->active_pane->slots == NULL) {
+			NautilusWindowPane *next_pane;
+			next_pane = nautilus_window_get_next_pane (window);
+			
+			/* If next_pane is non-NULL, we have more than one pane available. In this
+			 * case, close the current pane and switch to the next one. If there is
+			 * no next pane, close the window. */
+			if(next_pane) {
+				nautilus_window_close_pane (pane);
+				nautilus_window_pane_switch_to (next_pane);
+				if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
+					nautilus_navigation_window_update_show_hide_menu_items (NAUTILUS_NAVIGATION_WINDOW (window));
+				}
+			} else {
+				nautilus_window_close (window);
+			}
 		}
 	}
 }
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index df54f48..4563099 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -761,17 +761,15 @@ nautilus_window_close_pane (NautilusWindowPane *pane)
 
 	window = pane->window;
 
-	window->details->panes = g_list_remove (window->details->panes, pane);
-
-	/* if the pane was active, select the next one, or NULL */
+	/* If the pane was active, set it to NULL. The caller is responsible
+	 * for setting a new active pane with nautilus_window_pane_switch_to()
+	 * if it wants to continue using the window. */
 	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->active_pane = NULL;
 	}
 
+	window->details->panes = g_list_remove (window->details->panes, pane);
+
 	g_object_unref (pane);
 }
 
@@ -1536,7 +1534,7 @@ nautilus_window_get_next_pane (NautilusWindow *window)
 
        /* get next pane in the (wrapped around) list */
        node = g_list_find (window->details->panes, window->details->active_pane);
-       g_return_val_if_fail (node, FALSE);
+       g_return_val_if_fail (node, NULL);
        if (node->next) {
 	       next_pane = node->next->data;
        } else {



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