Mercurial > pidgin.yaz
changeset 12172:d5937f126c60
[gaim-migrate @ 14474]
Fix the bugs with the account option string lists that Pekka Riikonen
mentioned on gaim-devel
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sun, 20 Nov 2005 17:29:09 +0000 |
parents | ffdd2ccf3a53 |
children | 81c63578aa39 |
files | src/accountopt.c src/accountopt.h src/gtkaccount.c |
diffstat | 3 files changed, 41 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/accountopt.c Sun Nov 20 16:02:21 2005 +0000 +++ b/src/accountopt.c Sun Nov 20 17:29:09 2005 +0000 @@ -23,6 +23,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "accountopt.h" +#include "util.h" GaimAccountOption * gaim_account_option_new(GaimPrefType type, const char *text, @@ -197,15 +198,19 @@ gaim_account_option_add_list_item(GaimAccountOption *option, const char *key, const char *value) { + GaimKeyValuePair *kvp; + g_return_if_fail(option != NULL); g_return_if_fail(key != NULL); g_return_if_fail(value != NULL); g_return_if_fail(option->type == GAIM_PREF_STRING_LIST); + kvp = g_new0(GaimKeyValuePair, 1); + kvp->key = g_strdup(key); + kvp->value = g_strdup(value); + option->default_value.list = g_list_append(option->default_value.list, - g_strdup(key)); - option->default_value.list = g_list_append(option->default_value.list, - g_strdup(value)); + kvp); } GaimPrefType @@ -259,6 +264,22 @@ return option->default_value.string; } +const char * +gaim_account_option_get_default_list_value(const GaimAccountOption *option) +{ + GaimKeyValuePair *kvp; + + g_return_val_if_fail(option != NULL, NULL); + g_return_val_if_fail(option->type == GAIM_PREF_STRING_LIST, NULL); + + if (option->default_value.list == NULL) + return NULL; + + kvp = option->default_value.list->data; + + return (kvp ? kvp->value : NULL); +} + gboolean gaim_account_option_get_masked(const GaimAccountOption *option) {
--- a/src/accountopt.h Sun Nov 20 16:02:21 2005 +0000 +++ b/src/accountopt.h Sun Nov 20 17:29:09 2005 +0000 @@ -269,6 +269,16 @@ const GaimAccountOption *option); /** + * Returns the default string value for a list account option. + * + * @param option The account option. + * + * @return The default list string value. + */ +const char *gaim_account_option_get_default_list_value( + const GaimAccountOption *option); + +/** * Returns the masking for an account option. * * @param option The account option.
--- a/src/gtkaccount.c Sun Nov 20 16:02:21 2005 +0000 +++ b/src/gtkaccount.c Sun Nov 20 17:29:09 2005 +0000 @@ -1115,36 +1115,32 @@ case GAIM_PREF_STRING_LIST: i = 0; - idx = -1; + idx = 0; if (account == NULL || strcmp(gaim_account_get_protocol_id(account), dialog->protocol_id)) { - str_value = gaim_account_option_get_default_string(option); + str_value = gaim_account_option_get_default_list_value(option); } else { str_value = gaim_account_get_string(account, gaim_account_option_get_setting(option), - gaim_account_option_get_default_string(option)); + gaim_account_option_get_default_list_value(option)); } - list = gaim_account_option_get_list(option); model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER); combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(model)); - //if (gaim_account_option_get_masked(option)) - //gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); - /* Loop through list of GaimKeyValuePair items */ for (node = list; node != NULL; node = node->next) { if (node->data != NULL) { kvp = (GaimKeyValuePair *) node->data; - if ((idx < 0) && (kvp->value != NULL) && (str_value != NULL)) - if (!g_utf8_collate(kvp->value, str_value)) - idx = i; + if ((kvp->value != NULL) && (str_value != NULL) && + !g_utf8_collate(kvp->value, str_value)) + idx = i; gtk_list_store_append(model, &iter); gtk_list_store_set(model, &iter, @@ -1157,8 +1153,7 @@ } /* Set default */ - if (idx >= 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), idx); + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), idx); /* Define renderer */ renderer = gtk_cell_renderer_text_new();