[nautilus/wip/antoniof/gnome-42: 65/72] Revert "files-view: Stop setting custom filechooser filter"




commit c65839f0cd7510ad458fafe5deeed66b6f70a1bd
Author: António Fernandes <antoniof gnome org>
Date:   Fri Feb 11 19:06:17 2022 +0000

    Revert "files-view: Stop setting custom filechooser filter"
    
    This reverts commit 610b6902921ae9bdb1d23e044a5ba61ebc45afc2.

 src/nautilus-files-view.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 0e8908e8e..c859d9fd3 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -5893,6 +5893,45 @@ on_destination_dialog_response (GtkDialog *dialog,
     gtk_widget_destroy (GTK_WIDGET (dialog));
 }
 
+static gboolean
+destination_dialog_filter_cb (const GtkFileFilterInfo *filter_info,
+                              gpointer                 user_data)
+{
+    GList *selection = user_data;
+    GList *l;
+
+    for (l = selection; l != NULL; l = l->next)
+    {
+        char *uri;
+        uri = nautilus_file_get_uri (l->data);
+        if (strcmp (uri, filter_info->uri) == 0)
+        {
+            g_free (uri);
+            return FALSE;
+        }
+        g_free (uri);
+    }
+
+    return TRUE;
+}
+
+static GList *
+get_selected_folders (GList *selection)
+{
+    GList *folders;
+    GList *l;
+
+    folders = NULL;
+    for (l = selection; l != NULL; l = l->next)
+    {
+        if (nautilus_file_is_directory (l->data))
+        {
+            folders = g_list_prepend (folders, nautilus_file_ref (l->data));
+        }
+    }
+    return g_list_reverse (folders);
+}
+
 static void
 copy_or_move_selection (NautilusFilesView *view,
                         gboolean           is_move)
@@ -5937,6 +5976,23 @@ copy_or_move_selection (NautilusFilesView *view,
     copy_data->selection = selection;
     copy_data->is_move = is_move;
 
+    if (selection != NULL)
+    {
+        GtkFileFilter *filter;
+        GList *folders;
+
+        folders = get_selected_folders (selection);
+
+        filter = gtk_file_filter_new ();
+        gtk_file_filter_add_custom (filter,
+                                    GTK_FILE_FILTER_URI,
+                                    destination_dialog_filter_cb,
+                                    folders,
+                                    (GDestroyNotify) nautilus_file_list_free);
+        gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
+    }
+
+
     if (nautilus_view_is_searching (NAUTILUS_VIEW (view)))
     {
         directory = nautilus_search_directory_get_base_model (NAUTILUS_SEARCH_DIRECTORY (priv->model));


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