[nautilus] files-view: Store selected files list for compressing
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] files-view: Store selected files list for compressing
- Date: Wed, 21 Jul 2021 23:33:04 +0000 (UTC)
commit 6c7eacd20302046521e89dd28240c6b0193ba942
Author: Anubhav Tyagi <tyagianubhav619 gmail com>
Date: Sat Jul 17 12:39:20 2021 +0530
files-view: Store selected files list for compressing
The selected files list is chosen after the user confirmed the compress
operation in the compress-dialog which may result in files other than
chosen file being compressed.
Store the list of selected files when the user chooses the "Compress"
option from the menu, to avoid that
Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/1900
src/nautilus-files-view.c | 37 +++++++++++++++++++++++++++----------
1 file changed, 27 insertions(+), 10 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index b09883e55..8bfab06be 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -302,6 +302,12 @@ typedef struct
NautilusDirectory *directory;
} FileAndDirectory;
+typedef struct
+{
+ NautilusFilesView *view;
+ GList *selection;
+} CompressCallbackData;
+
/* forward declarations */
static gboolean display_selection_info_idle_callback (gpointer data);
@@ -2236,9 +2242,9 @@ static void
compress_dialog_controller_on_name_accepted (NautilusFileNameWidgetController *controller,
gpointer user_data)
{
+ CompressCallbackData *callback_data = user_data;
NautilusFilesView *view;
g_autofree gchar *name = NULL;
- GList *selection;
GList *source_files = NULL;
GList *l;
CompressData *data;
@@ -2249,12 +2255,10 @@ compress_dialog_controller_on_name_accepted (NautilusFileNameWidgetController *c
AutoarFormat format;
AutoarFilter filter;
- view = NAUTILUS_FILES_VIEW (user_data);
+ view = NAUTILUS_FILES_VIEW (callback_data->view);
priv = nautilus_files_view_get_instance_private (view);
- selection = nautilus_files_view_get_selection_for_file_transfer (view);
-
- for (l = selection; l != NULL; l = l->next)
+ for (l = callback_data->selection; l != NULL; l = l->next)
{
source_files = g_list_prepend (source_files,
nautilus_file_get_location (l->data));
@@ -2323,7 +2327,6 @@ compress_dialog_controller_on_name_accepted (NautilusFileNameWidgetController *c
compress_done,
data);
- nautilus_file_list_free (selection);
g_list_free_full (source_files, g_object_unref);
g_clear_object (&priv->compress_controller);
}
@@ -2341,6 +2344,12 @@ compress_dialog_controller_on_cancelled (NautilusNewFolderDialogController *cont
g_clear_object (&priv->compress_controller);
}
+static void
+compress_callback_data_free (CompressCallbackData *data)
+{
+ nautilus_file_list_free (data->selection);
+ g_free (data);
+}
static void
nautilus_files_view_compress_dialog_new (NautilusFilesView *view)
@@ -2349,6 +2358,7 @@ nautilus_files_view_compress_dialog_new (NautilusFilesView *view)
NautilusFilesViewPrivate *priv;
g_autolist (NautilusFile) selection = NULL;
g_autofree char *common_prefix = NULL;
+ CompressCallbackData *data;
priv = nautilus_files_view_get_instance_private (view);
@@ -2386,10 +2396,17 @@ nautilus_files_view_compress_dialog_new (NautilusFilesView *view)
containing_directory,
common_prefix);
- g_signal_connect (priv->compress_controller,
- "name-accepted",
- (GCallback) compress_dialog_controller_on_name_accepted,
- view);
+ data = g_new0 (CompressCallbackData, 1);
+ data->view = view;
+ data->selection = nautilus_files_view_get_selection_for_file_transfer (view);
+
+ g_signal_connect_data (priv->compress_controller,
+ "name-accepted",
+ (GCallback) compress_dialog_controller_on_name_accepted,
+ data,
+ (GClosureNotify) compress_callback_data_free,
+ G_CONNECT_AFTER);
+
g_signal_connect (priv->compress_controller,
"cancelled",
(GCallback) compress_dialog_controller_on_cancelled,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]