[gnome-control-center/wip/msanchez/printers-clean-heads: 27/28] Migrate the remaining bits of PpMaintenanceCommand to GTask
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/msanchez/printers-clean-heads: 27/28] Migrate the remaining bits of PpMaintenanceCommand to GTask
- Date: Sat, 9 Jul 2016 11:58:28 +0000 (UTC)
commit 25020661aa27a129056c2225a77c99c6dc326469
Author: Mario Sanchez Prada <mario endlessm com>
Date: Sat Jul 9 12:41:48 2016 +0100
Migrate the remaining bits of PpMaintenanceCommand to GTask
They were still using the deprecated GSimpleAsyncResult and throwing
a lot of warnings when building.
panels/printers/pp-maintenance-command.c | 43 ++++++++++++-----------------
1 files changed, 18 insertions(+), 25 deletions(-)
---
diff --git a/panels/printers/pp-maintenance-command.c b/panels/printers/pp-maintenance-command.c
index d03482e..2b0b864 100644
--- a/panels/printers/pp-maintenance-command.c
+++ b/panels/printers/pp-maintenance-command.c
@@ -181,11 +181,12 @@ static gboolean _pp_maintenance_command_is_supported (const gchar *printer_name,
const gchar *command);
static void
-_pp_maintenance_command_execute_thread (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
+_pp_maintenance_command_execute_thread (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
+ GCancellable *cancellable)
{
- PpMaintenanceCommand *command = (PpMaintenanceCommand *) object;
+ PpMaintenanceCommand *command = PP_MAINTENANCE_COMMAND (source_object);
PpMaintenanceCommandPrivate *priv = command->priv;
gboolean success = FALSE;
GError *error = NULL;
@@ -245,13 +246,13 @@ _pp_maintenance_command_execute_thread (GSimpleAsyncResult *res,
if (!success)
{
- g_simple_async_result_set_error (res,
- G_IO_ERROR,
- G_IO_ERROR_FAILED,
- "Execution of maintenance command failed.");
+ g_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ "Execution of maintenance command failed.");
}
- g_simple_async_result_set_op_res_gboolean (res, success);
+ g_task_return_boolean (task, success);
}
void
@@ -260,31 +261,23 @@ pp_maintenance_command_execute_async (PpMaintenanceCommand *command,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GSimpleAsyncResult *res;
-
- res = g_simple_async_result_new (G_OBJECT (command), callback, user_data,
pp_maintenance_command_execute_async);
+ GTask *task;
- g_simple_async_result_set_check_cancellable (res, cancellable);
- g_simple_async_result_run_in_thread (res, _pp_maintenance_command_execute_thread, 0, cancellable);
+ task = g_task_new (command, cancellable, callback, user_data);
+ g_task_set_check_cancellable (task, TRUE);
+ g_task_run_in_thread (task, _pp_maintenance_command_execute_thread);
- g_object_unref (res);
+ g_object_unref (task);
}
gboolean
pp_maintenance_command_execute_finish (PpMaintenanceCommand *command,
- GAsyncResult *res,
+ GAsyncResult *result,
GError **error)
{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
-
- g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == pp_maintenance_command_execute_async);
-
- if (g_simple_async_result_propagate_error (simple, error))
- {
- return FALSE;
- }
+ g_return_val_if_fail (g_task_is_valid (result, command), FALSE);
- return g_simple_async_result_get_op_res_gboolean (simple);
+ return g_task_propagate_boolean (G_TASK (result), error);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]