[nautilus/wip/corey/dnd_features: 4/7] dnd: Allow dropping to Starred




commit 030466279b101f709903d4969cf8e485f5c5de03
Author: Corey Berla <corey berla me>
Date:   Thu Aug 18 09:42:01 2022 -0700

    dnd: Allow dropping to Starred

 src/gtk/nautilusgtkplacessidebar.c |  6 ------
 src/nautilus-dnd.c                 |  4 ++++
 src/nautilus-list-base.c           | 40 ++++++++++++++++++++++++++++----------
 src/nautilus-window.c              | 31 +++++++++++++++++++++--------
 4 files changed, 57 insertions(+), 24 deletions(-)
---
diff --git a/src/gtk/nautilusgtkplacessidebar.c b/src/gtk/nautilusgtkplacessidebar.c
index 9ba3e0c99..c110917f6 100644
--- a/src/gtk/nautilusgtkplacessidebar.c
+++ b/src/gtk/nautilusgtkplacessidebar.c
@@ -1497,12 +1497,6 @@ check_valid_drop_target (NautilusGtkPlacesSidebar *sidebar,
                 "file", &dest_file,
                 NULL);
 
-  if (place_type == NAUTILUS_GTK_PLACES_STARRED_LOCATION)
-    {
-      g_free (uri);
-      return FALSE;
-    }
-
   if (place_type == NAUTILUS_GTK_PLACES_CONNECT_TO_SERVER)
     {
       g_free (uri);
diff --git a/src/nautilus-dnd.c b/src/nautilus-dnd.c
index b6a87a1ba..6c2522318 100644
--- a/src/nautilus-dnd.c
+++ b/src/nautilus-dnd.c
@@ -174,6 +174,10 @@ nautilus_dnd_get_preferred_action (NautilusFile *target_file,
     {
         return GDK_ACTION_COPY;
     }
+    else if (nautilus_file_is_starred_location (target_file))
+    {
+        return GDK_ACTION_COPY;
+    }
     else if (!nautilus_file_is_directory (target_file) ||
              !nautilus_file_can_write (target_file))
     {
diff --git a/src/nautilus-list-base.c b/src/nautilus-list-base.c
index 568f2328c..3b8de9867 100644
--- a/src/nautilus-list-base.c
+++ b/src/nautilus-list-base.c
@@ -17,6 +17,7 @@
 #include "nautilus-file-operations.h"
 #include "nautilus-metadata.h"
 #include "nautilus-global-preferences.h"
+#include "nautilus-tag-manager.h"
 #include "nautilus-thumbnails.h"
 
 /**
@@ -661,20 +662,39 @@ real_perform_drop (NautilusListBase *self,
     }
     else if (G_VALUE_HOLDS (value, GDK_TYPE_FILE_LIST))
     {
-        GSList *source_file_list = g_value_get_boxed (value);
-        GList *source_uri_list = NULL;
+        GSList *source_location_list = g_value_get_boxed (value);
+        g_autoptr (NautilusFile) target_file = nautilus_file_get (target_location);
 
-        for (GSList *l = source_file_list; l != NULL; l = l->next)
+        if (nautilus_file_is_starred_location (target_file))
         {
-            source_uri_list = g_list_prepend (source_uri_list, g_file_get_uri (l->data));
+            g_autolist (NautilusFile) source_file_list = NULL;
+
+            for (GSList *l = source_location_list; l != NULL; l = l->next)
+            {
+                source_file_list = g_list_prepend (source_file_list , nautilus_file_get (l->data));
+            }
+
+            source_file_list = g_list_reverse (source_file_list);
+            nautilus_tag_manager_star_files (nautilus_tag_manager_get (),
+                                             G_OBJECT (self),
+                                             source_file_list, NULL, NULL);
         }
-        source_uri_list = g_list_reverse (source_uri_list);
+        else
+        {
+            GList *source_uri_list = NULL;
 
-        nautilus_files_view_drop_proxy_received_uris (NAUTILUS_FILES_VIEW (self),
-                                                      source_uri_list,
-                                                      target_uri,
-                                                      action);
-        g_list_free_full (source_uri_list, g_free);
+            for (GSList *l = source_location_list; l != NULL; l = l->next)
+            {
+                source_uri_list = g_list_prepend (source_uri_list, g_file_get_uri (l->data));
+            }
+
+            source_uri_list = g_list_reverse (source_uri_list);
+            nautilus_files_view_drop_proxy_received_uris (NAUTILUS_FILES_VIEW (self),
+                                                          source_uri_list,
+                                                          target_uri,
+                                                          action);
+            g_list_free_full (source_uri_list, g_free);
+        }
     }
 }
 
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index eb6bec176..b38463ee5 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -64,6 +64,7 @@
 #include "nautilus-pathbar.h"
 #include "nautilus-profile.h"
 #include "nautilus-signaller.h"
+#include "nautilus-tag-manager.h"
 #include "nautilus-toolbar.h"
 #include "nautilus-trash-monitor.h"
 #include "nautilus-ui-utilities.h"
@@ -955,20 +956,34 @@ build_uri_list_from_gfile_list (GSList *file_list)
 static void
 places_sidebar_drag_perform_drop_cb (NautilusGtkPlacesSidebar *sidebar,
                                      GFile                    *dest_file,
-                                     GSList                   *source_file_list,
+                                     GSList                   *source_location_list,
                                      GdkDragAction             action,
                                      gpointer                  user_data)
 {
-    char *dest_uri;
-    GList *source_uri_list;
+    g_autoptr (NautilusFile) target_file = nautilus_file_get (dest_file);
 
-    dest_uri = g_file_get_uri (dest_file);
-    source_uri_list = build_uri_list_from_gfile_list (source_file_list);
+    if (nautilus_file_is_starred_location (target_file))
+    {
+        g_autolist (NautilusFile) source_file_list = NULL;
+
+        for (GSList *l = source_location_list; l != NULL; l = l->next)
+        {
+            source_file_list = g_list_prepend (source_file_list , nautilus_file_get (l->data));
+        }
 
-    nautilus_file_operations_copy_move (source_uri_list, dest_uri, action, GTK_WIDGET (sidebar), NULL, NULL, 
NULL);
+        source_file_list = g_list_reverse (source_file_list);
+        nautilus_tag_manager_star_files (nautilus_tag_manager_get (),
+                                         G_OBJECT (sidebar),
+                                         source_file_list, NULL, NULL);
+    }
+    else
+    {
+        g_autofree gchar *dest_uri = g_file_get_uri (dest_file);
+        GList *source_uri_list = build_uri_list_from_gfile_list (source_location_list);
 
-    g_free (dest_uri);
-    g_list_free_full (source_uri_list, g_free);
+        nautilus_file_operations_copy_move (source_uri_list, dest_uri, action, GTK_WIDGET (sidebar), NULL, 
NULL, NULL);
+        g_list_free_full (source_uri_list, g_free);
+    }
 }
 
 static void


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