pidgin: 3ac8d903: Fix data selection in a list-type reques...

sadrul at pidgin.im sadrul at pidgin.im
Sun Jul 4 00:08:04 EDT 2010


----------------------------------------------------------------------
Revision: 3ac8d903a9f4e67e9787c4c66b150906100a7678
Parent:   9516977f6181bc776a77f42a548b05b17dfbcfec
Author:   sadrul at pidgin.im
Date:     07/04/10 00:06:17
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/3ac8d903a9f4e67e9787c4c66b150906100a7678

Changelog: 

Fix data selection in a list-type request-field.

Changes against parent 9516977f6181bc776a77f42a548b05b17dfbcfec

  patched  finch/gntrequest.c

-------------- next part --------------
============================================================
--- finch/gntrequest.c	f18d02933e988a7afc44b078d45e7a2f3fbceae3
+++ finch/gntrequest.c	9c7dc35fe49bbe8825302fc55681fb6e8d081cf5
@@ -349,10 +349,9 @@ request_fields_cb(GntWidget *button, Pur
 			}
 			else if (type == PURPLE_REQUEST_FIELD_LIST)
 			{
-				GList *list = NULL;
+				GList *list = NULL, *iter;
 				if (purple_request_field_list_get_multi_select(field))
 				{
-					GList *iter;
 					GntWidget *tree = FINCH_GET_DATA(field);
 
 					iter = purple_request_field_list_get_items(field);
@@ -361,14 +360,23 @@ request_fields_cb(GntWidget *button, Pur
 						const char *text = iter->data;
 						gpointer key = purple_request_field_list_get_data(field, text);
 						if (gnt_tree_get_choice(GNT_TREE(tree), key))
-							list = g_list_prepend(list, key);
+							list = g_list_prepend(list, (gpointer)text);
 					}
 				}
 				else
 				{
 					GntWidget *combo = FINCH_GET_DATA(field);
 					gpointer data = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo));
-					list = g_list_append(list, data);
+
+					iter = purple_request_field_list_get_items(field);
+					for (; iter; iter = iter->next) {
+						const char *text = iter->data;
+						gpointer key = purple_request_field_list_get_data(field, text);
+						if (key == data) {
+							list = g_list_prepend(list, (gpointer)text);
+							break;
+						}
+					}
 				}
 
 				purple_request_field_list_set_selected(field, list);
@@ -815,7 +823,7 @@ void finch_request_save_in_prefs(gpointe
 	for (list = purple_request_fields_get_groups(allfields); list; list = list->next) {
 		PurpleRequestFieldGroup *group = list->data;
 		GList *fields = purple_request_field_group_get_fields(group);
-		
+
 		for (; fields ; fields = fields->next) {
 			PurpleRequestField *field = fields->data;
 			PurpleRequestFieldType type = purple_request_field_get_type(field);
@@ -826,6 +834,7 @@ void finch_request_save_in_prefs(gpointe
 			switch (type) {
 				case PURPLE_REQUEST_FIELD_LIST:
 					val = purple_request_field_list_get_selected(field)->data;
+					val = purple_request_field_list_get_data(field, val);
 					break;
 				case PURPLE_REQUEST_FIELD_BOOLEAN:
 					val = GINT_TO_POINTER(purple_request_field_bool_get_value(field));


More information about the Commits mailing list