comparison src/gtkrequest.c @ 5832:db204c4a411b

[gaim-migrate @ 6263] Values entered into multi-field dialogs are now set when the user hits enter. This works with multiple entry fields in the multi-field dialogs, which means multiple signals connecting many fields in multiple ways. This could increase to multiple uses in the many protocols, as fields are added to the many dialogs multiple times. This could increase for the many people using multiple dialogs, especially if open a multiple number of times and data entered into the many field entries. This may not even work, as I have not tested it multiple times, but rather 0. However, it's CVS, so don't use it yet, as it crashes on startup multiple times. Field entry. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 11 Jun 2003 21:24:27 +0000
parents 571e895bf6ba
children 77eba2e68d07
comparison
equal deleted inserted replaced
5831:cc52ed54b916 5832:db204c4a411b
91 91
92 gaim_request_close(GAIM_REQUEST_INPUT, data); 92 gaim_request_close(GAIM_REQUEST_INPUT, data);
93 } 93 }
94 94
95 static void 95 static void
96 field_string_focus_out_cb(GtkEntry *entry, GaimRequestField *field)
97 {
98 gaim_request_field_string_set_value(field,
99 gtk_entry_get_text(entry));
100 }
101
102 static void
103 field_int_focus_out_cb(GtkEntry *entry, GaimRequestField *field)
104 {
105 gaim_request_field_int_set_value(field,
106 atoi(gtk_entry_get_text(entry)));
107 }
108
109 static void
110 field_bool_cb(GtkToggleButton *button, GaimRequestField *field)
111 {
112 gaim_request_field_bool_set_value(field,
113 gtk_toggle_button_get_active(button));
114 }
115
116 static void
117 field_choice_menu_cb(GtkOptionMenu *menu, GaimRequestField *field)
118 {
119 gaim_request_field_choice_set_value(field,
120 gtk_option_menu_get_history(menu));
121 }
122
123 static void
124 field_choice_option_cb(GtkRadioButton *button, GaimRequestField *field)
125 {
126 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
127 gaim_request_field_choice_set_value(field,
128 g_slist_index(gtk_radio_button_get_group(button), button));
129 }
130
131 static void
96 multifield_ok_cb(GtkWidget *button, GaimGtkRequestData *data) 132 multifield_ok_cb(GtkWidget *button, GaimGtkRequestData *data)
97 { 133 {
98 if (data->cbs[0] != NULL) 134 if (data->cbs[0] != NULL)
99 ((GaimRequestFieldsCb)data->cbs[0])(data->user_data, 135 ((GaimRequestFieldsCb)data->cbs[0])(data->user_data,
100 data->u.multifield.fields); 136 data->u.multifield.fields);
487 523
488 value = gaim_request_field_string_get_default_value(field); 524 value = gaim_request_field_string_get_default_value(field);
489 525
490 if (value != NULL) 526 if (value != NULL)
491 gtk_entry_set_text(GTK_ENTRY(widget), value); 527 gtk_entry_set_text(GTK_ENTRY(widget), value);
528
529 g_signal_connect(G_OBJECT(widget), "focus-out-event",
530 G_CALLBACK(field_string_focus_out_cb),
531 field);
492 } 532 }
493 else if (type == GAIM_REQUEST_FIELD_INTEGER) { 533 else if (type == GAIM_REQUEST_FIELD_INTEGER) {
494 int value; 534 int value;
495 535
496 widget = gtk_entry_new(); 536 widget = gtk_entry_new();
502 542
503 g_snprintf(buf, sizeof(buf), "%d", value); 543 g_snprintf(buf, sizeof(buf), "%d", value);
504 544
505 gtk_entry_set_text(GTK_ENTRY(widget), buf); 545 gtk_entry_set_text(GTK_ENTRY(widget), buf);
506 } 546 }
547
548 g_signal_connect(G_OBJECT(widget), "focus-out-event",
549 G_CALLBACK(field_int_focus_out_cb),
550 field);
507 } 551 }
508 else if (type == GAIM_REQUEST_FIELD_BOOLEAN) { 552 else if (type == GAIM_REQUEST_FIELD_BOOLEAN) {
509 widget = gtk_check_button_new_with_label( 553 widget = gtk_check_button_new_with_label(
510 gaim_request_field_get_label(field)); 554 gaim_request_field_get_label(field));
511 555
512 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), 556 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
513 gaim_request_field_bool_get_default_value(field)); 557 gaim_request_field_bool_get_default_value(field));
558
559 g_signal_connect(G_OBJECT(widget), "toggled",
560 G_CALLBACK(field_bool_cb), field);
514 } 561 }
515 else if (type == GAIM_REQUEST_FIELD_CHOICE) { 562 else if (type == GAIM_REQUEST_FIELD_CHOICE) {
516 GList *labels; 563 GList *labels;
517 GList *l; 564 GList *l;
518 565
533 580
534 item = gtk_menu_item_new_with_label(text); 581 item = gtk_menu_item_new_with_label(text);
535 582
536 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); 583 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
537 } 584 }
585
586 g_signal_connect(G_OBJECT(widget), "changed",
587 G_CALLBACK(field_choice_menu_cb),
588 field);
538 } 589 }
539 else { 590 else {
540 GtkWidget *box; 591 GtkWidget *box;
541 GtkWidget *first_radio = NULL; 592 GtkWidget *first_radio = NULL;
542 GtkWidget *radio; 593 GtkWidget *radio;
559 first_radio = radio; 610 first_radio = radio;
560 611
561 gtk_box_pack_start(GTK_BOX(box), radio, 612 gtk_box_pack_start(GTK_BOX(box), radio,
562 TRUE, TRUE, 0); 613 TRUE, TRUE, 0);
563 gtk_widget_show(radio); 614 gtk_widget_show(radio);
615
616 g_signal_connect(G_OBJECT(widget), "toggled",
617 G_CALLBACK(field_choice_option_cb),
618 field);
564 } 619 }
565 } 620 }
566 } 621 }
567 622
568 if (type != GAIM_REQUEST_FIELD_BOOLEAN) { 623 if (type != GAIM_REQUEST_FIELD_BOOLEAN) {