[nautilus/wip/gbsneto/code-cleanup] project: use GTask instead of GSimpleAsyncResult



commit 72bc6990861e8889281009696a87588cb0cd88ae
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Jun 17 02:26:18 2015 -0300

    project: use GTask instead of GSimpleAsyncResult

 src/nautilus-bookmark-list.c |   38 ++++++++++++++++++--------------------
 1 files changed, 18 insertions(+), 20 deletions(-)
---
diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c
index 3a59d29..97ce836 100644
--- a/src/nautilus-bookmark-list.c
+++ b/src/nautilus-bookmark-list.c
@@ -442,7 +442,7 @@ load_callback (GObject *source,
        char **lines;
        int i;
 
-       contents = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
+       contents = g_async_result_get_user_data (res);
 
        if (contents == NULL) {
                op_processed_cb (self);
@@ -476,8 +476,9 @@ load_callback (GObject *source,
 }
 
 static void
-load_io_thread (GSimpleAsyncResult *result,
-               GObject *object,
+load_io_thread (GTask *task,
+               gpointer *object,
+                gpointer *task_data,
                GCancellable *cancellable)
 {
        GFile *file;
@@ -499,23 +500,21 @@ load_io_thread (GSimpleAsyncResult *result,
                }
                g_error_free (error);
        } else {
-               g_simple_async_result_set_op_res_gpointer (result, contents, g_free);
+               g_task_set_task_data (task, contents, g_free);
        }
 }
 
 static void
 load_file_async (NautilusBookmarkList *self)
 {
-       GSimpleAsyncResult *result;
+       GTask *task;
 
        /* Wipe out old list. */
        clear (self);
 
-       result = g_simple_async_result_new (G_OBJECT (self), 
-                                           load_callback, NULL, NULL);
-       g_simple_async_result_run_in_thread (result, load_io_thread,
-                                            G_PRIORITY_DEFAULT, NULL);
-       g_object_unref (result);
+       task = g_task_new (G_OBJECT (self), NULL, load_callback, NULL);
+       g_task_run_in_thread (task, (GTaskThreadFunc) load_io_thread);
+       g_object_unref (task);
 }
 
 static void
@@ -539,8 +538,9 @@ save_callback (GObject *source,
 }
 
 static void
-save_io_thread (GSimpleAsyncResult *result,
-               GObject *object,
+save_io_thread (GTask *task,
+               gpointer *source_object,
+                gpointer *task_data,
                GCancellable *cancellable)
 {
        gchar *contents, *path;
@@ -554,7 +554,7 @@ save_io_thread (GSimpleAsyncResult *result,
        g_free (path);
        g_object_unref (parent);
 
-       contents = g_simple_async_result_get_op_res_gpointer (result);
+       contents = (gchar*) task_data;
        g_file_replace_contents (file, 
                                 contents, strlen (contents),
                                 NULL, FALSE, 0, NULL,
@@ -572,7 +572,7 @@ save_io_thread (GSimpleAsyncResult *result,
 static void
 save_file_async (NautilusBookmarkList *self)
 {
-       GSimpleAsyncResult *result;
+       GTask *task;
        GString *bookmark_string;
        gchar *contents;
        GList *l;
@@ -607,14 +607,12 @@ save_file_async (NautilusBookmarkList *self)
                }
        }
 
-       result = g_simple_async_result_new (G_OBJECT (self),
-                                           save_callback, NULL, NULL);
+       task = g_task_new (G_OBJECT (self), NULL, (GAsyncReadyCallback) save_callback, NULL);
        contents = g_string_free (bookmark_string, FALSE);
-       g_simple_async_result_set_op_res_gpointer (result, contents, g_free);
+       g_task_set_task_data (task, contents, g_free);
 
-       g_simple_async_result_run_in_thread (result, save_io_thread,
-                                            G_PRIORITY_DEFAULT, NULL);
-       g_object_unref (result);
+       g_task_run_in_thread (task, (GTaskThreadFunc) save_io_thread);
+       g_object_unref (task);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]