diff options
author | Jonny Lamb <jonnylamb@gnome.org> | 2010-12-10 20:02:17 +0800 |
---|---|---|
committer | Jonny Lamb <jonnylamb@gnome.org> | 2011-01-26 21:36:40 +0800 |
commit | 09dfb1223c619498c4ef29567d34ba43b8c455b9 (patch) | |
tree | 5688f83a3720cf96d3e5f0cf2293d822b113851a | |
parent | 41433901d4d8aa182895a71c868c38dc16173573 (diff) | |
download | gsoc2013-empathy-09dfb1223c619498c4ef29567d34ba43b8c455b9.tar gsoc2013-empathy-09dfb1223c619498c4ef29567d34ba43b8c455b9.tar.gz gsoc2013-empathy-09dfb1223c619498c4ef29567d34ba43b8c455b9.tar.bz2 gsoc2013-empathy-09dfb1223c619498c4ef29567d34ba43b8c455b9.tar.lz gsoc2013-empathy-09dfb1223c619498c4ef29567d34ba43b8c455b9.tar.xz gsoc2013-empathy-09dfb1223c619498c4ef29567d34ba43b8c455b9.tar.zst gsoc2013-empathy-09dfb1223c619498c4ef29567d34ba43b8c455b9.zip |
account-settings: don't block notify::ready on getting a password
The account widget acts a little more synchronously, so we can't wait
for the keyring to give us the password. We can signal later about it
though.
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
-rw-r--r-- | libempathy-gtk/empathy-account-widget.c | 36 | ||||
-rw-r--r-- | libempathy/empathy-account-settings.c | 25 |
2 files changed, 55 insertions, 6 deletions
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c index 1cc0f9f82..819ac4e07 100644 --- a/libempathy-gtk/empathy-account-widget.c +++ b/libempathy-gtk/empathy-account-widget.c @@ -88,6 +88,7 @@ typedef struct { GtkWidget *param_account_widget; GtkWidget *param_password_widget; + gboolean automatic_change; GtkWidget *remember_password_widget; /* Used only for IRC accounts */ @@ -188,6 +189,11 @@ static void account_widget_entry_changed_cb (GtkEditable *entry, EmpathyAccountWidget *self) { + EmpathyAccountWidgetPriv *priv = GET_PRIV (self); + + if (priv->automatic_change) + return; + account_widget_entry_changed_common (self, GTK_ENTRY (entry), FALSE); empathy_account_widget_changed (self); } @@ -1731,6 +1737,30 @@ remember_password_toggled_cb (GtkToggleButton *button, } static void +account_settings_password_retrieved_cb (GObject *object, + gpointer user_data) +{ + EmpathyAccountWidget *self = user_data; + EmpathyAccountWidgetPriv *priv = GET_PRIV (self); + const gchar *password = empathy_account_settings_get_string ( + priv->settings, "password"); + + if (password != NULL) + { + /* We have to do this so that when we call gtk_entry_set_text, + * the ::changed callback doesn't think the user made the + * change. */ + priv->automatic_change = TRUE; + gtk_entry_set_text (GTK_ENTRY (priv->param_password_widget), password); + priv->automatic_change = FALSE; + } + + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (priv->remember_password_widget), + !EMP_STR_EMPTY (password)); +} + +static void do_constructed (GObject *obj) { EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj); @@ -1811,6 +1841,12 @@ do_constructed (GObject *obj) GTK_TOGGLE_BUTTON (priv->remember_password_widget), !EMP_STR_EMPTY (empathy_account_settings_get_string ( priv->settings, "password"))); + + /* The password might not have been retrieved from the + * keyring yet. We should update the remember password + * toggle button and the password entry when/if it is. */ + g_signal_connect (priv->settings, "password-retrieved", + G_CALLBACK (account_settings_password_retrieved_cb), self); } g_signal_connect (priv->remember_password_widget, "toggled", diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c index 8a92dfd96..d7a202eed 100644 --- a/libempathy/empathy-account-settings.c +++ b/libempathy/empathy-account-settings.c @@ -49,6 +49,13 @@ enum { PROP_READY }; +enum { + PASSWORD_RETRIEVED = 1, + LAST_SIGNAL +}; + +static gulong signals[LAST_SIGNAL] = { 0, }; + /* private structure */ typedef struct _EmpathyAccountSettingsPriv EmpathyAccountSettingsPriv; @@ -291,6 +298,13 @@ empathy_account_settings_class_init ( "Whether this account is ready to be used", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE)); + + signals[PASSWORD_RETRIEVED] = + g_signal_new ("password-retrieved", + G_TYPE_FROM_CLASS (empathy_account_settings_class), + G_SIGNAL_RUN_LAST, 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } static void @@ -417,9 +431,7 @@ empathy_account_settings_get_password_cb (GObject *source, priv->password = g_strdup (password); priv->password_original = g_strdup (password); - priv->password_retrieved = TRUE; - - empathy_account_settings_check_readyness (self); + g_signal_emit (self, signals[PASSWORD_RETRIEVED], 0); } static void @@ -514,14 +526,15 @@ empathy_account_settings_check_readyness (EmpathyAccountSettings *self) /* priv->account won't be a proper account if it's the account * assistant showing this widget. */ - if (priv->supports_sasl && !priv->password_retrieved - && !priv->password_requested && priv->account != NULL) + if (priv->supports_sasl && !priv->password_requested + && priv->account != NULL) { priv->password_requested = TRUE; + /* Make this call but don't block on its readiness. We'll signal + * if it's updated later with ::password-retrieved. */ empathy_keyring_get_password_async (priv->account, empathy_account_settings_get_password_cb, self); - return; } priv->ready = TRUE; |