summaryrefslogtreecommitdiff
path: root/trashapplet
diff options
context:
space:
mode:
authorzhuyaliang <zhuyaliang@[email protected]>2023-02-08 16:47:05 +0800
committerLuke from DC <[email protected]>2023-02-14 01:34:53 +0000
commitaf7a84176c33f3eb22cea5f94c45caa6bfb408b6 (patch)
tree9e0c6ea2fccd05a33c9ce1050c6d1557c6502ab2 /trashapplet
parent5e0c3bfa38b8b4ea3cfd1b6c674d125d46634f06 (diff)
downloadmate-applets-af7a84176c33f3eb22cea5f94c45caa6bfb408b6.tar.bz2
mate-applets-af7a84176c33f3eb22cea5f94c45caa6bfb408b6.tar.xz
trashapplet: Replace the deprecated function (g_io_scheduler...) and remove the compilation warning
Diffstat (limited to 'trashapplet')
-rw-r--r--trashapplet/src/trash-empty.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/trashapplet/src/trash-empty.c b/trashapplet/src/trash-empty.c
index 9ad61e5a..3a3bb6fa 100644
--- a/trashapplet/src/trash-empty.c
+++ b/trashapplet/src/trash-empty.c
@@ -114,20 +114,19 @@ trash_empty_update_dialog (gpointer user_data)
return FALSE;
}
-static gboolean
-trash_empty_done (gpointer user_data)
+static void
+trash_empty_done (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
gtk_widget_destroy (GTK_WIDGET (trash_empty_dialog));
g_assert (trash_empty_dialog == NULL);
-
- return FALSE;
}
/* =============== worker thread code begins here =============== */
static void
-trash_empty_maybe_schedule_update (GIOSchedulerJob *job,
- GFile *file,
+trash_empty_maybe_schedule_update (GFile *file,
gsize deleted)
{
if (!trash_empty_update_pending)
@@ -138,15 +137,12 @@ trash_empty_maybe_schedule_update (GIOSchedulerJob *job,
trash_empty_deleted_files = deleted;
trash_empty_update_pending = TRUE;
- g_io_scheduler_job_send_to_mainloop_async (job,
- trash_empty_update_dialog,
- NULL, NULL);
+ g_main_context_invoke (NULL, trash_empty_update_dialog, NULL);
}
}
static void
-trash_empty_delete_contents (GIOSchedulerJob *job,
- GCancellable *cancellable,
+trash_empty_delete_contents (GCancellable *cancellable,
GFile *file,
gboolean actually_delete,
gsize *deleted)
@@ -171,12 +167,12 @@ trash_empty_delete_contents (GIOSchedulerJob *job,
child = g_file_get_child (file, g_file_info_get_name (info));
if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
- trash_empty_delete_contents (job, cancellable, child,
+ trash_empty_delete_contents (cancellable, child,
actually_delete, deleted);
if (actually_delete)
{
- trash_empty_maybe_schedule_update (job, child, *deleted);
+ trash_empty_maybe_schedule_update (child, *deleted);
g_file_delete (child, cancellable, NULL);
}
@@ -193,10 +189,11 @@ trash_empty_delete_contents (GIOSchedulerJob *job,
}
}
-static gboolean
-trash_empty_job (GIOSchedulerJob *job,
- GCancellable *cancellable,
- gpointer user_data)
+static void
+trash_empty_job (GTask *task,
+ gpointer source_object,
+ gpointer user_data,
+ GCancellable *cancellable)
{
gsize deleted;
GFile *trash;
@@ -205,20 +202,16 @@ trash_empty_job (GIOSchedulerJob *job,
/* first do a dry run to count the number of files */
deleted = 0;
- trash_empty_delete_contents (job, cancellable, trash, FALSE, &deleted);
+ trash_empty_delete_contents (cancellable, trash, FALSE, &deleted);
trash_empty_total_files = deleted;
/* now do the real thing */
deleted = 0;
- trash_empty_delete_contents (job, cancellable, trash, TRUE, &deleted);
+ trash_empty_delete_contents (cancellable, trash, TRUE, &deleted);
/* done */
g_object_unref (trash);
- g_io_scheduler_job_send_to_mainloop_async (job,
- trash_empty_done,
- NULL, NULL);
-
- return FALSE;
+ g_task_return_boolean (task, TRUE);
}
/* ================ worker thread code ends here ================ */
@@ -234,6 +227,7 @@ trash_empty_start (GtkWidget *parent)
};
GCancellable *cancellable;
GtkBuilder *builder;
+ GTask *task;
gint i;
builder = gtk_builder_new_from_resource (GRESOURCE "trashapplet-empty-progress.ui");
@@ -264,7 +258,10 @@ trash_empty_start (GtkWidget *parent)
g_signal_connect_object (trash_empty_dialog, "response",
G_CALLBACK (g_cancellable_cancel),
cancellable, G_CONNECT_SWAPPED);
- g_io_scheduler_push_job (trash_empty_job, NULL, NULL, 0, cancellable);
+
+ task = g_task_new (parent, cancellable, trash_empty_done, NULL);
+ g_task_run_in_thread (task, trash_empty_job);
+ g_object_unref (task);
g_object_unref (cancellable);
gtk_window_set_screen (GTK_WINDOW (trash_empty_dialog),