changeset 18757:d54fecfe6bf7

Fix a bug with multi-field selections in Pidgin's implementation of the request API where, if a field had multiple selected values then only the first one would show up as selected.
author Mark Doliner <mark@kingant.net>
date Tue, 31 Jul 2007 16:30:58 +0000
parents 9b0fd9a4d01b
children 0a2059a1b0cc
files pidgin/gtkrequest.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkrequest.c	Tue Jul 31 16:11:21 2007 +0000
+++ b/pidgin/gtkrequest.c	Tue Jul 31 16:30:58 2007 +0000
@@ -1003,9 +1003,6 @@
 	if (purple_request_field_list_get_multi_select(field))
 		gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
 
-	g_signal_connect(G_OBJECT(sel), "changed",
-					 G_CALLBACK(list_field_select_changed_cb), field);
-
 	column = gtk_tree_view_column_new();
 	gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1);
 
@@ -1028,6 +1025,17 @@
 			gtk_tree_selection_select_iter(sel, &iter);
 	}
 
+	/*
+	 * We only want to catch changes made by the user, so it's important
+	 * that we wait until after the list is created to connect this
+	 * handler.  If we connect the handler before the loop above and
+	 * there are multiple items selected, then selecting the first iter
+	 * in the tree causes list_field_select_changed_cb to be triggered
+	 * which clears out the rest of the list of selected items.
+	 */
+	g_signal_connect(G_OBJECT(sel), "changed",
+					 G_CALLBACK(list_field_select_changed_cb), field);
+
 	gtk_container_add(GTK_CONTAINER(sw), treeview);
 	gtk_widget_show(treeview);