[nautilus/wip/corey/dnd_features] dnd: Allow GDK_ACTION_COPY within the same folder
- From: Corey Berla <coreyberla src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/corey/dnd_features] dnd: Allow GDK_ACTION_COPY within the same folder
- Date: Thu, 18 Aug 2022 19:43:13 +0000 (UTC)
commit fcc8007df492eef883047eec2ffc2a8c300a57fd
Author: Corey Berla <corey berla me>
Date: Thu Aug 18 12:11:11 2022 -0700
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
src/nautilus-dnd.c | 3 +--
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 7e537517c..08330da57 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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]