finch: Add support for string lists as account options

Fri, 27 Aug 2010 06:28:09 +0000

author
Paul Aurich <darkrain42@pidgin.im>
date
Fri, 27 Aug 2010 06:28:09 +0000
changeset 30725
4aa8ed98e52a
parent 30724
aec4b368087d
child 30726
21877cf94da0
child 30740
017077f79a0f

finch: Add support for string lists as account options

ChangeLog file | annotate | diff | comparison | revisions
finch/gntaccount.c file | annotate | diff | comparison | revisions
--- a/ChangeLog	Fri Aug 27 05:14:08 2010 +0000
+++ b/ChangeLog	Fri Aug 27 06:28:09 2010 +0000
@@ -12,6 +12,10 @@
 	* Add support for the Gadu-Gadu protocol in the gevolution plugin to
 	  provide Evolution integration with contacts with GG IDs. (#10709)
 
+	Finch:
+	* Add support for drop-down account options (like the SILC cipher
+	  and HMAC options or the QQ protocol version).
+
 	XMPP:
 	* Fix a crash when multiple accounts are simultaneously performing
 	  SASL authentication when built with Cyrus SASL support.  (thanks
--- a/finch/gntaccount.c	Fri Aug 27 05:14:08 2010 +0000
+++ b/finch/gntaccount.c	Fri Aug 27 06:28:09 2010 +0000
@@ -236,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
 			{
@@ -430,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
 			{

mercurial