diff options
author | George Mocanu <mocanu.geo98@gmail.com> | 2019-01-13 15:17:24 +0200 |
---|---|---|
committer | Ernestas Kulik <ekulik@redhat.com> | 2019-04-30 13:13:42 +0200 |
commit | ebd6a475737d112083993b090b5223151e3b634e (patch) | |
tree | 0a738fe627a42554301fd2b9456a15aaf2643517 | |
parent | b0f526070d4641bbe0e8508d8716a0fd22d314cc (diff) | |
download | nautilus-ebd6a475737d112083993b090b5223151e3b634e.tar.gz |
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 https://gitlab.gnome.org/GNOME/nautilus/issues/824
-rw-r--r-- | src/nautilus-files-view.c | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c index 591d87b52..0dad2fe96 100644 --- a/src/nautilus-files-view.c +++ b/src/nautilus-files-view.c @@ -2661,20 +2661,54 @@ paste_clipboard_text_received_callback (GtkClipboard *clipboard, } 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, gpointer user_data) { 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); |