diff options
author | Corey Berla <corey@berla.me> | 2022-08-18 12:11:11 -0700 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2022-09-01 21:42:41 +0000 |
commit | 1aca129eb7180f6b32cf5e30fafbe319a2008709 (patch) | |
tree | e8618d6d541b1ea65d9813c4ff35f88db9a73ffc | |
parent | 96ff1710e4c2d05c97e360a998074785b2d2e1de (diff) | |
download | nautilus-1aca129eb7180f6b32cf5e30fafbe319a2008709.tar.gz |
dnd: Allow GDK_ACTION_COPY within the same folder
We are setting the preferred action to 0 when the source and dest are
in the same folder. This prevents the ability to hold CTRL and perform
a copy operation (which worked in 42). It isn't clear why you can't
override a 0 preferred action with key modifiers.
In order to keep consistency, remove this check in
nautilus_dnd_get_preferred_action() and add it to
nautilus_files_view_drop_proxy_received_uris() (only if the action
is MOVE).
Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2438
-rw-r--r-- | src/nautilus-dnd.c | 3 | ||||
-rw-r--r-- | src/nautilus-files-view-dnd.c | 10 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/nautilus-dnd.c b/src/nautilus-dnd.c index 5f03f6178..6eca6e25d 100644 --- a/src/nautilus-dnd.c +++ b/src/nautilus-dnd.c @@ -204,8 +204,7 @@ nautilus_dnd_get_preferred_action (NautilusFile *target_file, } target_location = nautilus_file_get_location (target_file); - if (g_file_equal (target_location, dropped) || - g_file_has_parent (dropped, target_location)) + if (g_file_equal (target_location, dropped)) { return 0; } diff --git a/src/nautilus-files-view-dnd.c b/src/nautilus-files-view-dnd.c index 69254be65..c75ccb133 100644 --- a/src/nautilus-files-view-dnd.c +++ b/src/nautilus-files-view-dnd.c @@ -350,12 +350,22 @@ nautilus_files_view_drop_proxy_received_uris (NautilusFilesView *view, GdkDragAction action) { g_autofree char *container_uri = NULL; + g_autoptr (GFile) source_location = g_file_new_for_uri (source_uri_list->data); + g_autoptr (GFile) target_location = g_file_new_for_uri (target_uri); if (target_uri == NULL) { container_uri = nautilus_files_view_get_backing_uri (view); g_assert (container_uri != NULL); } + if (g_file_has_parent (source_location, target_location) && + action & GDK_ACTION_MOVE) + { + /* By default dragging to the same directory is allowed so that + * users can duplicate a file using the CTRL modifier key. Prevent + * an accidental MOVE, by rejecting what would be an error anyways. */ + return; + } if (action == GDK_ACTION_ASK) { |