summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2016-04-12 15:04:19 +0200
committerCarlos Soriano <csoriano@gnome.org>2016-04-12 16:25:52 +0200
commitfeab581803bb5e5d32dd8319b6bf6b81aebbd853 (patch)
treef8a30637434ba4f2e7ad706b16a941a5689282d6
parentf31dbd1ac89351a4690862b03560cc8f6e4aae2f (diff)
downloadnautilus-feab581803bb5e5d32dd8319b6bf6b81aebbd853.tar.gz
window: use helper for replacing slot
Also, make the code cleaner.
-rw-r--r--src/nautilus-window.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 20230f843..7981f9c13 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -557,6 +557,24 @@ real_create_slot (NautilusWindow *window,
return slot;
}
+static NautilusWindowSlot *
+replace_active_slot (NautilusWindow *window,
+ GFile *location,
+ NautilusWindowOpenFlags flags)
+{
+ NautilusWindowSlot *new_slot;
+ NautilusWindowSlot *active_slot;
+
+ new_slot = nautilus_window_create_slot (window, location);
+ nautilus_window_initialize_slot (window, new_slot, flags);
+ active_slot = nautilus_window_get_active_slot (window);
+ if (active_slot) {
+ close_slot (window, active_slot, TRUE);
+ }
+
+ return new_slot;
+}
+
void
nautilus_window_initialize_slot (NautilusWindow *window,
NautilusWindowSlot *slot,
@@ -594,7 +612,6 @@ nautilus_window_open_location_full (NautilusWindow *window,
NautilusWindowSlot *active_slot;
gboolean new_tab_at_end;
- active_slot = nautilus_window_get_active_slot (window);
/* The location owner can be one of the slots requesting to handle an
* unhandled location. But this slot can be destroyed when switching to
* a new slot. So keep the location alive.
@@ -608,20 +625,17 @@ nautilus_window_open_location_full (NautilusWindow *window,
new_tab_at_end = g_settings_get_enum (nautilus_preferences, NAUTILUS_PREFERENCES_NEW_TAB_POSITION) == NAUTILUS_NEW_TAB_POSITION_END;
if (new_tab_at_end)
flags |= NAUTILUS_WINDOW_OPEN_SLOT_APPEND;
-
- target_slot = nautilus_window_create_slot (window, location);
- nautilus_window_initialize_slot (window, target_slot, flags);
}
+ active_slot = nautilus_window_get_active_slot (window);
if (!target_slot)
target_slot = active_slot;
- if (target_slot == NULL || !nautilus_window_slot_handles_location (target_slot, location)) {
+ if (target_slot == NULL || (flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB) != 0) {
target_slot = nautilus_window_create_slot (window, location);
nautilus_window_initialize_slot (window, target_slot, flags);
- if (active_slot) {
- close_slot (window, active_slot, TRUE);
- }
+ } else if (!nautilus_window_slot_handles_location (target_slot, location)) {
+ target_slot = replace_active_slot (window, location, flags);
}
/* Make the opened location the one active if we weren't ask for the