diff options
author | António Fernandes <antoniof@gnome.org> | 2022-02-11 19:06:17 +0000 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2022-02-11 19:24:09 +0000 |
commit | c65839f0cd7510ad458fafe5deeed66b6f70a1bd (patch) | |
tree | cb6aedd3ddbb988c387526088ff5bb7935de9373 | |
parent | b9e939ae383226b05e2acdc2e17faa5ff2f8971e (diff) | |
download | nautilus-c65839f0cd7510ad458fafe5deeed66b6f70a1bd.tar.gz |
Revert "files-view: Stop setting custom filechooser filter"
This reverts commit 610b6902921ae9bdb1d23e044a5ba61ebc45afc2.
-rw-r--r-- | src/nautilus-files-view.c | 56 |
1 files changed, 56 insertions, 0 deletions
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)); |