comparison src/gtkrequest.c @ 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 6240d7fd5b2c
children 842a21e7480b
comparison
equal deleted inserted replaced
10942:77cb56ff14e1 10943:aa1df43e474c
205 static void 205 static void
206 field_choice_option_cb(GtkRadioButton *button, GaimRequestField *field) 206 field_choice_option_cb(GtkRadioButton *button, GaimRequestField *field)
207 { 207 {
208 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) 208 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
209 gaim_request_field_choice_set_value(field, 209 gaim_request_field_choice_set_value(field,
210 g_slist_index(gtk_radio_button_get_group(button), button)); 210 (g_slist_length(gtk_radio_button_get_group(button)) -
211 g_slist_index(gtk_radio_button_get_group(button), button)) - 1);
211 } 212 }
212 213
213 static void 214 static void
214 field_account_cb(GObject *w, GaimAccount *account, GaimRequestField *field) 215 field_account_cb(GObject *w, GaimAccount *account, GaimRequestField *field)
215 { 216 {
1147 else 1148 else
1148 { 1149 {
1149 GtkWidget *box; 1150 GtkWidget *box;
1150 GtkWidget *first_radio = NULL; 1151 GtkWidget *first_radio = NULL;
1151 GtkWidget *radio; 1152 GtkWidget *radio;
1153 gint i;
1152 1154
1153 if (g_list_length(labels) == 2) 1155 if (g_list_length(labels) == 2)
1154 box = gtk_hbox_new(FALSE, 6); 1156 box = gtk_hbox_new(FALSE, 6);
1155 else 1157 else
1156 box = gtk_vbox_new(FALSE, 0); 1158 box = gtk_vbox_new(FALSE, 0);
1157 1159
1158 widget = box; 1160 widget = box;
1159 1161
1160 for (l = labels; l != NULL; l = l->next) 1162 for (l = labels, i = 0; l != NULL; l = l->next, i++)
1161 { 1163 {
1162 const char *text = l->data; 1164 const char *text = l->data;
1163 1165
1164 radio = gtk_radio_button_new_with_label_from_widget( 1166 radio = gtk_radio_button_new_with_label_from_widget(
1165 GTK_RADIO_BUTTON(first_radio), text); 1167 GTK_RADIO_BUTTON(first_radio), text);
1166 1168
1167 if (first_radio == NULL) 1169 if (first_radio == NULL)
1168 first_radio = radio; 1170 first_radio = radio;
1171
1172 if (i == gaim_request_field_choice_get_default_value(field))
1173 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE);
1169 1174
1170 gtk_box_pack_start(GTK_BOX(box), radio, TRUE, TRUE, 0); 1175 gtk_box_pack_start(GTK_BOX(box), radio, TRUE, TRUE, 0);
1171 gtk_widget_show(radio); 1176 gtk_widget_show(radio);
1172 1177
1173 g_signal_connect(G_OBJECT(radio), "toggled", 1178 g_signal_connect(G_OBJECT(radio), "toggled",