aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2009-09-18 06:43:00 +0800
committerJonny Lamb <jonny.lamb@collabora.co.uk>2009-09-18 06:55:12 +0800
commit362089ad2d09b2992453e567c6c39fb4bb356dbc (patch)
tree31e7fb0fef288f1ce8fc2cfaf267b34963f9cddb /libempathy
parenteba6377a41b2b4780850465f61a07d3030693269 (diff)
downloadgsoc2013-empathy-362089ad2d09b2992453e567c6c39fb4bb356dbc.tar
gsoc2013-empathy-362089ad2d09b2992453e567c6c39fb4bb356dbc.tar.gz
gsoc2013-empathy-362089ad2d09b2992453e567c6c39fb4bb356dbc.tar.bz2
gsoc2013-empathy-362089ad2d09b2992453e567c6c39fb4bb356dbc.tar.lz
gsoc2013-empathy-362089ad2d09b2992453e567c6c39fb4bb356dbc.tar.xz
gsoc2013-empathy-362089ad2d09b2992453e567c6c39fb4bb356dbc.tar.zst
gsoc2013-empathy-362089ad2d09b2992453e567c6c39fb4bb356dbc.zip
idle: wait for the account manager to be ready before setting initial state
Also, if we can get the global presence from the account manager straight away (in _init), then don't bother signalling the change. Otherwise, do signal the initial setting so things like the presence chooser and status icon will be updated with the initial presence. Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-idle.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c
index b8c7784d7..64ec37001 100644
--- a/libempathy/empathy-idle.c
+++ b/libempathy/empathy-idle.c
@@ -410,6 +410,27 @@ empathy_idle_class_init (EmpathyIdleClass *klass)
}
static void
+account_manager_ready_cb (EmpathyAccountManager *account_manager,
+ GParamSpec *pspec,
+ EmpathyIdle *idle)
+{
+ EmpathyIdlePriv *priv;
+ TpConnectionPresenceType state;
+ gchar *status, *status_message;
+
+ priv = GET_PRIV (idle);
+
+ state = empathy_account_manager_get_global_presence (priv->manager,
+ &status, &status_message);
+
+ idle_presence_changed_cb (account_manager, state, status,
+ status_message, idle);
+
+ g_free (status);
+ g_free (status_message);
+}
+
+static void
empathy_idle_init (EmpathyIdle *idle)
{
EmpathyIdlePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (idle,
@@ -419,8 +440,14 @@ empathy_idle_init (EmpathyIdle *idle)
priv->is_idle = FALSE;
priv->manager = empathy_account_manager_dup_singleton ();
- priv->state = empathy_account_manager_get_global_presence (priv->manager,
- NULL, &priv->status);
+
+ if (empathy_account_manager_is_ready (priv->manager)) {
+ priv->state = empathy_account_manager_get_global_presence (priv->manager,
+ NULL, &priv->status);
+ } else {
+ g_signal_connect (priv->manager, "notify::ready",
+ G_CALLBACK (account_manager_ready_cb), idle);
+ }
g_signal_connect (priv->manager, "global-presence-changed",