From f17b4a2962cdc74a3fc2e410b5885ae96e3ed4e4 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 15 Mar 2012 16:02:27 +0100 Subject: reload the account widget when connection is (dis)connected https://bugzilla.gnome.org/show_bug.cgi?id=671035 --- src/empathy-accounts-dialog.c | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src/empathy-accounts-dialog.c') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 0bcf0ed21..2cc248251 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -1790,6 +1790,15 @@ finally: return FALSE; } +static void +reload_account_widget (EmpathyAccountsDialog *self) +{ + EmpathyAccountSettings *settings; + + settings = accounts_dialog_model_get_selected_settings (self); + accounts_dialog_update_settings (self, settings); +} + static void accounts_dialog_connection_changed_cb (TpAccount *account, guint old_status, @@ -1903,6 +1912,40 @@ accounts_dialog_account_display_name_changed_cb (TpAccount *account, g_object_unref (settings); } +static void +conn_prepare_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + EmpathyAccountsDialog *self = user_data; + + reload_account_widget (self); +} + +static void +accounts_dialog_notify_connection_cb (TpAccount *account, + GParamSpec *spec, + EmpathyAccountsDialog *self) +{ + TpConnection *conn; + if (!account_is_selected (self, account)) + return; + + conn = tp_account_get_connection (account); + if (conn == NULL) + { + reload_account_widget (self); + } + else + { + /* Wait for this feature so TpConnection will have fetch the + * self handle */ + GQuark features[] = { TP_CONNECTION_FEATURE_CONNECTED, 0 }; + + tp_proxy_prepare_async (conn, features, conn_prepare_cb, self); + } +} + static void accounts_dialog_add_account (EmpathyAccountsDialog *dialog, TpAccount *account) @@ -1968,6 +2011,8 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog, G_CALLBACK (accounts_dialog_connection_changed_cb), dialog, 0); tp_g_signal_connect_object (account, "presence-changed", G_CALLBACK (accounts_dialog_presence_changed_cb), dialog, 0); + tp_g_signal_connect_object (account, "notify::connection", + G_CALLBACK (accounts_dialog_notify_connection_cb), dialog, 0); g_object_unref (settings); } -- cgit v1.2.3