[gnome-builder/wip/libide] gobject: add basic async/finish snippets



commit fc6e6fc245dad6c5505d108715cb6cdd339409b6
Author: Christian Hergert <christian hergert me>
Date:   Fri Feb 27 11:47:07 2015 -0800

    gobject: add basic async/finish snippets

 data/snippets/gobject.snippets |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/data/snippets/gobject.snippets b/data/snippets/gobject.snippets
index c72c098..ed48b40 100644
--- a/data/snippets/gobject.snippets
+++ b/data/snippets/gobject.snippets
@@ -188,3 +188,34 @@ snippet gsignal
                              ${6:g_cclosure_marshal_generic},
                              ${7:G_TYPE_NONE},
                              ${8:0});
+snippet async
+- scope c
+       void
+       ${$2|functify}_${1:do_something}_async (${2:$filename|stripsuffix|camelize} *self,
+       ${$2|space} ${$1|space}          GCancellable *cancellable,
+       ${$2|space} ${$1|space}          GAsyncReadyCallback callback,
+       ${$2|space} ${$1|space}          gpointer user_data)
+       {
+               g_autoptr(GTask) task = NULL;
+
+               g_return_if_fail 
(${$filename|stripsuffix|functify|namespace|upper}_IS_${$filename|stripsuffix|class|functify|upper} (self));
+               g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+               task = g_task_new (self, cancellable, callback, user_data);
+
+               $0
+       }
+snippet finish
+- scope c
+       gboolean
+       ${$2|functify}_${1:do_something}_finish (${2:$filename|stripsuffix|camelize} *self,
+       ${$2|space} ${$1|space}           GAsyncResult *result,
+       ${$2|space} ${$1|space}           GError **error)
+       {
+               GTask *task = (GTask *)result;
+
+               g_return_val_if_fail 
(${$filename|stripsuffix|functify|namespace|upper}_IS_${$filename|stripsuffix|class|functify|upper} (self), 
${3:FALSE});
+               g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+               return g_task_propagate_${4:boolean} (task, error);
+       }


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