diff options
author | Jonathan Tellier <jonathan.tellier@gmail.com> | 2009-08-26 01:18:56 +0800 |
---|---|---|
committer | jtellier <jonathan.tellier@collabora.co.uk> | 2009-08-27 21:03:38 +0800 |
commit | 5a464a08117785832583bdf720288502410952aa (patch) | |
tree | eed383bcd7e28724114579319a48c2aa545f1ce2 | |
parent | c8eb8757721031aba99238804896881f2182bd9e (diff) | |
download | gsoc2013-empathy-5a464a08117785832583bdf720288502410952aa.tar gsoc2013-empathy-5a464a08117785832583bdf720288502410952aa.tar.gz gsoc2013-empathy-5a464a08117785832583bdf720288502410952aa.tar.bz2 gsoc2013-empathy-5a464a08117785832583bdf720288502410952aa.tar.lz gsoc2013-empathy-5a464a08117785832583bdf720288502410952aa.tar.xz gsoc2013-empathy-5a464a08117785832583bdf720288502410952aa.tar.zst gsoc2013-empathy-5a464a08117785832583bdf720288502410952aa.zip |
- The account display gets updated in the account list and in the
account name label.
- By default, the account default display name is set to the login id.
-rw-r--r-- | src/empathy-accounts-dialog.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 6fa484924..8a3d35531 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -112,6 +112,11 @@ enum { PROP_PARENT = 1 }; +static void accounts_dialog_account_display_name_changed_cb ( + EmpathyAccount *account, + GParamSpec *pspec, + gpointer user_data); + static EmpathyAccountSettings * accounts_dialog_model_get_selected_settings ( EmpathyAccountsDialog *dialog); @@ -181,8 +186,16 @@ static void empathy_account_dialog_account_created_cb (EmpathyAccountWidget *widget_object, EmpathyAccountsDialog *dialog) { + const gchar *default_display_name; EmpathyAccountSettings *settings = accounts_dialog_model_get_selected_settings (dialog); + + /* Setting the display name to the login ID. */ + default_display_name = empathy_account_settings_get_string (settings, + "account"); + empathy_account_settings_set_display_name_async (settings, + default_display_name, NULL, NULL); + accounts_dialog_update_settings (dialog, settings); if (settings) @@ -572,6 +585,8 @@ accounts_dialog_delete_account_response_cb (GtkDialog *message_dialog, if (account != NULL) { + g_signal_handlers_disconnect_by_func (account, + accounts_dialog_account_display_name_changed_cb, account_dialog); empathy_account_remove_async (account, NULL, NULL); g_object_unref (account); } @@ -920,6 +935,37 @@ accounts_dialog_connection_changed_cb (EmpathyAccountManager *manager, } static void +accounts_dialog_account_display_name_changed_cb (EmpathyAccount *account, + GParamSpec *pspec, + gpointer user_data) +{ + const gchar *display_name; + GtkTreeIter iter; + GtkTreeModel *model; + EmpathyAccountSettings *settings; + EmpathyAccount *selected_account; + EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (user_data); + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + display_name = empathy_account_get_display_name (account); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); + settings = accounts_dialog_model_get_selected_settings (dialog); + selected_account = empathy_account_settings_get_account (settings); + + if (accounts_dialog_get_account_iter (dialog, account, &iter)) + { + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COL_NAME, display_name, + -1); + } + + if (selected_account == account) + accounts_dialog_update_name_label (dialog, display_name); + + g_object_unref (settings); +} + +static void accounts_dialog_add_account (EmpathyAccountsDialog *dialog, EmpathyAccount *account) { @@ -955,6 +1001,9 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog, TP_CONNECTION_STATUS_DISCONNECTED, dialog); + g_signal_connect (account, "notify::display-name", + G_CALLBACK (accounts_dialog_account_display_name_changed_cb), dialog); + g_object_unref (settings); } @@ -1007,8 +1056,12 @@ accounts_dialog_account_removed_cb (EmpathyAccountManager *manager, EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); if (accounts_dialog_get_account_iter (dialog, account, &iter)) - gtk_list_store_remove (GTK_LIST_STORE ( + { + g_signal_handlers_disconnect_by_func (account, + accounts_dialog_account_display_name_changed_cb, dialog); + gtk_list_store_remove (GTK_LIST_STORE ( gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview))), &iter); + } } static void |