From: Stu T. <nos...@us...> - 2005-11-20 17:29:17
|
Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16267 Modified Files: accountopt.c accountopt.h gtkaccount.c Log Message: Fix the bugs with the account option string lists that Pekka Riikonen mentioned on gaim-devel Index: accountopt.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/accountopt.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -p -r1.8 -r1.9 --- accountopt.c 6 Mar 2005 06:14:26 -0000 1.8 +++ accountopt.c 20 Nov 2005 17:29:09 -0000 1.9 @@ -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 @@ void 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 @@ gaim_account_option_get_default_string(c 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) { Index: accountopt.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/accountopt.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -p -r1.10 -r1.11 --- accountopt.h 15 Nov 2005 08:42:03 -0000 1.10 +++ accountopt.h 20 Nov 2005 17:29:09 -0000 1.11 @@ -269,6 +269,16 @@ const char *gaim_account_option_get_defa 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. Index: gtkaccount.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkaccount.c,v retrieving revision 1.211 retrieving revision 1.212 diff -u -d -p -r1.211 -r1.212 --- gtkaccount.c 19 Nov 2005 04:58:44 -0000 1.211 +++ gtkaccount.c 20 Nov 2005 17:29:09 -0000 1.212 @@ -1115,36 +1115,32 @@ add_protocol_options(AccountPrefsDialog 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 @@ add_protocol_options(AccountPrefsDialog } /* 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(); |