aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-04-20 16:23:05 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-06-09 18:37:55 +0800
commit8d3f7406c2055e4483cdc9639f8463e48b521621 (patch)
tree11e4c12c4b90bdaeea3222435f936f558b9aed48
parent7a393000d1dd55dc60345f0b2bb51b44215d9607 (diff)
downloadgsoc2013-empathy-8d3f7406c2055e4483cdc9639f8463e48b521621.tar
gsoc2013-empathy-8d3f7406c2055e4483cdc9639f8463e48b521621.tar.gz
gsoc2013-empathy-8d3f7406c2055e4483cdc9639f8463e48b521621.tar.bz2
gsoc2013-empathy-8d3f7406c2055e4483cdc9639f8463e48b521621.tar.lz
gsoc2013-empathy-8d3f7406c2055e4483cdc9639f8463e48b521621.tar.xz
gsoc2013-empathy-8d3f7406c2055e4483cdc9639f8463e48b521621.tar.zst
gsoc2013-empathy-8d3f7406c2055e4483cdc9639f8463e48b521621.zip
TplActionChain: add _tpl_action_chain_start()
-rw-r--r--libempathy/action-chain-internal.h3
-rw-r--r--libempathy/action-chain.c18
2 files changed, 20 insertions, 1 deletions
diff --git a/libempathy/action-chain-internal.h b/libempathy/action-chain-internal.h
index 674cc2b06..d2395d172 100644
--- a/libempathy/action-chain-internal.h
+++ b/libempathy/action-chain-internal.h
@@ -27,6 +27,7 @@
typedef struct {
GQueue *chain;
GSimpleAsyncResult *simple;
+ gboolean running;
} TplActionChain;
TplActionChain *_tpl_action_chain_new_async (GObject *obj,
@@ -38,8 +39,10 @@ void _tpl_action_chain_append (TplActionChain *self, TplPendingAction func,
gpointer user_data);
void _tpl_action_chain_prepend (TplActionChain *self, TplPendingAction func,
gpointer user_data);
+void _tpl_action_chain_start (TplActionChain *self);
void _tpl_action_chain_continue (TplActionChain *self);
void _tpl_action_chain_terminate (TplActionChain *self, const GError *error);
+
gpointer _tpl_action_chain_get_object (TplActionChain *self);
gboolean _tpl_action_chain_new_finish (GObject *source,
GAsyncResult *result, GError **error);
diff --git a/libempathy/action-chain.c b/libempathy/action-chain.c
index df792e548..30217ddc5 100644
--- a/libempathy/action-chain.c
+++ b/libempathy/action-chain.c
@@ -104,18 +104,34 @@ _tpl_action_chain_append (TplActionChain *self,
g_queue_push_tail (self->chain, l);
}
+void
+_tpl_action_chain_start (TplActionChain *self)
+{
+ g_return_if_fail (!g_queue_is_empty (self->chain));
+
+ if (self->running)
+ return;
+
+ _tpl_action_chain_continue (self);
+}
void
_tpl_action_chain_continue (TplActionChain *self)
{
if (g_queue_is_empty (self->chain))
- g_simple_async_result_complete (self->simple);
+ {
+ self->running = FALSE;
+ g_simple_async_result_complete (self->simple);
+ }
else
{
TplActionLink *l = g_queue_pop_head (self->chain);
+ self->running = TRUE;
l->action (self, l->user_data);
link_free (l);
+ if (g_queue_is_empty (self->chain))
+ self->running = FALSE;
}
}