[nautilus] all: use nautilus_window_get_active_slot()



commit 455c8da5981db559d7d47d9f9fcb8dac8297d4ac
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Jan 6 02:24:09 2012 +0100

    all: use nautilus_window_get_active_slot()

 src/nautilus-location-bar.c        |    3 +-
 src/nautilus-window-bookmarks.c    |    2 +-
 src/nautilus-window-manage-views.c |   12 ++++------
 src/nautilus-window-menus.c        |   26 +++++++++++-----------
 src/nautilus-window-pane.c         |    2 +-
 src/nautilus-window-private.h      |    4 ---
 src/nautilus-window-slot.c         |    8 ++++--
 src/nautilus-window.c              |   42 ++++++++++++++++++------------------
 8 files changed, 47 insertions(+), 52 deletions(-)
---
diff --git a/src/nautilus-location-bar.c b/src/nautilus-location-bar.c
index 6831414..2a77655 100644
--- a/src/nautilus-location-bar.c
+++ b/src/nautilus-location-bar.c
@@ -35,7 +35,6 @@
 
 #include "nautilus-application.h"
 #include "nautilus-location-entry.h"
-#include "nautilus-window-private.h"
 #include "nautilus-window.h"
 #include <eel/eel-accessibility.h>
 #include <eel/eel-glib-extensions.h>
@@ -306,7 +305,7 @@ label_button_pressed_callback (GtkWidget             *widget,
 	}
 
 	window = nautilus_location_bar_get_window (gtk_widget_get_parent (widget));
-	slot = NAUTILUS_WINDOW (window)->details->active_pane->active_slot;
+	slot = nautilus_window_get_active_slot (window);
 	view = slot->content_view;
 	label = gtk_bin_get_child (GTK_BIN (widget));
 	/* only pop-up if the URI in the entry matches the displayed location */
diff --git a/src/nautilus-window-bookmarks.c b/src/nautilus-window-bookmarks.c
index f8148b1..fb788b6 100644
--- a/src/nautilus-window-bookmarks.c
+++ b/src/nautilus-window-bookmarks.c
@@ -147,7 +147,7 @@ nautilus_window_add_bookmark_for_current_location (NautilusWindow *window)
 
 	g_assert (NAUTILUS_IS_WINDOW (window));
 
-	slot = window->details->active_pane->active_slot;
+	slot = nautilus_window_get_active_slot (window);
 	bookmark = slot->current_location_bookmark;
 	list = window->details->bookmark_list;
 
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 803760e..83b6930 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -265,7 +265,7 @@ nautilus_window_update_up_button (NautilusWindow *window)
 	gboolean allowed;
 	GFile *parent;
 
-	slot = window->details->active_pane->active_slot;
+	slot = nautilus_window_get_active_slot (window);
 
 	allowed = FALSE;
 	if (slot->location != NULL) {
@@ -532,7 +532,7 @@ nautilus_window_slot_open_location_full (NautilusWindowSlot *slot,
 		if (target_window == window) {
 			target_slot = slot;
 		} else {
-			target_slot = target_window->details->active_pane->active_slot;
+			target_slot = nautilus_window_get_active_slot (target_window);
 		}
 	}
 
@@ -1189,9 +1189,7 @@ nautilus_window_report_location_change (NautilusWindow *window)
 	NautilusWindowSlot *slot;
 	GFile *location;
 
-	g_assert (NAUTILUS_IS_WINDOW (window));
-
-	slot = window->details->active_pane->active_slot;
+	slot = nautilus_window_get_active_slot (window);
 	g_assert (NAUTILUS_IS_WINDOW_SLOT (slot));
 
 	location = NULL;
@@ -1482,7 +1480,7 @@ update_for_new_location (NautilusWindowSlot *slot)
 				 G_CALLBACK (viewed_file_changed_callback), slot, 0);
         nautilus_file_unref (file);
 
