mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-06-30 23:46:35 +00:00
general: Introduce Network place
And request network view for network view directory. Remember whether the previous view was grid or list, to preserve per-window settings.
This commit is contained in:
parent
d1437e9fd6
commit
7e6af9d61d
|
@ -215,6 +215,7 @@ enum {
|
|||
#define ICON_NAME_DESKTOP "user-desktop-symbolic"
|
||||
#define ICON_NAME_EJECT "media-eject-symbolic"
|
||||
#define ICON_NAME_NETWORK "network-workgroup-symbolic"
|
||||
#define ICON_NAME_NETWORK_VIEW "network-computer-symbolic"
|
||||
#define ICON_NAME_FOLDER_NETWORK "folder-remote-symbolic"
|
||||
#define ICON_NAME_OTHER_LOCATIONS "list-add-symbolic"
|
||||
|
||||
|
@ -843,6 +844,15 @@ update_places (NautilusGtkPlacesSidebar *sidebar)
|
|||
/* XDG directories */
|
||||
add_special_dirs (sidebar);
|
||||
|
||||
/* Network view */
|
||||
start_icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_NETWORK_VIEW);
|
||||
add_place (sidebar, NAUTILUS_GTK_PLACES_BUILT_IN,
|
||||
NAUTILUS_GTK_PLACES_SECTION_COMPUTER,
|
||||
_("Network"), start_icon, NULL, SCHEME_NETWORK_VIEW ":///",
|
||||
NULL, NULL, NULL, NULL, 0,
|
||||
_("Open Network Locations"));
|
||||
g_object_unref (start_icon);
|
||||
|
||||
/* Trash */
|
||||
start_icon = nautilus_trash_monitor_get_symbolic_icon ();
|
||||
sidebar->trash_row = add_place (sidebar, NAUTILUS_GTK_PLACES_BUILT_IN,
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
#include "nautilus-list-view.h"
|
||||
#include "nautilus-metadata.h"
|
||||
#include "nautilus-mime-actions.h"
|
||||
#include "nautilus-network-view.h"
|
||||
#include "nautilus-module.h"
|
||||
#include "nautilus-new-folder-dialog.h"
|
||||
#include "nautilus-previewer.h"
|
||||
|
@ -953,11 +954,14 @@ nautilus_files_view_invert_selection (NautilusFilesView *self)
|
|||
static NautilusToolbarMenuSections *
|
||||
nautilus_files_view_get_toolbar_menu_sections (NautilusView *view)
|
||||
{
|
||||
NautilusFilesViewPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), NULL);
|
||||
|
||||
priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (view));
|
||||
NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (view));
|
||||
|
||||
if (NAUTILUS_IS_NETWORK_VIEW (priv->list_base))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return priv->toolbar_menu_sections;
|
||||
}
|
||||
|
@ -3530,6 +3534,15 @@ nautilus_files_view_display_selection_info (NautilusFilesView *view)
|
|||
|
||||
g_return_if_fail (NAUTILUS_IS_FILES_VIEW (view));
|
||||
|
||||
NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (view);
|
||||
|
||||
if (priv->list_base != NULL && NAUTILUS_IS_NETWORK_VIEW (priv->list_base))
|
||||
{
|
||||
/* Selection info is not relevant on this view and visually clashes with
|
||||
* the action bar. */
|
||||
return;
|
||||
}
|
||||
|
||||
selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
|
||||
|
||||
folder_item_count_known = TRUE;
|
||||
|
@ -9823,6 +9836,12 @@ create_inner_view (NautilusFilesView *self,
|
|||
}
|
||||
break;
|
||||
|
||||
case NAUTILUS_VIEW_NETWORK_ID:
|
||||
{
|
||||
priv->list_base = NAUTILUS_LIST_BASE (nautilus_network_view_new ());
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
g_critical ("Unknown view type ID: %d. Falling back to list.", id);
|
||||
|
|
|
@ -124,7 +124,7 @@ nautilus_view_get_icon_name (guint view_id)
|
|||
{
|
||||
return "view-grid-symbolic";
|
||||
}
|
||||
else if (view_id == NAUTILUS_VIEW_LIST_ID)
|
||||
else if (view_id == NAUTILUS_VIEW_LIST_ID || view_id == NAUTILUS_VIEW_NETWORK_ID)
|
||||
{
|
||||
return "view-list-symbolic";
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ nautilus_view_get_tooltip (guint view_id)
|
|||
{
|
||||
return _("Grid View");
|
||||
}
|
||||
else if (view_id == NAUTILUS_VIEW_LIST_ID)
|
||||
else if (view_id == NAUTILUS_VIEW_LIST_ID || view_id == NAUTILUS_VIEW_NETWORK_ID)
|
||||
{
|
||||
return _("List View");
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ struct _NautilusWindowSlot
|
|||
GCancellable *mount_cancellable;
|
||||
GError *mount_error;
|
||||
gboolean tried_mount;
|
||||
gint view_mode_before_places;
|
||||
gint view_mode_before_network;
|
||||
|
||||
/* Menus */
|
||||
GMenuModel *extensions_background_menu;
|
||||
|
@ -234,18 +234,24 @@ static NautilusView *
|
|||
nautilus_window_slot_get_view_for_location (NautilusWindowSlot *self,
|
||||
GFile *location)
|
||||
{
|
||||
g_autoptr (NautilusFile) file = NULL;
|
||||
NautilusView *view;
|
||||
guint view_id;
|
||||
|
||||
file = nautilus_file_get (location);
|
||||
view = NULL;
|
||||
view_id = NAUTILUS_VIEW_INVALID_ID;
|
||||
g_autoptr (NautilusFile) file = nautilus_file_get (location);
|
||||
NautilusView *view = NULL;
|
||||
guint view_id = NAUTILUS_VIEW_INVALID_ID;
|
||||
|
||||
if (self->content_view != NULL)
|
||||
{
|
||||
/* If there is already a view, just use the view mode that it's currently using */
|
||||
view_id = nautilus_view_get_view_id (self->content_view);
|
||||
if (view_id == NAUTILUS_VIEW_NETWORK_ID)
|
||||
{
|
||||
view_id = self->view_mode_before_network;
|
||||
}
|
||||
}
|
||||
|
||||
if (nautilus_file_is_network_view (file))
|
||||
{
|
||||
self->view_mode_before_network = view_id;
|
||||
view_id = NAUTILUS_VIEW_NETWORK_ID;
|
||||
}
|
||||
|
||||
/* If there is not previous view in this slot, use the default view mode
|
||||
|
@ -319,6 +325,7 @@ static void
|
|||
nautilus_window_slot_sync_actions (NautilusWindowSlot *self)
|
||||
{
|
||||
NautilusView *view;
|
||||
gboolean is_network_view;
|
||||
GAction *action;
|
||||
GVariant *variant;
|
||||
|
||||
|
@ -339,15 +346,16 @@ nautilus_window_slot_sync_actions (NautilusWindowSlot *self)
|
|||
|
||||
/* Files view mode */
|
||||
view = nautilus_window_slot_get_current_view (self);
|
||||
is_network_view = nautilus_view_get_view_id (view) == NAUTILUS_VIEW_NETWORK_ID;
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (self->slot_action_group), "files-view-mode");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), NAUTILUS_IS_FILES_VIEW (view));
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !is_network_view);
|
||||
if (g_action_get_enabled (action))
|
||||
{
|
||||
variant = g_variant_new_uint32 (nautilus_view_get_view_id (view));
|
||||
g_action_change_state (action, variant);
|
||||
}
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (self->slot_action_group), "files-view-mode-toggle");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), NAUTILUS_IS_FILES_VIEW (view));
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !is_network_view);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1085,7 +1093,8 @@ update_search_information (NautilusWindowSlot *self)
|
|||
file = nautilus_file_get (location);
|
||||
label = NULL;
|
||||
|
||||
if (nautilus_is_root_for_scheme (location, SCHEME_NETWORK))
|
||||
if (nautilus_is_root_for_scheme (location, SCHEME_NETWORK_VIEW) ||
|
||||
nautilus_is_root_for_scheme (location, SCHEME_NETWORK))
|
||||
{
|
||||
label = _("Searching network locations only");
|
||||
}
|
||||
|
@ -1154,7 +1163,7 @@ nautilus_window_slot_init (NautilusWindowSlot *self)
|
|||
nautilus_application_set_accelerator (app, "slot.search-global", "<control><shift>f");
|
||||
|
||||
self->fd_holder = nautilus_fd_holder_new ();
|
||||
self->view_mode_before_places = NAUTILUS_VIEW_INVALID_ID;
|
||||
self->view_mode_before_network = NAUTILUS_VIEW_INVALID_ID;
|
||||
}
|
||||
|
||||
static void begin_location_change (NautilusWindowSlot *slot,
|
||||
|
@ -2640,6 +2649,7 @@ nautilus_window_slot_switch_new_content_view (NautilusWindowSlot *self)
|
|||
widget = GTK_WIDGET (self->content_view);
|
||||
gtk_box_append (GTK_BOX (self->vbox), widget);
|
||||
gtk_widget_set_vexpand (widget, TRUE);
|
||||
|
||||
/* Note that this is not bidirectional and that we may also change
|
||||
* :search-visible alone, e.g. when clicking the search button. */
|
||||
self->searching_binding = g_object_bind_property (self->content_view, "searching",
|
||||
|
@ -3109,6 +3119,12 @@ nautilus_window_slot_get_icon_name (NautilusWindowSlot *self)
|
|||
}
|
||||
break;
|
||||
|
||||
case NAUTILUS_VIEW_NETWORK_ID:
|
||||
{
|
||||
return nautilus_view_get_icon_name (NAUTILUS_VIEW_NETWORK_ID);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
return NULL;
|
||||
|
@ -3142,6 +3158,12 @@ nautilus_window_slot_get_tooltip (NautilusWindowSlot *self)
|
|||
}
|
||||
break;
|
||||
|
||||
case NAUTILUS_VIEW_NETWORK_ID:
|
||||
{
|
||||
return nautilus_view_get_tooltip (NAUTILUS_VIEW_NETWORK_ID);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue
Block a user