[nautilus] file-operations: Remove blocking dialog for emptying trash
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] file-operations: Remove blocking dialog for emptying trash
- Date: Tue, 28 Dec 2021 23:48:37 +0000 (UTC)
commit ed23b17a50da5d86339cc5930b62814eda1416ff
Author: Matthew Jakeman <mjakeman26 outlook co nz>
Date: Mon Dec 20 09:35:40 2021 +1300
file-operations: Remove blocking dialog for emptying trash
Stop using the blocking dialog function `gtk_dialog_run`
when the user is prompted to empty the trash during unmount.
Part of #1992
src/nautilus-file-operations.c | 80 +++++++++++++++++++++++-------------------
1 file changed, 44 insertions(+), 36 deletions(-)
---
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index 73893d7f4..877275035 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -3011,11 +3011,9 @@ has_trash_files (GMount *mount)
return res;
}
-
-static gint
-prompt_empty_trash (GtkWindow *parent_window)
+static GtkWidget *
+create_empty_trash_prompt (GtkWindow *parent_window)
{
- gint result;
GtkWidget *dialog;
dialog = gtk_message_dialog_new (parent_window, GTK_DIALOG_MODAL,
@@ -3035,9 +3033,7 @@ prompt_empty_trash (GtkWindow *parent_window)
gtk_window_set_title (GTK_WINDOW (dialog), "");
atk_object_set_role (gtk_widget_get_accessible (dialog), ATK_ROLE_ALERT);
- result = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- return result;
+ return dialog;
}
static void
@@ -3048,6 +3044,42 @@ empty_trash_for_unmount_done (gboolean success,
do_unmount (data);
}
+static void
+empty_trash_prompt_cb (GtkDialog *dialog,
+ gint response_id,
+ gpointer user_data)
+{
+ UnmountData *data = user_data;
+
+ if (response_id == GTK_RESPONSE_ACCEPT)
+ {
+ GTask *task;
+ EmptyTrashJob *job;
+
+ job = op_job_new (EmptyTrashJob, data->parent_window, NULL);
+ job->should_confirm = FALSE;
+ job->trash_dirs = get_trash_dirs_for_mount (data->mount);
+ job->done_callback = empty_trash_for_unmount_done;
+ job->done_callback_data = data;
+
+ task = g_task_new (NULL, NULL, empty_trash_task_done, job);
+ g_task_set_task_data (task, job, NULL);
+ g_task_run_in_thread (task, empty_trash_thread_func);
+ g_object_unref (task);
+ }
+ else if (response_id == GTK_RESPONSE_CANCEL)
+ {
+ if (data->callback)
+ {
+ data->callback (data->callback_data);
+ }
+
+ unmount_data_free (data);
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
void
nautilus_file_operations_unmount_mount_full (GtkWindow *parent_window,
GMount *mount,
@@ -3058,7 +3090,6 @@ nautilus_file_operations_unmount_mount_full (GtkWindow *parent_win
gpointer callback_data)
{
UnmountData *data;
- int response;
data = g_new0 (UnmountData, 1);
data->callback = callback;
@@ -3078,35 +3109,12 @@ nautilus_file_operations_unmount_mount_full (GtkWindow *parent_win
if (check_trash && has_trash_files (mount))
{
- response = prompt_empty_trash (parent_window);
-
- if (response == GTK_RESPONSE_ACCEPT)
- {
- GTask *task;
- EmptyTrashJob *job;
-
- job = op_job_new (EmptyTrashJob, parent_window, NULL);
- job->should_confirm = FALSE;
- job->trash_dirs = get_trash_dirs_for_mount (mount);
- job->done_callback = empty_trash_for_unmount_done;
- job->done_callback_data = data;
-
- task = g_task_new (NULL, NULL, empty_trash_task_done, job);
- g_task_set_task_data (task, job, NULL);
- g_task_run_in_thread (task, empty_trash_thread_func);
- g_object_unref (task);
- return;
- }
- else if (response == GTK_RESPONSE_CANCEL)
- {
- if (callback)
- {
- callback (callback_data);
- }
+ GtkWidget *dialog;
+ dialog = create_empty_trash_prompt (parent_window);
- unmount_data_free (data);
- return;
- }
+ g_signal_connect (dialog, "response", G_CALLBACK (empty_trash_prompt_cb), data);
+ gtk_widget_show_all (dialog);
+ return;
}
do_unmount (data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]