-	if (slot == window->details->active_pane->active_slot) {
+	if (slot == nautilus_window_get_active_slot (window)) {
 		/* Check if we can go up. */
 		nautilus_window_update_up_button (window);
 
@@ -1914,7 +1912,7 @@ nautilus_window_back_or_forward (NautilusWindow *window,
         NautilusBookmark *bookmark;
 	GFile *old_location;
 
-	slot = window->details->active_pane->active_slot;
+	slot = nautilus_window_get_active_slot (window);
 	list = back ? slot->back_list : slot->forward_list;
 
         len = (guint) g_list_length (list);
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index 792e46a..0b0fbec 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -591,7 +591,7 @@ action_split_view_same_location_callback (GtkAction *action,
 	}
 	location = nautilus_window_slot_get_location (next_pane->active_slot);
 	if (location) {
-		nautilus_window_slot_go_to (window->details->active_pane->active_slot, location, FALSE);
+		nautilus_window_slot_go_to (nautilus_window_get_active_slot (window), location, FALSE);
 		g_object_unref (location);
 	}
 }
@@ -622,16 +622,17 @@ action_split_view_callback (GtkAction *action,
 
 	is_active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 	if (is_active != nautilus_window_split_view_showing (window)) {
-		NautilusWindow *nautilus_window;
+		NautilusWindowSlot *slot;
 
 		if (is_active) {
 			nautilus_window_split_view_on (window);
 		} else {
 			nautilus_window_split_view_off (window);
 		}
-		nautilus_window = NAUTILUS_WINDOW (window);
-		if (nautilus_window->details->active_pane && nautilus_window->details->active_pane->active_slot) {
-			nautilus_view_update_menus (nautilus_window->details->active_pane->active_slot->content_view);
+
+		slot = nautilus_window_get_active_slot (window);
+		if (slot != NULL) {
+			nautilus_view_update_menus (slot->content_view);
 		}
 	}
 }
@@ -743,7 +744,6 @@ nautilus_window_initialize_go_menu (NautilusWindow *window)
 void
 nautilus_window_update_split_view_actions_sensitivity (NautilusWindow *window)
 {
-	NautilusWindow *win;
 	GtkActionGroup *action_group;
 	GtkAction *action;
 	gboolean have_multiple_panes;
@@ -751,21 +751,21 @@ nautilus_window_update_split_view_actions_sensitivity (NautilusWindow *window)
 	GFile *active_pane_location;
 	GFile *next_pane_location;
 	NautilusWindowPane *next_pane;
+	NautilusWindowSlot *active_slot;
 
 	g_assert (NAUTILUS_IS_WINDOW (window));
 
 	action_group = window->details->main_action_group;
-	win = NAUTILUS_WINDOW (window);
+	active_slot = nautilus_window_get_active_slot (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 {
+	have_multiple_panes = (window->details->panes && window->details->panes->next);
+	if (active_slot != NULL) {
+		active_pane_location = nautilus_window_slot_get_location (active_slot);
+	} else {
 		active_pane_location = NULL;
 	}
-	next_pane = nautilus_window_get_next_pane (win);
+	next_pane = nautilus_window_get_next_pane (window);
 	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 &&
diff --git a/src/nautilus-window-pane.c b/src/nautilus-window-pane.c
index 30a7d4d..104cc43 100644
--- a/src/nautilus-window-pane.c
+++ b/src/nautilus-window-pane.c
@@ -863,7 +863,7 @@ nautilus_window_pane_sync_location_widgets (NautilusWindowPane *pane)
 		nautilus_window_update_up_button (pane->window);
 
 		/* Check if the back and forward buttons need enabling or disabling. */
-		active_slot = pane->window->details->active_pane->active_slot;
+		active_slot = nautilus_window_get_active_slot (pane->window);
 		nautilus_window_allow_back (pane->window,
 					    active_slot->back_list != NULL);
 		nautilus_window_allow_forward (pane->window,
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index c75306e..8c159c4 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -140,8 +140,6 @@ void                nautilus_window_close_slot                           (Nautil
 NautilusWindowSlot *nautilus_window_get_slot_for_view                    (NautilusWindow *window,
 									  NautilusView   *view);
 
-NautilusWindowSlot * nautilus_window_get_active_slot                     (NautilusWindow    *window);
-NautilusWindowSlot * nautilus_window_get_extra_slot                      (NautilusWindow    *window);
 void                 nautilus_window_set_active_slot                     (NautilusWindow    *window,
 									  NautilusWindowSlot *slot);
 void                 nautilus_window_set_active_pane                     (NautilusWindow *window,
@@ -164,9 +162,7 @@ GtkActionGroup *nautilus_window_create_toolbar_action_group (NautilusWindow *win
 void               nautilus_window_initialize_actions                    (NautilusWindow    *window);
 void               nautilus_window_initialize_menus                      (NautilusWindow    *window);
 void               nautilus_window_finalize_menus                        (NautilusWindow    *window);
-void               nautilus_window_remove_bookmarks_menu_callback        (NautilusWindow    *window);
 
-void               nautilus_window_remove_bookmarks_menu_items           (NautilusWindow    *window);
 void               nautilus_window_update_show_hide_menu_items           (NautilusWindow     *window);
 
 /* window toolbar */
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 4db2e66..b9c6b7f 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -74,10 +74,12 @@ real_update_query_editor (NautilusWindowSlot *slot)
 	NautilusSearchDirectory *search_directory;
 	NautilusQuery *query;
 	GtkWidget *query_editor;
+	gboolean slot_is_active;
 
 	g_assert (slot->pane->window != NULL);
 
 	query_editor = NULL;
+	slot_is_active = (slot == nautilus_window_get_active_slot (slot->pane->window));
 
 	directory = nautilus_directory_get (slot->location);
 	if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
@@ -88,7 +90,7 @@ real_update_query_editor (NautilusWindowSlot *slot)
 			nautilus_window_pane_sync_search_widgets (slot->pane);
 		} else {
 			query_editor = nautilus_query_editor_new_with_bar (FALSE,
-									   slot->pane->window->details->active_pane->active_slot == slot,
+									   slot_is_active,
 									   NAUTILUS_SEARCH_BAR (slot->pane->search_bar),
 									   slot);
 		}
@@ -153,7 +155,7 @@ real_inactive (NautilusWindowSlot *slot)
 	NautilusWindow *window;
 
 	window = NAUTILUS_WINDOW (slot->pane->window);
-	g_assert (slot == window->details->active_pane->active_slot);
+	g_assert (slot == nautilus_window_get_active_slot (window));
 }
 
 static void
@@ -584,7 +586,7 @@ nautilus_window_slot_set_status (NautilusWindowSlot *slot,
 	}
 
 	window = NAUTILUS_WINDOW (slot->pane->window);
-	if (slot == window->details->active_pane->active_slot) {
+	if (slot == nautilus_window_get_active_slot (window)) {
 		nautilus_window_sync_status (window);
 	}
 }
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 3cd661c..a58b6ca 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -173,7 +173,7 @@ nautilus_window_sync_status (NautilusWindow *window)
 {
 	NautilusWindowSlot *slot;
 
-	slot = window->details->active_pane->active_slot;
+	slot = nautilus_window_get_active_slot (window);
 	nautilus_window_push_status (window, slot->status_text);
 }
 
@@ -182,7 +182,8 @@ nautilus_window_go_to (NautilusWindow *window, GFile *location)
 {
 	g_return_if_fail (NAUTILUS_IS_WINDOW (window));
 
-	nautilus_window_slot_go_to (window->details->active_pane->active_slot, location, FALSE);
+	nautilus_window_slot_go_to (nautilus_window_get_active_slot (window),
+				    location, FALSE);
 }
 
 void
@@ -193,7 +194,8 @@ nautilus_window_go_to_full (NautilusWindow *window,
 {
 	g_return_if_fail (NAUTILUS_IS_WINDOW (window));
 
-	nautilus_window_slot_go_to_full (window->details->active_pane->active_slot, location, FALSE, callback, user_data);
+	nautilus_window_slot_go_to_full (nautilus_window_get_active_slot (window),
+					 location, FALSE, callback, user_data);
 }
 
 static gboolean
@@ -215,7 +217,7 @@ nautilus_window_new_tab (NautilusWindow *window)
 	int new_slot_position;
 	char *scheme;
 
-	current_slot = window->details->active_pane->active_slot;
+	current_slot = nautilus_window_get_active_slot (window);
 	location = nautilus_window_slot_get_location (current_slot);
 
 	if (location != NULL) {
@@ -261,7 +263,7 @@ update_cursor (NautilusWindow *window)
 	NautilusWindowSlot *slot;
 	GdkCursor *cursor;
 
-	slot = window->details->active_pane->active_slot;
+	slot = nautilus_window_get_active_slot (window);
 
 	if (slot->allow_stop) {
 		cursor = gdk_cursor_new (GDK_WATCH);
@@ -277,7 +279,7 @@ nautilus_window_sync_allow_stop (NautilusWindow *window,
 				 NautilusWindowSlot *slot)
 {
 	GtkAction *action;
-	gboolean allow_stop;
+	gboolean allow_stop, slot_is_active;
 	NautilusNotebook *notebook;
 
 	g_assert (NAUTILUS_IS_WINDOW (window));
@@ -286,9 +288,11 @@ nautilus_window_sync_allow_stop (NautilusWindow *window,
 					      NAUTILUS_ACTION_STOP);
 	allow_stop = gtk_action_get_sensitive (action);
 
-	if (slot != window->details->active_pane->active_slot ||
+	slot_is_active = (slot == nautilus_window_get_active_slot (window));
+
+	if (!slot_is_active ||
 	    allow_stop != slot->allow_stop) {
-		if (slot == window->details->active_pane->active_slot) {
+		if (slot_is_active) {
 			gtk_action_set_sensitive (action, slot->allow_stop);
 		}
 
@@ -974,11 +978,7 @@ nautilus_window_set_active_slot (NautilusWindow *window, NautilusWindowSlot *new
 		g_assert (g_list_find (new_slot->pane->slots, new_slot) != NULL);
 	}
 
-	if (window->details->active_pane != NULL) {
-		old_slot = window->details->active_pane->active_slot;
-	} else {
-		old_slot = NULL;
-	}
+	old_slot = nautilus_window_get_active_slot (window);
 
 	if (old_slot == new_slot) {
 		return;
@@ -1142,7 +1142,7 @@ action_view_as_callback (GtkAction *action,
 	window = data->window;
 
 	if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
-		slot = window->details->active_pane->active_slot;
+		slot = nautilus_window_get_active_slot (window);
 		nautilus_window_slot_set_content_view (slot,
 						       data->id);
 	}
@@ -1275,7 +1275,7 @@ replace_extra_viewer_in_view_as_menus (NautilusWindow *window)
 	NautilusWindowSlot *slot;
 	const char *id;
 
-	slot = window->details->active_pane->active_slot;
+	slot = nautilus_window_get_active_slot (window);
 
 	id = nautilus_window_slot_get_content_view_id (slot);
 	update_extra_viewer_in_view_as_menus (window, id);
@@ -1301,7 +1301,7 @@ nautilus_window_synch_view_as_menus (NautilusWindow *window)
 
 	g_assert (NAUTILUS_IS_WINDOW (window));
 
-	slot = window->details->active_pane->active_slot;
+	slot = nautilus_window_get_active_slot (window);
 
 	if (slot->content_view == NULL) {
 		return;
@@ -1347,7 +1347,7 @@ refresh_stored_viewers (NautilusWindow *window)
 	GList *viewers;
 	char *uri, *mimetype;
 
-	slot = window->details->active_pane->active_slot;
+	slot = nautilus_window_get_active_slot (window);
 
 	uri = nautilus_file_get_uri (slot->viewed_file);
 	mimetype = nautilus_file_get_mime_type (slot->viewed_file);
@@ -1427,7 +1427,7 @@ load_view_as_menus_callback (NautilusFile *file,
 	slot = callback_data;
 	window = slot->pane->window;
 
-	if (slot == window->details->active_pane->active_slot) {
+	if (slot == nautilus_window_get_active_slot (window)) {
 		load_view_as_menu (window);
 	}
 }
@@ -1450,7 +1450,7 @@ nautilus_window_load_view_as_menus (NautilusWindow *window)
 
 	attributes = nautilus_mime_actions_get_required_file_attributes ();
 
-	slot = window->details->active_pane->active_slot;
+	slot = nautilus_window_get_active_slot (window);
 
 	cancel_view_as_callback (slot);
 	nautilus_file_call_when_ready (slot->viewed_file,
@@ -1474,7 +1474,7 @@ nautilus_window_sync_title (NautilusWindow *window,
 		return;
 	}
 
-	if (slot == window->details->active_pane->active_slot) {
+	if (slot == nautilus_window_get_active_slot (window)) {
 		/* if spatial mode is default, we keep "File Browser" in the window title
 		 * to recognize browser windows. Otherwise, we default to the directory name.
 		 */
@@ -1505,7 +1505,7 @@ nautilus_window_sync_zoom_widgets (NautilusWindow *window)
 	gboolean can_zoom, can_zoom_in, can_zoom_out;
 	NautilusZoomLevel zoom_level;
 
-	slot = window->details->active_pane->active_slot;
+	slot = nautilus_window_get_active_slot (window);
 	view = slot->content_view;
 
 	if (view != NULL) {



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