[nautilus/gnome-42] Fix move operation in treeview DnD



commit 222bb41f8081be9ac1a023bdc8f66ab267365a4d
Author: Sergio Costas <rastersoft gmail com>
Date:   Mon Feb 14 19:01:42 2022 +0100

    Fix move operation in treeview DnD
    
    When doing a DnD operation from outside Nautilus into one of
    its windows, if the window is in "iconview mode", Nautilus
    is able to detect when the origin and the destination folders
    are in the same disk volume and do a move in that case, or
    do a copy when they are in different volumes.
    
    Unfortunately, when the window is in "treeview mode", this
    operation doesn't work as expected, and always copy the file(s),
    no matter if the origin and destination folders are or not in
    the same volume.
    
    After tracking the bug, I found that, in "treeview mode", the
    NautilusFile object with the destination folder doesn't have
    defined the filesystem_id property. This makes fail the
    check_same_fs() function, which always returns FALSE. In
    "iconview mode", instead, the object does have that property
    defined, and that's why there it works.
    
    I did a fix proposal, and although it was a safe workaround,
    António Fernandes found a better way to fix it, which is
    this patch.
    
    Fix https://gitlab.gnome.org/GNOME/nautilus/-/issues/2170

 src/nautilus-tree-view-drag-dest.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/src/nautilus-tree-view-drag-dest.c b/src/nautilus-tree-view-drag-dest.c
index cd87f187f..fbb43e047 100644
--- a/src/nautilus-tree-view-drag-dest.c
+++ b/src/nautilus-tree-view-drag-dest.c
@@ -883,6 +883,20 @@ receive_xds (NautilusTreeViewDragDest *dest,
     return TRUE;
 }
 
+static void
+cache_selection_list (NautilusTreeViewDragDest *dest)
+{
+    g_autolist (NautilusFile) files = NULL;
+
+    /* File selection list information (mostly the file system info, in order to
+     * know if we want to copy or move the files) about the files being dragged,
+     * that can come from another process, like desktop icons extension. */
+
+    files = nautilus_drag_file_list_from_selection_list (dest->details->drag_list);
+    nautilus_file_list_call_when_ready (files,
+                                        NAUTILUS_FILE_ATTRIBUTE_INFO,
+                                        NULL, NULL, NULL);
+}
 
 static gboolean
 drag_data_received_callback (GtkWidget        *widget,
@@ -911,6 +925,7 @@ drag_data_received_callback (GtkWidget        *widget,
         {
             dest->details->drag_list =
                 nautilus_drag_build_selection_list (selection_data);
+            cache_selection_list (dest);
         }
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]