[nautilus/wip/antoniof/gtk4-preparation-file-chooser-api: 2/5] files-view: Stop setting custom filechooser filter




commit d06a1835af9551eb4923b06d01fd139dac5e4d18
Author: António Fernandes <antoniof gnome org>
Date:   Wed Dec 22 23:43:51 2021 +0000

    files-view: Stop setting custom filechooser filter
    
    We set a custom filter to prevent selecting a folder that's part of the
    selection as the destination to move that selection.
    
    GTK 4 doesn't support custom filters, and the available options don't
    fit this purpose.
    
    Just remove it. It's safe: we popup an error dialog saying you can't
    move a folder into iself. Of course, it would better not to allow the
    user to make this mistake, but let's we can't have everything.

 src/nautilus-files-view.c | 56 -----------------------------------------------
 1 file changed, 56 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index dfb7fb26c..98a5a3289 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -5952,45 +5952,6 @@ 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)
@@ -6035,23 +5996,6 @@ 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]