summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/meson.build2
-rw-r--r--src/nautilus-other-locations-window-slot.c83
-rw-r--r--src/nautilus-other-locations-window-slot.h33
-rw-r--r--src/nautilus-window-slot.c66
-rw-r--r--src/nautilus-window-slot.h8
-rw-r--r--src/nautilus-window.c71
6 files changed, 37 insertions, 226 deletions
diff --git a/src/meson.build b/src/meson.build
index 0672359a5..39e0b0370 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -102,8 +102,6 @@ libnautilus_sources = [
'nautilus-mime-actions.h',
'nautilus-notebook.c',
'nautilus-notebook.h',
- 'nautilus-other-locations-window-slot.c',
- 'nautilus-other-locations-window-slot.h',
'nautilus-pathbar.c',
'nautilus-pathbar.h',
'nautilus-places-view.c',
diff --git a/src/nautilus-other-locations-window-slot.c b/src/nautilus-other-locations-window-slot.c
deleted file mode 100644
index 0c6bf2fdc..000000000
--- a/src/nautilus-other-locations-window-slot.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* nautilus-other-locations-window-slot.c
- *
- * Copyright (C) 2016 Carlos Soriano <csoriano@gnome.org>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "nautilus-other-locations-window-slot.h"
-
-#include "nautilus-file.h"
-#include "nautilus-places-view.h"
-#include "nautilus-view.h"
-
-struct _NautilusOtherLocationsWindowSlot
-{
- NautilusWindowSlot parent_instance;
-};
-
-G_DEFINE_TYPE (NautilusOtherLocationsWindowSlot, nautilus_other_locations_window_slot, NAUTILUS_TYPE_WINDOW_SLOT)
-
-static gboolean
-real_handles_location (NautilusWindowSlot *self,
- GFile *location)
-{
- NautilusFile *file;
- gboolean handles_location;
-
- file = nautilus_file_get (location);
- handles_location = nautilus_file_is_other_locations (file);
- nautilus_file_unref (file);
-
- return handles_location;
-}
-
-static NautilusView *
-real_get_view_for_location (NautilusWindowSlot *self,
- GFile *location)
-{
- return NAUTILUS_VIEW (nautilus_places_view_new ());
-}
-
-NautilusOtherLocationsWindowSlot *
-nautilus_other_locations_window_slot_new (NautilusWindow *window)
-{
- return g_object_new (NAUTILUS_TYPE_OTHER_LOCATIONS_WINDOW_SLOT,
- "window", window,
- NULL);
-}
-
-static void
-nautilus_other_locations_window_slot_class_init (NautilusOtherLocationsWindowSlotClass *klass)
-{
- NautilusWindowSlotClass *parent_class = NAUTILUS_WINDOW_SLOT_CLASS (klass);
-
- parent_class->get_view_for_location = real_get_view_for_location;
- parent_class->handles_location = real_handles_location;
-}
-
-static void
-nautilus_other_locations_window_slot_init (NautilusOtherLocationsWindowSlot *self)
-{
- GAction *action;
- GActionGroup *action_group;
-
- /* Disable the ability to change between types of views */
- action_group = gtk_widget_get_action_group (GTK_WIDGET (self), "slot");
-
- action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "files-view-mode");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
- action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "files-view-mode-toggle");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
-}
diff --git a/src/nautilus-other-locations-window-slot.h b/src/nautilus-other-locations-window-slot.h
deleted file mode 100644
index 70136d181..000000000
--- a/src/nautilus-other-locations-window-slot.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* nautilus-other-locations-window-slot.h
- *
- * Copyright (C) 2016 Carlos Soriano <csoriano@gnome.org>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#include "nautilus-window-slot.h"
-
-#include "nautilus-types.h"
-
-G_BEGIN_DECLS
-
-#define NAUTILUS_TYPE_OTHER_LOCATIONS_WINDOW_SLOT (nautilus_other_locations_window_slot_get_type())
-
-G_DECLARE_FINAL_TYPE (NautilusOtherLocationsWindowSlot, nautilus_other_locations_window_slot, NAUTILUS, OTHER_LOCATIONS_WINDOW_SLOT, NautilusWindowSlot)
-
-NautilusOtherLocationsWindowSlot *nautilus_other_locations_window_slot_new (NautilusWindow *window);
-
-G_END_DECLS
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 17ed6e164..502de6ede 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -27,6 +27,7 @@
#include "nautilus-bookmark.h"
#include "nautilus-bookmark-list.h"
#include "nautilus-mime-actions.h"
+#include "nautilus-places-view.h"
#include "nautilus-query-editor.h"
#include "nautilus-special-location-bar.h"
#include "nautilus-toolbar.h"
@@ -127,6 +128,7 @@ typedef struct
GError *mount_error;
gboolean tried_mount;
gint view_mode_before_search;
+ gint view_mode_before_places;
/* Menus */
GMenuModel *extensions_background_menu;
@@ -246,30 +248,6 @@ nautilus_window_slot_get_navigation_state (NautilusWindowSlot *self)
return data;
}
-gboolean
-nautilus_window_slot_handles_location (NautilusWindowSlot *self,
- GFile *location)
-{
- return NAUTILUS_WINDOW_SLOT_CLASS (G_OBJECT_GET_CLASS (self))->handles_location (self, location);
-}
-
-static gboolean
-real_handles_location (NautilusWindowSlot *self,
- GFile *location)
-{
- NautilusFile *file;
- gboolean handles_location;
- g_autofree char *uri = NULL;
-
- uri = g_file_get_uri (location);
-
- file = nautilus_file_get (location);
- handles_location = !nautilus_file_is_other_locations (file);
- nautilus_file_unref (file);
-
- return handles_location;
-}
-
static NautilusView *
nautilus_window_slot_get_view_for_location (NautilusWindowSlot *self,
GFile *location)
@@ -282,7 +260,7 @@ real_get_view_for_location (NautilusWindowSlot *self,
GFile *location)
{
NautilusWindowSlotPrivate *priv;
- NautilusFile *file;
+ g_autoptr (NautilusFile) file = NULL;
NautilusView *view;
guint view_id;
@@ -291,13 +269,27 @@ real_get_view_for_location (NautilusWindowSlot *self,
view = NULL;
view_id = NAUTILUS_VIEW_INVALID_ID;
+ if (nautilus_file_is_other_locations (file))
+ {
+ view = NAUTILUS_VIEW (nautilus_places_view_new ());
+
+ /* Save the current view, so we can go back after places view */
+ if (NAUTILUS_IS_FILES_VIEW (priv->content_view))
+ {
+ priv->view_mode_before_places = nautilus_files_view_get_view_id (priv->content_view);
+ }
+
+ return view;
+ }
+
/* If we are in search, try to use by default list view. */
if (nautilus_file_is_in_search (file))
{
/* If it's already set, is because we already made the change to search mode,
* so the view mode of the current view will be the one search is using,
* which is not the one we are interested in */
- if (priv->view_mode_before_search == NAUTILUS_VIEW_INVALID_ID && priv->content_view)
+ if (priv->view_mode_before_search == NAUTILUS_VIEW_INVALID_ID &&
+ NAUTILUS_IS_FILES_VIEW (priv->content_view))
{
priv->view_mode_before_search = nautilus_files_view_get_view_id (priv->content_view);
}
@@ -313,6 +305,11 @@ real_get_view_for_location (NautilusWindowSlot *self,
view_id = priv->view_mode_before_search;
priv->view_mode_before_search = NAUTILUS_VIEW_INVALID_ID;
}
+ else if (NAUTILUS_IS_PLACES_VIEW (priv->content_view))
+ {
+ view_id = priv->view_mode_before_places;
+ priv->view_mode_before_places = NAUTILUS_VIEW_INVALID_ID;
+ }
else
{
view_id = nautilus_files_view_get_view_id (priv->content_view);
@@ -336,8 +333,6 @@ real_get_view_for_location (NautilusWindowSlot *self,
view = NAUTILUS_VIEW (nautilus_files_view_new (view_id, self));
}
- nautilus_file_unref (file);
-
return view;
}
@@ -353,9 +348,9 @@ nautilus_window_slot_content_view_matches (NautilusWindowSlot *self,
return FALSE;
}
- if (id != NAUTILUS_VIEW_INVALID_ID && NAUTILUS_IS_FILES_VIEW (priv->content_view))
+ if (id != NAUTILUS_VIEW_INVALID_ID)
{
- return nautilus_files_view_get_view_id (priv->content_view) == id;
+ return nautilus_view_get_view_id (priv->content_view) == id;
}
else
{
@@ -406,6 +401,7 @@ nautilus_window_slot_sync_actions (NautilusWindowSlot *self)
{
NautilusWindowSlotPrivate *priv;
+ NautilusView *view;
GAction *action;
GVariant *variant;
@@ -426,12 +422,16 @@ nautilus_window_slot_sync_actions (NautilusWindowSlot *self)
update_search_visible (self);
/* Files view mode */
+ view = nautilus_window_slot_get_current_view (self);
action = g_action_map_lookup_action (G_ACTION_MAP (priv->slot_action_group), "files-view-mode");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), NAUTILUS_IS_FILES_VIEW (view));
if (g_action_get_enabled (action))
{
- variant = g_variant_new_uint32 (nautilus_files_view_get_view_id (nautilus_window_slot_get_current_view (self)));
+ variant = g_variant_new_uint32 (nautilus_files_view_get_view_id (view));
g_action_change_state (action, variant);
}
+ action = g_action_map_lookup_action (G_ACTION_MAP (priv->slot_action_group), "files-view-mode-toggle");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), NAUTILUS_IS_FILES_VIEW (view));
}
static void
@@ -1088,7 +1088,7 @@ action_files_view_mode_toggle (GSimpleAction *action,
self = NAUTILUS_WINDOW_SLOT (user_data);
priv = nautilus_window_slot_get_instance_private (self);
- if (priv->content_view == NULL)
+ if (!NAUTILUS_IS_FILES_VIEW (priv->content_view))
{
return;
}
@@ -2735,6 +2735,7 @@ nautilus_window_slot_show_trash_bar (NautilusWindowSlot *self)
NautilusView *view;
view = nautilus_window_slot_get_current_view (self);
+ g_return_if_fail (NAUTILUS_IS_FILES_VIEW (view));
bar = nautilus_trash_bar_new (NAUTILUS_FILES_VIEW (view));
gtk_widget_show (bar);
@@ -3188,7 +3189,6 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
klass->get_view_for_location = real_get_view_for_location;
- klass->handles_location = real_handles_location;
oclass->dispose = nautilus_window_slot_dispose;
oclass->finalize = nautilus_window_slot_finalize;
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index bdb9dccfa..d2f83175c 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -59,11 +59,6 @@ struct _NautilusWindowSlotClass {
*/
NautilusView* (* get_view_for_location) (NautilusWindowSlot *slot,
GFile *location);
- /* Whether this type of slot handles the location or not. This can be used
- * for the special slots which handle special locations like the desktop
- * or the other locations. */
- gboolean (* handles_location) (NautilusWindowSlot *slot,
- GFile *location);
};
NautilusWindowSlot * nautilus_window_slot_new (NautilusWindow *window);
@@ -121,9 +116,6 @@ GList* nautilus_window_slot_get_selection (NautilusWindowSlot *
void nautilus_window_slot_search (NautilusWindowSlot *slot,
NautilusQuery *query);
-gboolean nautilus_window_slot_handles_location (NautilusWindowSlot *self,
- GFile *location);
-
void nautilus_window_slot_restore_navigation_state (NautilusWindowSlot *self,
NautilusNavigationState *data);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 9b6df9767..62dc480d2 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -61,7 +61,6 @@
#include "nautilus-metadata.h"
#include "nautilus-mime-actions.h"
#include "nautilus-notebook.h"
-#include "nautilus-other-locations-window-slot.h"
#include "nautilus-pathbar.h"
#include "nautilus-profile.h"
#include "nautilus-properties-window.h"
@@ -81,9 +80,6 @@ static void mouse_forward_button_changed (gpointer callback_data);
static void use_extra_mouse_buttons_changed (gpointer callback_data);
static void nautilus_window_initialize_actions (NautilusWindow *window);
static GtkWidget *nautilus_window_ensure_location_entry (NautilusWindow *window);
-static void close_slot (NautilusWindow *window,
- NautilusWindowSlot *slot,
- gboolean remove_from_notebook);
/* Sanity check: highest mouse button value I could find was 14. 5 is our
* lower threshold (well-documented to be the one of the button events for the
@@ -499,64 +495,17 @@ disconnect_slot (NautilusWindow *window,
}
static NautilusWindowSlot *
-nautilus_window_create_slot (NautilusWindow *window,
- GFile *location)
-{
- NautilusFile *file = NULL;
- NautilusWindowSlot *slot;
-
- if (location)
- {
- file = nautilus_file_get (location);
- }
- /* If not file, assume we open the home directory. We will switch eventually
- * to a different location if not.
- */
- if (file && nautilus_file_is_other_locations (file))
- {
- slot = NAUTILUS_WINDOW_SLOT (nautilus_other_locations_window_slot_new (window));
- }
- else
- {
- slot = nautilus_window_slot_new (window);
- }
-
- nautilus_file_unref (file);
-
- return slot;
-}
-
-static NautilusWindowSlot *
nautilus_window_create_and_init_slot (NautilusWindow *window,
- GFile *location,
NautilusWindowOpenFlags flags)
{
NautilusWindowSlot *slot;
- slot = nautilus_window_create_slot (window, location);
+ slot = nautilus_window_slot_new (window);
nautilus_window_initialize_slot (window, slot, flags);
return slot;
}
-static NautilusWindowSlot *
-replace_active_slot (NautilusWindow *window,
- GFile *location,
- NautilusWindowOpenFlags flags)
-{
- NautilusWindowSlot *new_slot;
- NautilusWindowSlot *active_slot;
-
- new_slot = nautilus_window_create_and_init_slot (window, location, 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,12 +543,6 @@ nautilus_window_open_location_full (NautilusWindow *window,
NautilusWindowSlot *active_slot;
gboolean new_tab_at_end;
- /* 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.
- */
- g_object_ref (location);
-
/* Assert that we are not managing new windows */
g_assert (!(flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW));
/* if the flags say we want a new tab, open a slot in the current window */
@@ -620,11 +563,7 @@ nautilus_window_open_location_full (NautilusWindow *window,
if (target_slot == NULL || (flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB) != 0)
{
- target_slot = nautilus_window_create_and_init_slot (window, location, flags);
- }
- else if (!nautilus_window_slot_handles_location (target_slot, location))
- {
- target_slot = replace_active_slot (window, location, flags);
+ target_slot = nautilus_window_create_and_init_slot (window, flags);
}
/* Make the opened location the one active if we weren't ask for the
@@ -636,8 +575,6 @@ nautilus_window_open_location_full (NautilusWindow *window,
}
nautilus_window_slot_open_location_full (target_slot, location, flags, selection);
-
- g_object_unref (location);
}
static void
@@ -1212,7 +1149,7 @@ action_restore_tab (GSimpleAction *action,
location = nautilus_file_get_location (data->file);
- slot = nautilus_window_create_and_init_slot (window, location, flags);
+ slot = nautilus_window_create_and_init_slot (window, flags);
nautilus_window_slot_open_location_full (slot, location, flags, NULL);
nautilus_window_slot_restore_navigation_state (slot, data);
@@ -2203,7 +2140,7 @@ nautilus_window_constructed (GObject *self)
* some actions trigger UI widgets to show/hide. */
nautilus_window_initialize_actions (window);
- slot = nautilus_window_create_and_init_slot (window, NULL, 0);
+ slot = nautilus_window_create_and_init_slot (window, 0);
nautilus_window_set_active_slot (window, slot);
window->bookmarks_id =