Commit ebd6a475 authored by George Mocanu's avatar George Mocanu Committed by Ernestas Kulik

files-view: Indicate when Ctrl+V cannot be executed

Currently, the Paste action is disabled in Read-Only
directories (both the Ctrl+V accelerator and the "Paste"
option from Context Menu), but the user isn't informed
that the operation cannot be executed if he uses Ctrl+V.

A pop-over should inform the user that the Paste action
couldn't be completed if Ctrl+V accelerator was used.

This patch solves this by adding a new action and mapping
the Ctrl+V accelerator to that.

Closes #824
parent b0f52607
Pipeline #78645 failed with stages
in 13 minutes and 8 seconds
......@@ -2660,6 +2660,23 @@ paste_clipboard_text_received_callback (GtkClipboard *clipboard,
g_object_unref (view);
}
static void
paste_files (NautilusFilesView *view)
{
GtkClipboard *clipboard;
clipboard = nautilus_clipboard_get (GTK_WIDGET (view));
/* Performing an async request of clipboard contents, corresponding unref
* is in the callback.
*/
g_object_ref (view);
gtk_clipboard_request_text (clipboard,
paste_clipboard_text_received_callback,
view);
}
static void
action_paste_files (GSimpleAction *action,
GVariant *state,
......@@ -2667,14 +2684,31 @@ action_paste_files (GSimpleAction *action,
{
NautilusFilesView *view;
g_assert (NAUTILUS_IS_FILES_VIEW (user_data));
view = NAUTILUS_FILES_VIEW (user_data);
paste_files (view);
}
static void
action_paste_files_accel (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
NautilusFilesView *view;
view = NAUTILUS_FILES_VIEW (user_data);
g_object_ref (view);
gtk_clipboard_request_text (nautilus_clipboard_get (GTK_WIDGET (view)),
paste_clipboard_text_received_callback,
view);
if (nautilus_files_view_is_read_only (view))
{
show_dialog (_("Could not paste files"),
_("Permissions do not allow pasting files in this directory"),
nautilus_files_view_get_containing_window (view),
GTK_MESSAGE_ERROR);
}
else
{
paste_files (view);
}
}
static void
......@@ -6907,6 +6941,7 @@ const GActionEntry view_entries[] =
{ "new-folder", action_new_folder },
{ "select-all", action_select_all },
{ "paste", action_paste_files },
{ "paste_accel", action_paste_files_accel },
{ "create-link", action_create_links },
{ "new-document" },
/* Selection menu */
......@@ -9687,7 +9722,7 @@ nautilus_files_view_init (NautilusFilesView *view)
nautilus_application_set_accelerator (app, "view.show-hidden-files", "<control>h");
/* Background menu */
nautilus_application_set_accelerator (app, "view.select-all", "<control>a");
nautilus_application_set_accelerator (app, "view.paste", "<control>v");
nautilus_application_set_accelerator (app, "view.paste_accel", "<control>v");
nautilus_application_set_accelerator (app, "view.create-link", "<control>m");
/* Selection menu */
nautilus_application_set_accelerators (app, "view.open-with-default-application", open_accels);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment