mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-06-30 23:46:35 +00:00
Merge branch 'wip/antoniof/filechooser-prep-7' into 'main'
Preparations for FileChooser implementation (Part 7 - Deadly Modes) See merge request GNOME/nautilus!1542
This commit is contained in:
commit
edce828ade
|
@ -17,6 +17,7 @@ libnautilus_sources = [
|
|||
'gtk/nautilusgtkplacessidebarprivate.h',
|
||||
'nautilus-enums.h',
|
||||
'nautilus-location-banner.h',
|
||||
'nautilus-mode.h',
|
||||
'nautilus-search-popover.h',
|
||||
'nautilus-query.h',
|
||||
'nautilus-search-provider.h'
|
||||
|
|
|
@ -1311,7 +1311,13 @@ nautilus_files_view_activate_files (NautilusFilesView *view,
|
|||
NautilusOpenFlags flags,
|
||||
gboolean confirm_multiple)
|
||||
{
|
||||
NautilusFilesViewPrivate *priv;
|
||||
NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (view);
|
||||
|
||||
if (nautilus_window_slot_handle_activate_files (priv->slot, files))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GList *files_to_extract;
|
||||
GList *files_to_activate;
|
||||
char *path;
|
||||
|
@ -1321,8 +1327,6 @@ nautilus_files_view_activate_files (NautilusFilesView *view,
|
|||
return;
|
||||
}
|
||||
|
||||
priv = nautilus_files_view_get_instance_private (view);
|
||||
|
||||
files_to_extract = nautilus_file_list_filter (files,
|
||||
&files_to_activate,
|
||||
(NautilusFileFilterFunc) nautilus_mime_file_extracts,
|
||||
|
@ -7230,6 +7234,7 @@ update_actions_clipboard_contents_received (GObject *source_object,
|
|||
gboolean selection_contains_starred;
|
||||
GAction *action;
|
||||
const GValue *value;
|
||||
NautilusMode mode;
|
||||
|
||||
value = gdk_clipboard_read_value_finish (GDK_CLIPBOARD (source_object), res, NULL);
|
||||
if (value == NULL)
|
||||
|
@ -7260,15 +7265,18 @@ update_actions_clipboard_contents_received (GObject *source_object,
|
|||
can_link_from_copied_files = clip != NULL && !nautilus_clipboard_is_cut (clip) &&
|
||||
!selection_contains_recent && !selection_contains_starred &&
|
||||
!is_read_only;
|
||||
mode = nautilus_window_slot_get_mode (priv->slot);
|
||||
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (priv->view_action_group),
|
||||
"create-link");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_link_from_copied_files &&
|
||||
settings_show_create_link);
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (priv->view_action_group),
|
||||
"create-link-shortcut");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_link_from_copied_files &&
|
||||
!settings_show_create_link);
|
||||
}
|
||||
|
@ -7519,6 +7527,7 @@ static void
|
|||
real_update_actions_state (NautilusFilesView *view)
|
||||
{
|
||||
NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (view);
|
||||
NautilusMode mode = nautilus_window_slot_get_mode (priv->slot);
|
||||
g_autolist (NautilusFile) selection = NULL;
|
||||
GList *l;
|
||||
gint selection_count;
|
||||
|
@ -7601,6 +7610,7 @@ real_update_actions_state (NautilusFilesView *view)
|
|||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"new-folder-with-selection");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_create_files && can_delete_files && (selection_count > 1) && !selection_contains_recent
|
||||
&& !selection_contains_starred);
|
||||
|
||||
|
@ -7621,6 +7631,7 @@ real_update_actions_state (NautilusFilesView *view)
|
|||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"extract-here");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_extract_files &&
|
||||
!handles_all_files_to_extract &&
|
||||
can_extract_here);
|
||||
|
@ -7628,6 +7639,7 @@ real_update_actions_state (NautilusFilesView *view)
|
|||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"extract-to");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_extract_files &&
|
||||
(!handles_all_files_to_extract ||
|
||||
can_extract_here));
|
||||
|
@ -7635,6 +7647,7 @@ real_update_actions_state (NautilusFilesView *view)
|
|||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"compress");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_create_files && can_copy_files);
|
||||
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
|
@ -7666,29 +7679,42 @@ real_update_actions_state (NautilusFilesView *view)
|
|||
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"open-with-default-application");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), selection_count != 0);
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
selection_count != 0);
|
||||
|
||||
/* Allow to select a different application to open the item */
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"open-with-other-application");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
selection_count > 0);
|
||||
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"open-item-new-tab");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), item_opens_in_view);
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
item_opens_in_view);
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"open-item-new-window");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), item_opens_in_view);
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
item_opens_in_view);
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"run-in-terminal");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), can_run_in_terminal (selection));
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_run_in_terminal (selection));
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"set-as-wallpaper");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), can_set_wallpaper (selection));
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_set_wallpaper (selection));
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"restore-from-trash");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), can_restore_from_trash (selection));
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_restore_from_trash (selection));
|
||||
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"move-to-trash");
|
||||
|
@ -7697,16 +7723,19 @@ real_update_actions_state (NautilusFilesView *view)
|
|||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"delete-from-trash");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_delete_files && selection_all_in_trash);
|
||||
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"delete-permanently-shortcut");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_delete_files);
|
||||
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"delete-permanently-menu-item");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_delete_files && !can_trash_files &&
|
||||
!selection_all_in_trash && !selection_contains_recent &&
|
||||
!selection_contains_starred);
|
||||
|
@ -7714,6 +7743,7 @@ real_update_actions_state (NautilusFilesView *view)
|
|||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"permanent-delete-permanently-menu-item");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_delete_files && can_trash_files &&
|
||||
settings_show_delete_permanently &&
|
||||
!selection_all_in_trash && !selection_contains_recent &&
|
||||
|
@ -7722,40 +7752,48 @@ real_update_actions_state (NautilusFilesView *view)
|
|||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"remove-from-recent");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
selection_contains_recent && selection_count > 0);
|
||||
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"cut");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_move_files && !selection_contains_recent &&
|
||||
!selection_contains_starred);
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"copy");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_copy_files);
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"create-link-in-place");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_copy_files &&
|
||||
can_create_files &&
|
||||
settings_show_create_link);
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"create-link-in-place-shortcut");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_copy_files &&
|
||||
can_create_files &&
|
||||
!settings_show_create_link);
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"send-email");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
app_info_mailto != NULL);
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"copy-to");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_copy_files);
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"move-to");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
can_move_files && !selection_contains_recent &&
|
||||
!selection_contains_starred);
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
|
@ -7837,13 +7875,16 @@ real_update_actions_state (NautilusFilesView *view)
|
|||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"open-current-directory-with-other-application");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
!selection_contains_recent &&
|
||||
!selection_contains_search &&
|
||||
!selection_contains_starred &&
|
||||
!is_network_view);
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"new-folder");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), can_create_files);
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
!nautilus_mode_is_open (mode) &&
|
||||
can_create_files);
|
||||
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"empty-trash");
|
||||
|
@ -7855,14 +7896,21 @@ real_update_actions_state (NautilusFilesView *view)
|
|||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"paste");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
!is_read_only &&
|
||||
!selection_contains_recent &&
|
||||
!is_in_trash &&
|
||||
!selection_contains_starred);
|
||||
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"paste_accel");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE);
|
||||
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"paste-into");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
!selection_contains_recent &&
|
||||
!is_in_trash &&
|
||||
!selection_contains_starred &&
|
||||
|
@ -7871,17 +7919,20 @@ real_update_actions_state (NautilusFilesView *view)
|
|||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"console");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
selection_count == 1 && nautilus_file_is_directory (selection->data) &&
|
||||
nautilus_dbus_launcher_is_available (nautilus_dbus_launcher_get (),
|
||||
NAUTILUS_DBUS_LAUNCHER_CONSOLE));
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"current-directory-console");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
nautilus_dbus_launcher_is_available (nautilus_dbus_launcher_get (),
|
||||
NAUTILUS_DBUS_LAUNCHER_CONSOLE));
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"properties");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
(is_network_view ?
|
||||
(selection_count == 1 &&
|
||||
nautilus_file_can_unmount (selection->data)) :
|
||||
|
@ -7892,6 +7943,7 @@ real_update_actions_state (NautilusFilesView *view)
|
|||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"current-directory-properties");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
!selection_contains_recent &&
|
||||
!selection_contains_search &&
|
||||
!selection_contains_starred &&
|
||||
|
@ -7952,11 +8004,15 @@ real_update_actions_state (NautilusFilesView *view)
|
|||
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"star");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), show_star);
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
show_star);
|
||||
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
|
||||
"unstar");
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), show_unstar && selection_contains_starred);
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
|
||||
mode == NAUTILUS_MODE_BROWSE &&
|
||||
show_unstar && selection_contains_starred);
|
||||
|
||||
/* Network view actions */
|
||||
gboolean can_remove_recent_server = is_network_view;
|
||||
|
@ -8003,6 +8059,7 @@ update_selection_menu (NautilusFilesView *view,
|
|||
GtkBuilder *builder)
|
||||
{
|
||||
NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (view);
|
||||
NautilusMode mode = nautilus_window_slot_get_mode (priv->slot);
|
||||
g_autolist (NautilusFile) selection = NULL;
|
||||
GList *l;
|
||||
gint selection_count;
|
||||
|
@ -8035,106 +8092,112 @@ update_selection_menu (NautilusFilesView *view,
|
|||
show_stop = (selection != NULL && selection_count == 1);
|
||||
show_detect_media = (selection != NULL && selection_count == 1);
|
||||
start_stop_type = G_DRIVE_START_STOP_TYPE_UNKNOWN;
|
||||
item_label = g_strdup_printf (ngettext ("New Folder with Selection (%'d Item)",
|
||||
"New Folder with Selection (%'d Items)",
|
||||
selection_count),
|
||||
selection_count);
|
||||
menu_item = g_menu_item_new (item_label, "view.new-folder-with-selection");
|
||||
g_menu_item_set_attribute (menu_item, "hidden-when", "s", "action-disabled");
|
||||
object = gtk_builder_get_object (builder, "new-folder-with-selection-section");
|
||||
g_menu_append_item (G_MENU (object), menu_item);
|
||||
g_object_unref (menu_item);
|
||||
g_free (item_label);
|
||||
|
||||
/* Open With <App> menu item */
|
||||
show_extract = show_app = show_run = item_opens_in_view = selection_count != 0;
|
||||
for (l = selection; l != NULL; l = l->next)
|
||||
if (mode == NAUTILUS_MODE_BROWSE)
|
||||
{
|
||||
NautilusFile *file;
|
||||
|
||||
file = NAUTILUS_FILE (l->data);
|
||||
|
||||
if (show_extract && !nautilus_mime_file_extracts (file))
|
||||
{
|
||||
show_extract = FALSE;
|
||||
}
|
||||
|
||||
if (show_app && !nautilus_mime_file_opens_in_external_app (file))
|
||||
{
|
||||
show_app = FALSE;
|
||||
}
|
||||
|
||||
if (show_run && !nautilus_mime_file_launches (file))
|
||||
{
|
||||
show_run = FALSE;
|
||||
}
|
||||
|
||||
if (item_opens_in_view && !nautilus_file_opens_in_view (file))
|
||||
{
|
||||
item_opens_in_view = FALSE;
|
||||
}
|
||||
|
||||
if (!show_extract && !show_app && !show_run && !item_opens_in_view)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
item_label = NULL;
|
||||
app = NULL;
|
||||
if (show_app)
|
||||
{
|
||||
app = nautilus_mime_get_default_application_for_files (selection);
|
||||
}
|
||||
|
||||
if (app != NULL)
|
||||
{
|
||||
g_autofree char *escaped_app = escape_underscores (g_app_info_get_name (app));
|
||||
item_label = g_strdup_printf (_("Open With %s"), escaped_app);
|
||||
|
||||
app_icon = g_app_info_get_icon (app);
|
||||
if (app_icon != NULL)
|
||||
{
|
||||
g_object_ref (app_icon);
|
||||
}
|
||||
g_object_unref (app);
|
||||
}
|
||||
else if (show_run)
|
||||
{
|
||||
item_label = g_strdup (_("Run"));
|
||||
}
|
||||
else if (show_extract)
|
||||
{
|
||||
item_label = nautilus_files_view_supports_extract_here (view) ?
|
||||
g_strdup (_("Extract")) :
|
||||
g_strdup (_("Extract to…"));
|
||||
}
|
||||
else
|
||||
{
|
||||
item_label = g_strdup (_("Open"));
|
||||
}
|
||||
|
||||
/* The action already exists in the submenu if item opens in view */
|
||||
if (!item_opens_in_view)
|
||||
{
|
||||
menu_item = g_menu_item_new (item_label, "view.open-with-default-application");
|
||||
if (app_icon != NULL)
|
||||
{
|
||||
g_menu_item_set_icon (menu_item, app_icon);
|
||||
}
|
||||
|
||||
object = gtk_builder_get_object (builder, "open-with-application-section");
|
||||
g_menu_prepend_item (G_MENU (object), menu_item);
|
||||
|
||||
item_label = g_strdup_printf (ngettext ("New Folder with Selection (%'d Item)",
|
||||
"New Folder with Selection (%'d Items)",
|
||||
selection_count),
|
||||
selection_count);
|
||||
menu_item = g_menu_item_new (item_label, "view.new-folder-with-selection");
|
||||
g_menu_item_set_attribute (menu_item, "hidden-when", "s", "action-disabled");
|
||||
object = gtk_builder_get_object (builder, "new-folder-with-selection-section");
|
||||
g_menu_append_item (G_MENU (object), menu_item);
|
||||
g_object_unref (menu_item);
|
||||
}
|
||||
else
|
||||
{
|
||||
object = gtk_builder_get_object (builder, "open-with-application-section");
|
||||
i = nautilus_g_menu_model_find_by_string (G_MENU_MODEL (object),
|
||||
"nautilus-menu-item",
|
||||
"open_with_in_main_menu");
|
||||
g_menu_remove (G_MENU (object), i);
|
||||
g_free (item_label);
|
||||
|
||||
/* Open With <App> menu item */
|
||||
show_extract = show_app = show_run = item_opens_in_view = selection_count != 0;
|
||||
for (l = selection; l != NULL; l = l->next)
|
||||
{
|
||||
NautilusFile *file;
|
||||
|
||||
file = NAUTILUS_FILE (l->data);
|
||||
|
||||
if (show_extract && !nautilus_mime_file_extracts (file))
|
||||
{
|
||||
show_extract = FALSE;
|
||||
}
|
||||
|
||||
if (show_app && !nautilus_mime_file_opens_in_external_app (file))
|
||||
{
|
||||
show_app = FALSE;
|
||||
}
|
||||
|
||||
if (show_run && !nautilus_mime_file_launches (file))
|
||||
{
|
||||
show_run = FALSE;
|
||||
}
|
||||
|
||||
if (item_opens_in_view && !nautilus_file_opens_in_view (file))
|
||||
{
|
||||
item_opens_in_view = FALSE;
|
||||
}
|
||||
|
||||
if (!show_extract && !show_app && !show_run && !item_opens_in_view)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
item_label = NULL;
|
||||
app = NULL;
|
||||
if (show_app)
|
||||
{
|
||||
app = nautilus_mime_get_default_application_for_files (selection);
|
||||
}
|
||||
|
||||
if (app != NULL)
|
||||
{
|
||||
g_autofree char *escaped_app = escape_underscores (g_app_info_get_name (app));
|
||||
item_label = g_strdup_printf (_("Open With %s"), escaped_app);
|
||||
|
||||
app_icon = g_app_info_get_icon (app);
|
||||
if (app_icon != NULL)
|
||||
{
|
||||
g_object_ref (app_icon);
|
||||
}
|
||||
g_object_unref (app);
|
||||
}
|
||||
else if (show_run)
|
||||
{
|
||||
item_label = g_strdup (_("Run"));
|
||||
}
|
||||
else if (show_extract)
|
||||
{
|
||||
item_label = nautilus_files_view_supports_extract_here (view) ?
|
||||
g_strdup (_("Extract")) :
|
||||
g_strdup (_("Extract to…"));
|
||||
}
|
||||
else
|
||||
{
|
||||
item_label = g_strdup (_("Open"));
|
||||
}
|
||||
|
||||
/* The action already exists in the submenu if item opens in view */
|
||||
if (!item_opens_in_view)
|
||||
{
|
||||
menu_item = g_menu_item_new (item_label, "view.open-with-default-application");
|
||||
if (app_icon != NULL)
|
||||
{
|
||||
g_menu_item_set_icon (menu_item, app_icon);
|
||||
}
|
||||
|
||||
object = gtk_builder_get_object (builder, "open-with-application-section");
|
||||
g_menu_prepend_item (G_MENU (object), menu_item);
|
||||
|
||||
g_object_unref (menu_item);
|
||||
}
|
||||
else
|
||||
{
|
||||
object = gtk_builder_get_object (builder, "open-with-application-section");
|
||||
i = nautilus_g_menu_model_find_by_string (G_MENU_MODEL (object),
|
||||
"nautilus-menu-item",
|
||||
"open_with_in_main_menu");
|
||||
g_menu_remove (G_MENU (object), i);
|
||||
}
|
||||
|
||||
g_free (item_label);
|
||||
}
|
||||
|
||||
/* The "Open" submenu should be hidden if the item doesn't open in the view. */
|
||||
|
@ -8144,9 +8207,8 @@ update_selection_menu (NautilusFilesView *view,
|
|||
"open_in_view_submenu");
|
||||
nautilus_g_menu_replace_string_in_item (G_MENU (object), i,
|
||||
"hidden-when",
|
||||
(!item_opens_in_view) ? "action-missing" : NULL);
|
||||
|
||||
g_free (item_label);
|
||||
(!item_opens_in_view ||
|
||||
mode != NAUTILUS_MODE_BROWSE) ? "action-missing" : NULL);
|
||||
|
||||
/* Drives */
|
||||
for (l = selection; l != NULL && (show_mount || show_unmount
|
||||
|
@ -8260,7 +8322,13 @@ update_selection_menu (NautilusFilesView *view,
|
|||
g_object_unref (menu_item);
|
||||
}
|
||||
|
||||
if (!priv->scripts_menu_updated)
|
||||
if (mode != NAUTILUS_MODE_BROWSE)
|
||||
{
|
||||
object = gtk_builder_get_object (builder, "move-copy-section");
|
||||
g_menu_remove_all (G_MENU (object));
|
||||
}
|
||||
|
||||
if (!priv->scripts_menu_updated && mode == NAUTILUS_MODE_BROWSE)
|
||||
{
|
||||
update_scripts_menu (view, builder);
|
||||
priv->scripts_menu_updated = TRUE;
|
||||
|
@ -8345,11 +8413,11 @@ update_background_menu (NautilusFilesView *view,
|
|||
static void
|
||||
real_update_context_menus (NautilusFilesView *view)
|
||||
{
|
||||
NautilusFilesViewPrivate *priv;
|
||||
NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (view);
|
||||
NautilusMode mode = nautilus_window_slot_get_mode (priv->slot);
|
||||
g_autoptr (GtkBuilder) builder = NULL;
|
||||
GObject *object;
|
||||
|
||||
priv = nautilus_files_view_get_instance_private (view);
|
||||
builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-files-view-context-menus.ui");
|
||||
|
||||
g_clear_object (&priv->background_menu_model);
|
||||
|
@ -8362,8 +8430,12 @@ real_update_context_menus (NautilusFilesView *view)
|
|||
priv->selection_menu_model = g_object_ref (G_MENU (object));
|
||||
|
||||
update_selection_menu (view, builder);
|
||||
update_background_menu (view, builder);
|
||||
update_extensions_menus (view, builder);
|
||||
|
||||
if (mode == NAUTILUS_MODE_BROWSE)
|
||||
{
|
||||
update_background_menu (view, builder);
|
||||
update_extensions_menus (view, builder);
|
||||
}
|
||||
|
||||
nautilus_files_view_update_actions_state (view);
|
||||
}
|
||||
|
@ -8497,6 +8569,11 @@ nautilus_files_view_pop_up_background_context_menu (NautilusFilesView *view,
|
|||
|
||||
priv = nautilus_files_view_get_instance_private (view);
|
||||
|
||||
if (nautilus_window_slot_get_mode (priv->slot) != NAUTILUS_MODE_BROWSE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Make the context menu items not flash as they update to proper disabled,
|
||||
* etc. states by forcing menus to update now.
|
||||
*/
|
||||
|
@ -9240,7 +9317,6 @@ nautilus_files_view_set_property (GObject *object,
|
|||
{
|
||||
NautilusFilesView *directory_view;
|
||||
NautilusFilesViewPrivate *priv;
|
||||
NautilusWindowSlot *slot;
|
||||
|
||||
directory_view = NAUTILUS_FILES_VIEW (object);
|
||||
priv = nautilus_files_view_get_instance_private (directory_view);
|
||||
|
@ -9251,12 +9327,7 @@ nautilus_files_view_set_property (GObject *object,
|
|||
{
|
||||
g_assert (priv->slot == NULL);
|
||||
|
||||
slot = NAUTILUS_WINDOW_SLOT (g_value_get_object (value));
|
||||
priv->slot = slot;
|
||||
|
||||
g_signal_connect_object (priv->slot,
|
||||
"notify::active", G_CALLBACK (slot_active_changed),
|
||||
directory_view, 0);
|
||||
priv->slot = NAUTILUS_WINDOW_SLOT (g_value_get_object (value));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -9484,6 +9555,25 @@ nautilus_files_view_iface_init (NautilusViewInterface *iface)
|
|||
iface->set_extensions_background_menu = nautilus_files_view_set_extensions_background_menu;
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_files_view_constructed (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (nautilus_files_view_parent_class)->constructed (object);
|
||||
|
||||
NautilusFilesView *self = NAUTILUS_FILES_VIEW (object);
|
||||
NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (self);
|
||||
NautilusMode mode = nautilus_window_slot_get_mode (priv->slot);
|
||||
|
||||
g_signal_connect_object (priv->slot, "notify::active",
|
||||
G_CALLBACK (slot_active_changed), self,
|
||||
G_CONNECT_DEFAULT);
|
||||
|
||||
priv->model = nautilus_view_model_new (nautilus_mode_is_single_selection (mode));
|
||||
g_signal_connect_object (GTK_SELECTION_MODEL (priv->model), "selection-changed",
|
||||
G_CALLBACK (nautilus_files_view_notify_selection_changed), self,
|
||||
G_CONNECT_SWAPPED);
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_files_view_class_init (NautilusFilesViewClass *klass)
|
||||
{
|
||||
|
@ -9493,6 +9583,7 @@ nautilus_files_view_class_init (NautilusFilesViewClass *klass)
|
|||
widget_class = GTK_WIDGET_CLASS (klass);
|
||||
oclass = G_OBJECT_CLASS (klass);
|
||||
|
||||
oclass->constructed = nautilus_files_view_constructed;
|
||||
oclass->dispose = nautilus_files_view_dispose;
|
||||
oclass->finalize = nautilus_files_view_finalize;
|
||||
oclass->get_property = nautilus_files_view_get_property;
|
||||
|
@ -9675,13 +9766,6 @@ nautilus_files_view_init (NautilusFilesView *view)
|
|||
/* Ensure opaque background, to hide the view underneath it. */
|
||||
gtk_widget_add_css_class (priv->empty_view_page, "view");
|
||||
|
||||
priv->model = nautilus_view_model_new ();
|
||||
g_signal_connect_object (GTK_SELECTION_MODEL (priv->model),
|
||||
"selection-changed",
|
||||
G_CALLBACK (nautilus_files_view_notify_selection_changed),
|
||||
view,
|
||||
G_CONNECT_SWAPPED);
|
||||
|
||||
/* Toolbar menu */
|
||||
builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-toolbar-view-menu.ui");
|
||||
priv->toolbar_menu_sections = g_new0 (NautilusToolbarMenuSections, 1);
|
||||
|
@ -9837,6 +9921,8 @@ create_inner_view (NautilusFilesView *self,
|
|||
guint id)
|
||||
{
|
||||
NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (self);
|
||||
NautilusMode mode = nautilus_window_slot_get_mode (priv->slot);
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case NAUTILUS_VIEW_GRID_ID:
|
||||
|
@ -9864,6 +9950,11 @@ create_inner_view (NautilusFilesView *self,
|
|||
}
|
||||
}
|
||||
|
||||
if (mode != NAUTILUS_MODE_BROWSE)
|
||||
{
|
||||
nautilus_list_base_disable_dnd (priv->list_base);
|
||||
}
|
||||
|
||||
gtk_overlay_set_child (GTK_OVERLAY (priv->overlay), GTK_WIDGET (priv->list_base));
|
||||
}
|
||||
|
||||
|
|
|
@ -469,6 +469,19 @@ setup_cell (GtkSignalListItemFactory *factory,
|
|||
gtk_expression_bind (expression, listitem, "accessible-label", listitem);
|
||||
}
|
||||
|
||||
static void
|
||||
on_model_changed (NautilusGridView *self)
|
||||
{
|
||||
NautilusViewModel *model = nautilus_list_base_get_model (NAUTILUS_LIST_BASE (self));
|
||||
|
||||
if (model != NULL)
|
||||
{
|
||||
gtk_grid_view_set_enable_rubberband (GTK_GRID_VIEW (self->view_ui),
|
||||
!nautilus_view_model_get_single_selection (model));
|
||||
}
|
||||
|
||||
gtk_grid_view_set_model (self->view_ui, GTK_SELECTION_MODEL (model));
|
||||
}
|
||||
static GtkGridView *
|
||||
create_view_ui (NautilusGridView *self)
|
||||
{
|
||||
|
@ -481,7 +494,6 @@ create_view_ui (NautilusGridView *self)
|
|||
g_signal_connect (factory, "unbind", G_CALLBACK (unbind_cell), self);
|
||||
|
||||
widget = gtk_grid_view_new (NULL, factory);
|
||||
g_object_bind_property (self, "model", widget, "model", G_BINDING_SYNC_CREATE);
|
||||
|
||||
/* We don't use the built-in child activation feature for clicks because it
|
||||
* doesn't fill all our needs nor does it match our expected behavior.
|
||||
|
@ -491,7 +503,6 @@ create_view_ui (NautilusGridView *self)
|
|||
* hover). Setting it to FALSE gives us the expected behavior. */
|
||||
gtk_grid_view_set_single_click_activate (GTK_GRID_VIEW (widget), FALSE);
|
||||
gtk_grid_view_set_max_columns (GTK_GRID_VIEW (widget), 20);
|
||||
gtk_grid_view_set_enable_rubberband (GTK_GRID_VIEW (widget), TRUE);
|
||||
gtk_grid_view_set_tab_behavior (GTK_GRID_VIEW (widget), GTK_LIST_TAB_ITEM);
|
||||
|
||||
/* While we don't want to use GTK's click activation, we'll let it handle
|
||||
|
@ -541,6 +552,8 @@ nautilus_grid_view_init (NautilusGridView *self)
|
|||
self->view_ui = create_view_ui (self);
|
||||
nautilus_list_base_setup_gestures (NAUTILUS_LIST_BASE (self));
|
||||
|
||||
g_signal_connect_swapped (self, "notify::model", G_CALLBACK (on_model_changed), self);
|
||||
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||
GTK_WIDGET (self->view_ui));
|
||||
|
||||
|
|
|
@ -44,7 +44,9 @@ struct _NautilusListBasePrivate
|
|||
GtkWidget *overlay;
|
||||
GtkWidget *scrolled_window;
|
||||
|
||||
gboolean dnd_disabled;
|
||||
gboolean single_click_mode;
|
||||
|
||||
gboolean activate_on_release;
|
||||
gboolean deny_background_click;
|
||||
|
||||
|
@ -203,9 +205,15 @@ rubberband_set_state (NautilusListBase *self,
|
|||
* rubberband on item release/stop. See:
|
||||
* https://gitlab.gnome.org/GNOME/gtk/-/issues/5670 */
|
||||
|
||||
GtkWidget *view;
|
||||
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
|
||||
|
||||
view = nautilus_list_base_get_view_ui (self);
|
||||
if (priv->model != NULL && nautilus_view_model_get_single_selection (priv->model))
|
||||
{
|
||||
/* Rubberband is always disabled in this case. Do nothing. */
|
||||
return;
|
||||
}
|
||||
|
||||
GtkWidget *view = nautilus_list_base_get_view_ui (self);
|
||||
if (GTK_IS_GRID_VIEW (view))
|
||||
{
|
||||
gtk_grid_view_set_enable_rubberband (GTK_GRID_VIEW (view), enabled);
|
||||
|
@ -424,6 +432,11 @@ on_item_drag_prepare (GtkDragSource *source,
|
|||
GtkBitsetIter iter;
|
||||
guint i;
|
||||
|
||||
if (priv->dnd_disabled)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Anticipate selection, if necessary, for dragging the clicked item. */
|
||||
select_single_item_if_not_selected (self, cell);
|
||||
|
||||
|
@ -607,6 +620,12 @@ on_item_drag_enter (GtkDropTarget *target,
|
|||
/* Reset action cache. */
|
||||
priv->drag_item_action = 0;
|
||||
|
||||
if (priv->dnd_disabled)
|
||||
{
|
||||
gtk_drop_target_reject (target);
|
||||
return 0;
|
||||
}
|
||||
|
||||
item = nautilus_view_cell_get_item (cell);
|
||||
if (item == NULL)
|
||||
{
|
||||
|
@ -733,6 +752,12 @@ on_view_drag_enter (GtkDropTarget *target,
|
|||
NautilusFile *dest_file = nautilus_list_base_get_directory_as_file (self);
|
||||
const GValue *value;
|
||||
|
||||
if (priv->dnd_disabled)
|
||||
{
|
||||
gtk_drop_target_reject (target);
|
||||
return 0;
|
||||
}
|
||||
|
||||
value = gtk_drop_target_get_value (target);
|
||||
priv->drag_view_action = get_preferred_action (dest_file, value);
|
||||
if (priv->drag_view_action == 0)
|
||||
|
@ -1362,6 +1387,14 @@ nautilus_list_base_setup_gestures (NautilusListBase *self)
|
|||
priv->view_drop_target = drop_target;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_list_base_disable_dnd (NautilusListBase *self)
|
||||
{
|
||||
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
|
||||
|
||||
priv->dnd_disabled = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_list_base_get_backing_item:
|
||||
*
|
||||
|
|
|
@ -50,6 +50,7 @@ struct _NautilusListBaseClass
|
|||
NautilusDirectory *directory);
|
||||
};
|
||||
|
||||
void nautilus_list_base_disable_dnd (NautilusListBase *self);
|
||||
NautilusViewItem *nautilus_list_base_get_backing_item (NautilusListBase *self);
|
||||
GtkWidget *nautilus_list_base_get_selected_item_ui (NautilusListBase *self);
|
||||
GVariant *nautilus_list_base_get_sort_state (NautilusListBase *self);
|
||||
|
|
|
@ -383,7 +383,6 @@ create_view_ui (NautilusListView *self)
|
|||
* activation, as it affects the selection behavior as well (e.g. selects on
|
||||
* hover). Setting it to FALSE gives us the expected behavior. */
|
||||
gtk_column_view_set_single_click_activate (GTK_COLUMN_VIEW (widget), FALSE);
|
||||
gtk_column_view_set_enable_rubberband (GTK_COLUMN_VIEW (widget), TRUE);
|
||||
gtk_column_view_set_tab_behavior (GTK_COLUMN_VIEW (widget), GTK_LIST_TAB_ITEM);
|
||||
gtk_column_view_set_row_factory (GTK_COLUMN_VIEW (widget), row_factory);
|
||||
|
||||
|
@ -1078,6 +1077,9 @@ on_model_changed (NautilusListView *self)
|
|||
nautilus_view_model_set_sorter (model, self->view_model_sorter);
|
||||
|
||||
nautilus_view_model_expand_as_a_tree (model, self->expand_as_a_tree);
|
||||
|
||||
gtk_column_view_set_enable_rubberband (GTK_COLUMN_VIEW (self->view_ui),
|
||||
!nautilus_view_model_get_single_selection (model));
|
||||
}
|
||||
|
||||
gtk_column_view_set_model (self->view_ui, GTK_SELECTION_MODEL (model));
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "nautilus-scheme.h"
|
||||
#include "nautilus-signaller.h"
|
||||
#include "nautilus-ui-utilities.h"
|
||||
#include "nautilus-window-slot.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -1644,12 +1645,10 @@ activate_files_internal (ActivateParameters *parameters)
|
|||
}
|
||||
|
||||
location_with_permissions = g_file_new_for_uri (uri);
|
||||
/* FIXME: we need to pass the parent_window, but we only use it for the current active window,
|
||||
* which nautilus-application should take care of. However is not working and creating regressions
|
||||
* in some cases. Until we figure out what's going on, continue to use the parameters->slot
|
||||
* to make splicit the window we want to use for activating the files */
|
||||
nautilus_application_open_location_full (NAUTILUS_APPLICATION (g_application_get_default ()),
|
||||
location_with_permissions, parameters->flags, NULL, NULL, parameters->slot);
|
||||
nautilus_window_slot_open_location_full (parameters->slot,
|
||||
location_with_permissions,
|
||||
parameters->flags,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
38
src/nautilus-mode.h
Normal file
38
src/nautilus-mode.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (C) 2024 GNOME Foundation Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Original Author: António Fernandes <antoniof@gnome.org>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NAUTILUS_MODE_BROWSE = 0,
|
||||
NAUTILUS_MODE_OPEN_FILE,
|
||||
NAUTILUS_MODE_OPEN_FILES,
|
||||
NAUTILUS_MODE_OPEN_FOLDER,
|
||||
NAUTILUS_MODE_OPEN_FOLDERS,
|
||||
NAUTILUS_MODE_SAVE_FILE,
|
||||
NAUTILUS_MODE_SAVE_FILES,
|
||||
} NautilusMode;
|
||||
|
||||
#define nautilus_mode_is_save(mode) \
|
||||
((mode) == NAUTILUS_MODE_SAVE_FILE || \
|
||||
(mode) == NAUTILUS_MODE_SAVE_FILES)
|
||||
|
||||
#define nautilus_mode_is_open(mode) \
|
||||
((mode) == NAUTILUS_MODE_OPEN_FILE || \
|
||||
(mode) == NAUTILUS_MODE_OPEN_FILES || \
|
||||
(mode) == NAUTILUS_MODE_OPEN_FOLDER || \
|
||||
(mode) == NAUTILUS_MODE_OPEN_FOLDERS)
|
||||
|
||||
#define nautilus_mode_is_single_selection(mode) \
|
||||
((mode) == NAUTILUS_MODE_OPEN_FILE || \
|
||||
(mode) == NAUTILUS_MODE_OPEN_FOLDER || \
|
||||
(mode) == NAUTILUS_MODE_SAVE_FILE || \
|
||||
(mode) == NAUTILUS_MODE_SAVE_FILES)
|
|
@ -12,8 +12,9 @@ struct _NautilusViewModel
|
|||
|
||||
GtkTreeListModel *tree_model;
|
||||
GtkSortListModel *sort_model;
|
||||
GtkMultiSelection *selection_model;
|
||||
GtkSelectionModel *selection_model;
|
||||
|
||||
gboolean single_selection;
|
||||
gboolean expand_as_a_tree;
|
||||
GList *cut_files;
|
||||
};
|
||||
|
@ -111,9 +112,8 @@ nautilus_view_model_is_selected (GtkSelectionModel *model,
|
|||
guint position)
|
||||
{
|
||||
NautilusViewModel *self = NAUTILUS_VIEW_MODEL (model);
|
||||
GtkSelectionModel *selection_model = GTK_SELECTION_MODEL (self->selection_model);
|
||||
|
||||
return gtk_selection_model_is_selected (selection_model, position);
|
||||
return gtk_selection_model_is_selected (self->selection_model, position);
|
||||
}
|
||||
|
||||
static GtkBitset *
|
||||
|
@ -122,9 +122,18 @@ nautilus_view_model_get_selection_in_range (GtkSelectionModel *model,
|
|||
guint n_items)
|
||||
{
|
||||
NautilusViewModel *self = NAUTILUS_VIEW_MODEL (model);
|
||||
GtkSelectionModel *selection_model = GTK_SELECTION_MODEL (self->selection_model);
|
||||
|
||||
return gtk_selection_model_get_selection_in_range (selection_model, pos, n_items);
|
||||
return gtk_selection_model_get_selection_in_range (self->selection_model, pos, n_items);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
nautilus_view_model_select_item (GtkSelectionModel *model,
|
||||
guint position,
|
||||
gboolean unselect_rest)
|
||||
{
|
||||
NautilusViewModel *self = NAUTILUS_VIEW_MODEL (model);
|
||||
|
||||
return gtk_selection_model_select_item (self->selection_model, position, unselect_rest);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -133,12 +142,18 @@ nautilus_view_model_set_selection (GtkSelectionModel *model,
|
|||
GtkBitset *mask)
|
||||
{
|
||||
NautilusViewModel *self = NAUTILUS_VIEW_MODEL (model);
|
||||
GtkSelectionModel *selection_model = GTK_SELECTION_MODEL (self->selection_model);
|
||||
gboolean res;
|
||||
|
||||
res = gtk_selection_model_set_selection (selection_model, selected, mask);
|
||||
return gtk_selection_model_set_selection (self->selection_model, selected, mask);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
static gboolean
|
||||
nautilus_view_model_unselect_item (GtkSelectionModel *model,
|
||||
guint position)
|
||||
{
|
||||
NautilusViewModel *self = NAUTILUS_VIEW_MODEL (model);
|
||||
|
||||
return gtk_selection_model_unselect_item (self->selection_model, position);
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,7 +162,9 @@ nautilus_view_model_selection_model_init (GtkSelectionModelInterface *iface)
|
|||
{
|
||||
iface->is_selected = nautilus_view_model_is_selected;
|
||||
iface->get_selection_in_range = nautilus_view_model_get_selection_in_range;
|
||||
iface->select_item = nautilus_view_model_select_item;
|
||||
iface->set_selection = nautilus_view_model_set_selection;
|
||||
iface->unselect_item = nautilus_view_model_unselect_item;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NautilusViewModel, nautilus_view_model, G_TYPE_OBJECT,
|
||||
|
@ -161,6 +178,7 @@ G_DEFINE_TYPE_WITH_CODE (NautilusViewModel, nautilus_view_model, G_TYPE_OBJECT,
|
|||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_SINGLE_SELECTION,
|
||||
PROP_SORTER,
|
||||
N_PROPS
|
||||
};
|
||||
|
@ -221,6 +239,12 @@ get_property (GObject *object,
|
|||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SINGLE_SELECTION:
|
||||
{
|
||||
g_value_set_boolean (value, nautilus_view_model_get_single_selection (self));
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_SORTER:
|
||||
{
|
||||
g_value_set_object (value, nautilus_view_model_get_sorter (self));
|
||||
|
@ -244,6 +268,12 @@ set_property (GObject *object,
|
|||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SINGLE_SELECTION:
|
||||
{
|
||||
self->single_selection = g_value_get_boolean (value);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_SORTER:
|
||||
{
|
||||
nautilus_view_model_set_sorter (self, g_value_get_object (value));
|
||||
|
@ -292,7 +322,21 @@ constructed (GObject *object)
|
|||
(GtkTreeListModelCreateModelFunc) create_model_func,
|
||||
self, NULL);
|
||||
self->sort_model = gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (self->tree_model)), NULL);
|
||||
self->selection_model = gtk_multi_selection_new (g_object_ref (G_LIST_MODEL (self->sort_model)));
|
||||
|
||||
if (self->single_selection)
|
||||
{
|
||||
GtkSingleSelection *single = gtk_single_selection_new (NULL);
|
||||
|
||||
gtk_single_selection_set_autoselect (single, FALSE);
|
||||
gtk_single_selection_set_can_unselect (single, TRUE);
|
||||
|
||||
gtk_single_selection_set_model (single, G_LIST_MODEL (self->sort_model));
|
||||
self->selection_model = GTK_SELECTION_MODEL (single);
|
||||
}
|
||||
else
|
||||
{
|
||||
self->selection_model = GTK_SELECTION_MODEL (gtk_multi_selection_new (g_object_ref (G_LIST_MODEL (self->sort_model))));
|
||||
}
|
||||
|
||||
self->map_files_to_model = g_hash_table_new (NULL, NULL);
|
||||
self->directory_reverse_map = g_hash_table_new_full (NULL, NULL, NULL, g_object_unref);
|
||||
|
@ -316,9 +360,12 @@ nautilus_view_model_class_init (NautilusViewModelClass *klass)
|
|||
object_class->set_property = set_property;
|
||||
object_class->constructed = constructed;
|
||||
|
||||
properties[PROP_SINGLE_SELECTION] =
|
||||
g_param_spec_boolean ("single-selection", NULL, NULL,
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
|
||||
properties[PROP_SORTER] =
|
||||
g_param_spec_object ("sorter",
|
||||
"", "",
|
||||
g_param_spec_object ("sorter", NULL, NULL,
|
||||
GTK_TYPE_SORTER,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
|
@ -346,9 +393,17 @@ compare_data_func (gconstpointer a,
|
|||
}
|
||||
|
||||
NautilusViewModel *
|
||||
nautilus_view_model_new (void)
|
||||
nautilus_view_model_new (gboolean single_selection)
|
||||
{
|
||||
return g_object_new (NAUTILUS_TYPE_VIEW_MODEL, NULL);
|
||||
return g_object_new (NAUTILUS_TYPE_VIEW_MODEL,
|
||||
"single-selection", single_selection,
|
||||
NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_view_model_get_single_selection (NautilusViewModel *self)
|
||||
{
|
||||
return self->single_selection;
|
||||
}
|
||||
|
||||
GtkSorter *
|
||||
|
|
|
@ -10,8 +10,9 @@ G_BEGIN_DECLS
|
|||
|
||||
G_DECLARE_FINAL_TYPE (NautilusViewModel, nautilus_view_model, NAUTILUS, VIEW_MODEL, GObject)
|
||||
|
||||
NautilusViewModel * nautilus_view_model_new (void);
|
||||
NautilusViewModel * nautilus_view_model_new (gboolean single_selection);
|
||||
|
||||
gboolean nautilus_view_model_get_single_selection (NautilusViewModel *self);
|
||||
GtkSorter *nautilus_view_model_get_sorter (NautilusViewModel *self);
|
||||
void nautilus_view_model_set_sorter (NautilusViewModel *self,
|
||||
GtkSorter *sorter);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "nautilus-application.h"
|
||||
#include "nautilus-bookmark.h"
|
||||
#include "nautilus-bookmark-list.h"
|
||||
#include "nautilus-enum-types.h"
|
||||
#include "nautilus-fd-holder.h"
|
||||
#include "nautilus-files-view.h"
|
||||
#include "nautilus-location-banner.h"
|
||||
|
@ -50,6 +51,7 @@
|
|||
enum
|
||||
{
|
||||
PROP_ACTIVE = 1,
|
||||
PROP_MODE,
|
||||
PROP_ICON_NAME,
|
||||
PROP_TOOLBAR_MENU_SECTIONS,
|
||||
PROP_EXTENSIONS_BACKGROUND_MENU,
|
||||
|
@ -65,10 +67,22 @@ enum
|
|||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *properties[NUM_PROPERTIES];
|
||||
|
||||
enum
|
||||
{
|
||||
SIGNAL_ACTIVATE_FILES,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL];
|
||||
|
||||
struct _NautilusWindowSlot
|
||||
{
|
||||
AdwBin parent_instance;
|
||||
|
||||
NautilusMode mode;
|
||||
|
||||
gboolean active : 1;
|
||||
guint loading : 1;
|
||||
|
||||
|
@ -146,8 +160,6 @@ struct _NautilusWindowSlot
|
|||
|
||||
G_DEFINE_TYPE (NautilusWindowSlot, nautilus_window_slot, ADW_TYPE_BIN);
|
||||
|
||||
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
|
||||
|
||||
static const GtkPadActionEntry pad_actions[] =
|
||||
{
|
||||
{ GTK_PAD_ACTION_BUTTON, 3, -1, N_("Parent folder"), "up" },
|
||||
|
@ -563,6 +575,27 @@ nautilus_window_slot_search (NautilusWindowSlot *self,
|
|||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_window_slot_handle_activate_files (NautilusWindowSlot *self,
|
||||
GList *files)
|
||||
{
|
||||
if (self->mode == NAUTILUS_MODE_BROWSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (files != NULL && files->next == NULL &&
|
||||
nautilus_file_opens_in_view (NAUTILUS_FILE (files->data)))
|
||||
{
|
||||
/* Single folder or folder-like item is always handled by the view. */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_signal_emit (self, signals[SIGNAL_ACTIVATE_FILES], 0, files);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_window_slot_handle_event (NautilusWindowSlot *self,
|
||||
GtkEventControllerKey *controller,
|
||||
|
@ -662,6 +695,12 @@ nautilus_window_slot_set_property (GObject *object,
|
|||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_MODE:
|
||||
{
|
||||
self->mode = g_value_get_enum (value);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_LOCATION:
|
||||
{
|
||||
nautilus_window_slot_set_location (self, g_value_get_object (value));
|
||||
|
@ -747,6 +786,12 @@ nautilus_window_slot_get_property (GObject *object,
|
|||
}
|
||||
break;
|
||||
|
||||
case PROP_MODE:
|
||||
{
|
||||
g_value_set_enum (value, nautilus_window_slot_get_mode (self));
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_ICON_NAME:
|
||||
{
|
||||
g_value_set_static_string (value, nautilus_window_slot_get_icon_name (self));
|
||||
|
@ -1901,7 +1946,7 @@ handle_regular_file_if_needed (NautilusWindowSlot *self,
|
|||
g_clear_object (&self->pending_file_to_activate);
|
||||
|
||||
self->pending_location = nautilus_file_get_parent_location (file);
|
||||
if (nautilus_mime_file_extracts (file))
|
||||
if (self->mode == NAUTILUS_MODE_BROWSE && nautilus_mime_file_extracts (file))
|
||||
{
|
||||
self->pending_file_to_activate = nautilus_file_ref (file);
|
||||
}
|
||||
|
@ -2895,6 +2940,11 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass)
|
|||
FALSE,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
properties[PROP_MODE] =
|
||||
g_param_spec_enum ("mode", NULL, NULL,
|
||||
NAUTILUS_TYPE_MODE, NAUTILUS_MODE_BROWSE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
properties[PROP_LOADING] =
|
||||
g_param_spec_boolean ("loading",
|
||||
"Whether the slot loading",
|
||||
|
@ -2976,6 +3026,12 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass)
|
|||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
|
||||
|
||||
signals[SIGNAL_ACTIVATE_FILES] = g_signal_new ("activate-files",
|
||||
G_TYPE_FROM_CLASS (oclass),
|
||||
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
|
||||
g_cclosure_marshal_VOID__POINTER,
|
||||
G_TYPE_NONE, 1, G_TYPE_POINTER);
|
||||
}
|
||||
|
||||
GFile *
|
||||
|
@ -3131,9 +3187,10 @@ nautilus_window_slot_get_forward_history (NautilusWindowSlot *self)
|
|||
}
|
||||
|
||||
NautilusWindowSlot *
|
||||
nautilus_window_slot_new (void)
|
||||
nautilus_window_slot_new (NautilusMode mode)
|
||||
{
|
||||
return g_object_new (NAUTILUS_TYPE_WINDOW_SLOT,
|
||||
"mode", mode,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
@ -3274,6 +3331,14 @@ nautilus_window_slot_set_loading (NautilusWindowSlot *self,
|
|||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LOADING]);
|
||||
}
|
||||
|
||||
NautilusMode
|
||||
nautilus_window_slot_get_mode (NautilusWindowSlot *self)
|
||||
{
|
||||
g_return_val_if_fail (NAUTILUS_IS_WINDOW_SLOT (self), NAUTILUS_MODE_BROWSE);
|
||||
|
||||
return self->mode;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_window_slot_get_loading (NautilusWindowSlot *self)
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <adwaita.h>
|
||||
|
||||
#include "nautilus-mode.h"
|
||||
#include "nautilus-types.h"
|
||||
|
||||
typedef enum {
|
||||
|
@ -46,13 +47,14 @@ typedef struct
|
|||
NautilusQuery *current_search_query;
|
||||
} NautilusNavigationState;
|
||||
|
||||
NautilusWindowSlot * nautilus_window_slot_new (void);
|
||||
NautilusWindowSlot * nautilus_window_slot_new (NautilusMode mode);
|
||||
|
||||
void nautilus_window_slot_open_location_full (NautilusWindowSlot *slot,
|
||||
GFile *location,
|
||||
NautilusOpenFlags flags,
|
||||
GList *new_selection);
|
||||
|
||||
NautilusMode nautilus_window_slot_get_mode (NautilusWindowSlot *slot);
|
||||
GFile * nautilus_window_slot_get_location (NautilusWindowSlot *slot);
|
||||
GFile * nautilus_window_slot_get_pending_location (NautilusWindowSlot *slot);
|
||||
|
||||
|
@ -69,6 +71,8 @@ void nautilus_window_slot_stop_loading (NautilusWindowSlot *
|
|||
const gchar *nautilus_window_slot_get_title (NautilusWindowSlot *slot);
|
||||
void nautilus_window_slot_update_title (NautilusWindowSlot *slot);
|
||||
|
||||
gboolean nautilus_window_slot_handle_activate_files (NautilusWindowSlot *slot,
|
||||
GList *files);
|
||||
gboolean nautilus_window_slot_handle_event (NautilusWindowSlot *slot,
|
||||
GtkEventControllerKey *controller,
|
||||
guint keyval,
|
||||
|
|
|
@ -494,7 +494,7 @@ nautilus_window_create_and_init_slot (NautilusWindow *window,
|
|||
{
|
||||
NautilusWindowSlot *slot;
|
||||
|
||||
slot = nautilus_window_slot_new ();
|
||||
slot = nautilus_window_slot_new (NAUTILUS_MODE_BROWSE);
|
||||
nautilus_window_initialize_slot (window, slot, flags);
|
||||
|
||||
return slot;
|
||||
|
@ -1718,7 +1718,7 @@ nautilus_window_back_or_forward_in_new_tab (NautilusWindow *window,
|
|||
NautilusNavigationState *state;
|
||||
|
||||
window_slot = nautilus_window_get_active_slot (window);
|
||||
new_slot = nautilus_window_slot_new ();
|
||||
new_slot = nautilus_window_slot_new (NAUTILUS_MODE_BROWSE);
|
||||
state = nautilus_window_slot_get_navigation_state (window_slot);
|
||||
|
||||
/* Manually fix up the back / forward lists and location.
|
||||
|
|
|
@ -265,6 +265,7 @@
|
|||
<item>
|
||||
<attribute name="label" translatable="yes">P_roperties</attribute>
|
||||
<attribute name="action">view.properties</attribute>
|
||||
<attribute name="hidden-when">action-disabled</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
|
|
Loading…
Reference in New Issue
Block a user