changeset 10943:aa1df43e474c

[gaim-migrate @ 12735] Fix multiple choice requests that have 5 or less choices, these use radio buttons and we were returning a "backwards" value because gtk prepends to the list of buttons and we assumed they were being appended. Also fix selecting the default entry when the request is shown. committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Thu, 26 May 2005 12:49:25 +0000
parents 77cb56ff14e1
children 4a4f2760a9ad
files src/gtkrequest.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkrequest.c	Thu May 26 12:15:13 2005 +0000
+++ b/src/gtkrequest.c	Thu May 26 12:49:25 2005 +0000
@@ -207,7 +207,8 @@
 {
 	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
 		gaim_request_field_choice_set_value(field,
-				g_slist_index(gtk_radio_button_get_group(button), button));
+				(g_slist_length(gtk_radio_button_get_group(button)) -
+				 g_slist_index(gtk_radio_button_get_group(button), button)) - 1);
 }
 
 static void
@@ -1149,6 +1150,7 @@
 		GtkWidget *box;
 		GtkWidget *first_radio = NULL;
 		GtkWidget *radio;
+		gint i;
 
 		if (g_list_length(labels) == 2)
 			box = gtk_hbox_new(FALSE, 6);
@@ -1157,7 +1159,7 @@
 
 		widget = box;
 
-		for (l = labels; l != NULL; l = l->next)
+		for (l = labels, i = 0; l != NULL; l = l->next, i++)
 		{
 			const char *text = l->data;
 
@@ -1167,6 +1169,9 @@
 			if (first_radio == NULL)
 				first_radio = radio;
 
+			if (i == gaim_request_field_choice_get_default_value(field))
+				gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE);
+
 			gtk_box_pack_start(GTK_BOX(box), radio, TRUE, TRUE, 0);
 			gtk_widget_show(radio);