aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-01-12 19:19:30 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-01-12 19:26:27 +0800
commit4fcf2a8de21bc613d9cbaafd59fc93c854905a90 (patch)
treecd8ec2c39f014a304a07c934d2e2230addd10fe3 /src
parent66e1966ee3b3303968997f229f62ada8d7b519ba (diff)
downloadgsoc2013-empathy-4fcf2a8de21bc613d9cbaafd59fc93c854905a90.tar
gsoc2013-empathy-4fcf2a8de21bc613d9cbaafd59fc93c854905a90.tar.gz
gsoc2013-empathy-4fcf2a8de21bc613d9cbaafd59fc93c854905a90.tar.bz2
gsoc2013-empathy-4fcf2a8de21bc613d9cbaafd59fc93c854905a90.tar.lz
gsoc2013-empathy-4fcf2a8de21bc613d9cbaafd59fc93c854905a90.tar.xz
gsoc2013-empathy-4fcf2a8de21bc613d9cbaafd59fc93c854905a90.tar.zst
gsoc2013-empathy-4fcf2a8de21bc613d9cbaafd59fc93c854905a90.zip
roster-window: factor out add_account()
Also fix a stupid bug where roster_window_account_removed_cb() was called on a valid account in roster_window_account_validity_changed_cb(). https://bugzilla.gnome.org/show_bug.cgi?id=667743
Diffstat (limited to 'src')
-rw-r--r--src/empathy-roster-window.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/empathy-roster-window.c b/src/empathy-roster-window.c
index 629363a06..7fc7f9a6b 100644
--- a/src/empathy-roster-window.c
+++ b/src/empathy-roster-window.c
@@ -2053,30 +2053,37 @@ roster_window_account_removed_cb (TpAccountManager *manager,
}
static void
+add_account (EmpathyRosterWindow *self,
+ TpAccount *account)
+{
+ gulong handler_id;
+
+ handler_id = GPOINTER_TO_UINT (g_hash_table_lookup (
+ self->priv->status_changed_handlers, account));
+
+ /* connect signal only if it was not connected yet */
+ if (handler_id != 0)
+ return;
+
+ handler_id = g_signal_connect (account, "status-changed",
+ G_CALLBACK (roster_window_connection_changed_cb), self);
+
+ g_hash_table_insert (self->priv->status_changed_handlers,
+ account, GUINT_TO_POINTER (handler_id));
+
+ roster_window_setup_balance (self, account);
+}
+
+static void
roster_window_account_validity_changed_cb (TpAccountManager *manager,
TpAccount *account,
gboolean valid,
EmpathyRosterWindow *self)
{
if (valid)
- {
- gulong handler_id;
- handler_id = GPOINTER_TO_UINT (g_hash_table_lookup (
- self->priv->status_changed_handlers, account));
-
- /* connect signal only if it was not connected yet */
- if (handler_id == 0)
- {
- handler_id = g_signal_connect (account,
- "status-changed",
- G_CALLBACK (roster_window_connection_changed_cb),
- self);
- g_hash_table_insert (self->priv->status_changed_handlers,
- account, GUINT_TO_POINTER (handler_id));
- }
- }
-
- roster_window_account_removed_cb (manager, account, self);
+ add_account (self, account);
+ else
+ roster_window_account_removed_cb (manager, account, self);
}
static void
@@ -2137,15 +2144,8 @@ account_manager_prepared_cb (GObject *source_object,
for (j = accounts; j != NULL; j = j->next)
{
TpAccount *account = TP_ACCOUNT (j->data);
- gulong handler_id;
- handler_id = g_signal_connect (account, "status-changed",
- G_CALLBACK (roster_window_connection_changed_cb),
- self);
- g_hash_table_insert (self->priv->status_changed_handlers,
- account, GUINT_TO_POINTER (handler_id));
-
- roster_window_setup_balance (self, account);
+ add_account (self, account);
}
g_signal_connect (manager, "account-validity-changed",