summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2021-09-24 09:42:54 +0200
committerOndrej Holy <oholy@redhat.com>2021-09-24 09:34:56 +0000
commite525d441ac16b2c9d0b5541e3861520f17dc20cd (patch)
tree197466f2ac2c22fca745d642d1a121b5b3414bb7
parent332df8050d31dde2981f31e16385aa06aa57796e (diff)
downloadnautilus-e525d441ac16b2c9d0b5541e3861520f17dc20cd.tar.gz
file-operations: Do not offer skipping when extracting one file
In case of extraction failure, the "Skip" and "Cancel" actions are offered everytime, but skipping doesn't make sense when extracting one file only. Let's use the same approach as it is used also for other operations, which is based on total number of files and remaining files. Also the "Skip All" action will be offered as a side-effect of this change.
-rw-r--r--src/nautilus-file-operations.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index fb5168c2e..d9aaace36 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -210,6 +210,7 @@ typedef struct
guint64 archive_compressed_size;
guint64 total_compressed_size;
+ gint total_files;
NautilusExtractCallback done_callback;
gpointer done_callback_data;
@@ -8327,6 +8328,7 @@ extract_job_on_error (AutoarExtractor *extractor,
GFile *source_file;
GFile *destination;
gint response_id;
+ gint remaining_files;
g_autofree gchar *basename = NULL;
source_file = autoar_extractor_get_source_file (extractor);
@@ -8348,25 +8350,35 @@ extract_job_on_error (AutoarExtractor *extractor,
g_object_unref (destination);
}
+ if (extract_job->common.skip_all_error)
+ {
+ return;
+ }
+
basename = get_basename (source_file);
nautilus_progress_info_take_status (extract_job->common.progress,
g_strdup_printf (_("Error extracting “%s”"),
basename));
- response_id = run_warning ((CommonJob *) extract_job,
- g_strdup_printf (_("There was an error while extracting “%s”."),
- basename),
- g_strdup (error->message),
- NULL,
- FALSE,
- CANCEL,
- SKIP,
- NULL);
+ remaining_files = g_list_length (g_list_find_custom (extract_job->source_files,
+ source_file,
+ (GCompareFunc) g_file_equal)) - 1;
+ response_id = run_cancel_or_skip_warning ((CommonJob *) extract_job,
+ g_strdup_printf (_("There was an error while extracting “%s”."),
+ basename),
+ g_strdup (error->message),
+ NULL,
+ extract_job->total_files,
+ remaining_files);
if (response_id == 0 || response_id == GTK_RESPONSE_DELETE_EVENT)
{
abort_job ((CommonJob *) extract_job);
}
+ else if (response_id == 1)
+ {
+ extract_job->common.skip_all_error = TRUE;
+ }
}
static void
@@ -8598,7 +8610,6 @@ extract_task_thread_func (GTask *task,
{
ExtractJob *extract_job = task_data;
GList *l;
- gint total_files;
g_autofree guint64 *archive_compressed_sizes = NULL;
gint i;
@@ -8609,9 +8620,10 @@ extract_task_thread_func (GTask *task,
nautilus_progress_info_set_details (extract_job->common.progress,
_("Preparing to extract"));
- total_files = g_list_length (extract_job->source_files);
+ extract_job->total_files = g_list_length (extract_job->source_files);
- archive_compressed_sizes = g_malloc0_n (total_files, sizeof (guint64));
+ archive_compressed_sizes = g_malloc0_n (extract_job->total_files,
+ sizeof (guint64));
extract_job->total_compressed_size = 0;
for (l = extract_job->source_files, i = 0;
@@ -8682,7 +8694,7 @@ extract_task_thread_func (GTask *task,
if (!job_aborted ((CommonJob *) extract_job))
{
- report_extract_final_progress (extract_job, total_files);
+ report_extract_final_progress (extract_job, extract_job->total_files);
}
if (extract_job->common.undo_info)