Mercurial > pidgin.yaz
diff finch/gntaccount.c @ 30909:25e200cb3532
propagate from branch 'im.pidgin.pidgin' (head dca20e09164518b0f7a773edd7e9649f41d8873d)
to branch 'im.pidgin.cpw.malu.xmpp.google_refactor' (head 7823c556f2d1bbca43f5ef9f0fea30cabc5d313f)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Tue, 31 Aug 2010 18:28:10 +0000 |
parents | 014dbe36b722 |
children | a8cc50c2279f |
line wrap: on
line diff
--- a/finch/gntaccount.c Fri Apr 09 22:14:51 2010 +0000 +++ b/finch/gntaccount.c Tue Aug 31 18:28:10 2010 +0000 @@ -125,7 +125,8 @@ if (value == NULL || *value == '\0') { - purple_notify_error(NULL, _("Error"), _("Account was not added"), + purple_notify_error(NULL, _("Error"), + dialog->account ? _("Account was not modified") : _("Account was not added"), _("Username of an account must be non-empty.")); return; } @@ -160,8 +161,28 @@ account = dialog->account; /* Protocol */ - purple_account_set_protocol_id(account, purple_plugin_get_id(plugin)); - purple_account_set_username(account, username->str); + if (purple_account_is_disconnected(account)) { + purple_account_set_protocol_id(account, purple_plugin_get_id(plugin)); + purple_account_set_username(account, username->str); + } else { + const char *old = purple_account_get_protocol_id(account); + char *oldprpl; + if (strcmp(old, purple_plugin_get_id(plugin))) { + purple_notify_error(NULL, _("Error"), _("Account was not modified"), + _("The account's protocol cannot be changed while it is connected to the server.")); + return; + } + + oldprpl = g_strdup(purple_normalize(account, purple_account_get_username(account))); + if (g_utf8_collate(oldprpl, purple_normalize(account, username->str))) { + purple_notify_error(NULL, _("Error"), _("Account was not modified"), + _("The account's username cannot be changed while it is connected to the server.")); + g_free(oldprpl); + return; + } + g_free(oldprpl); + purple_account_set_username(account, username->str); + } } g_string_free(username, TRUE); @@ -215,7 +236,8 @@ } else if (type == PURPLE_PREF_STRING_LIST) { - /* TODO: */ + gchar *value = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(entry)); + purple_account_set_string(account, setting, value); } else { @@ -245,6 +267,17 @@ } } + /* In case of a new account, the 'Accounts' window is updated from the account-added + * callback. In case of changes in an existing account, we need to explicitly do it + * here. + */ + if (dialog->account != NULL && accounts.window) { + gnt_tree_change_text(GNT_TREE(accounts.tree), dialog->account, + 0, purple_account_get_username(dialog->account)); + gnt_tree_change_text(GNT_TREE(accounts.tree), dialog->account, + 1, purple_account_get_protocol_name(dialog->account)); + } + gnt_widget_destroy(dialog->window); } @@ -398,8 +431,26 @@ if (type == PURPLE_PREF_STRING_LIST) { - /* TODO: Use a combobox */ - /* Don't forget to append the widget to prpl_entries */ + GntWidget *combo = gnt_combo_box_new(); + GList *opt_iter = purple_account_option_get_list(option); + const char *dv = purple_account_option_get_default_list_value(option); + const char *active = dv; + + if (account) + active = purple_account_get_string(account, + purple_account_option_get_setting(option), dv); + + gnt_box_add_widget(GNT_BOX(box), combo); + dialog->prpl_entries = g_list_append(dialog->prpl_entries, combo); + + for ( ; opt_iter; opt_iter = opt_iter->next) + { + PurpleKeyValuePair *kvp = opt_iter->data; + gnt_combo_box_add_data(GNT_COMBO_BOX(combo), kvp->value, kvp->key); + + if (g_str_equal(kvp->value, active)) + gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), kvp->value); + } } else { @@ -603,7 +654,7 @@ button = gnt_button_new(_("Cancel")); gnt_box_add_widget(GNT_BOX(hbox), button); g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), window); - + button = gnt_button_new(_("Save")); gnt_box_add_widget(GNT_BOX(hbox), button); g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(save_account_cb), dialog);