Mercurial > pidgin.yaz
comparison src/gtkrequest.c @ 5817:571e895bf6ba
[gaim-migrate @ 6247]
The buttons on GTK+ multi-field dialogs are now actually called, but they
have not been tested.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Mon, 09 Jun 2003 01:54:51 +0000 |
parents | 64a164aa6f70 |
children | db204c4a411b |
comparison
equal
deleted
inserted
replaced
5816:64a164aa6f70 | 5817:571e895bf6ba |
---|---|
46 | 46 |
47 gboolean multiline; | 47 gboolean multiline; |
48 | 48 |
49 } input; | 49 } input; |
50 | 50 |
51 struct | |
52 { | |
53 GaimRequestFields *fields; | |
54 | |
55 } multifield; | |
56 | |
51 } u; | 57 } u; |
52 | 58 |
53 } GaimGtkRequestData; | 59 } GaimGtkRequestData; |
54 | 60 |
55 static void | 61 static void |
82 { | 88 { |
83 if (id < data->cb_count && data->cbs[id] != NULL) | 89 if (id < data->cb_count && data->cbs[id] != NULL) |
84 ((GaimRequestActionCb)data->cbs[id])(data->user_data, id); | 90 ((GaimRequestActionCb)data->cbs[id])(data->user_data, id); |
85 | 91 |
86 gaim_request_close(GAIM_REQUEST_INPUT, data); | 92 gaim_request_close(GAIM_REQUEST_INPUT, data); |
93 } | |
94 | |
95 static void | |
96 multifield_ok_cb(GtkWidget *button, GaimGtkRequestData *data) | |
97 { | |
98 if (data->cbs[0] != NULL) | |
99 ((GaimRequestFieldsCb)data->cbs[0])(data->user_data, | |
100 data->u.multifield.fields); | |
101 | |
102 gaim_request_close(GAIM_REQUEST_FIELDS, data); | |
103 } | |
104 | |
105 static void | |
106 multifield_cancel_cb(GtkWidget *button, GaimGtkRequestData *data) | |
107 { | |
108 if (data->cbs[1] != NULL) | |
109 ((GaimRequestFieldsCb)data->cbs[1])(data->user_data, | |
110 data->u.multifield.fields); | |
111 | |
112 gaim_request_close(GAIM_REQUEST_FIELDS, data); | |
87 } | 113 } |
88 | 114 |
89 #define STOCK_ITEMIZE(r, l) \ | 115 #define STOCK_ITEMIZE(r, l) \ |
90 if (!strcmp((r), text)) \ | 116 if (!strcmp((r), text)) \ |
91 return (l); | 117 return (l); |
351 char *label_text; | 377 char *label_text; |
352 | 378 |
353 data = g_new0(GaimGtkRequestData, 1); | 379 data = g_new0(GaimGtkRequestData, 1); |
354 data->type = GAIM_REQUEST_FIELDS; | 380 data->type = GAIM_REQUEST_FIELDS; |
355 data->user_data = user_data; | 381 data->user_data = user_data; |
382 data->u.multifield.fields = fields; | |
356 | 383 |
357 data->cb_count = 2; | 384 data->cb_count = 2; |
358 data->cbs = g_new0(GCallback, 2); | 385 data->cbs = g_new0(GCallback, 2); |
359 | 386 |
360 data->cbs[0] = ok_cb; | 387 data->cbs[0] = ok_cb; |
361 data->cbs[1] = cancel_cb; | 388 data->cbs[1] = cancel_cb; |
362 | 389 |
363 data->dialog = win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 390 data->dialog = win = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
364 gtk_window_set_role(GTK_WINDOW(win), "fields request"); | 391 gtk_window_set_role(GTK_WINDOW(win), "multifield"); |
365 gtk_container_set_border_width(GTK_CONTAINER(win), 12); | 392 gtk_container_set_border_width(GTK_CONTAINER(win), 12); |
366 gtk_window_set_resizable(GTK_WINDOW(win), FALSE); | 393 gtk_window_set_resizable(GTK_WINDOW(win), FALSE); |
367 | 394 |
368 /* Setup the vbox */ | 395 /* Setup the vbox */ |
369 vbox = gtk_vbox_new(FALSE, 12); | 396 vbox = gtk_vbox_new(FALSE, 12); |
579 /* Cancel button */ | 606 /* Cancel button */ |
580 button = gtk_button_new_from_stock(text_to_stock(cancel_text)); | 607 button = gtk_button_new_from_stock(text_to_stock(cancel_text)); |
581 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | 608 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
582 gtk_widget_show(button); | 609 gtk_widget_show(button); |
583 | 610 |
611 g_signal_connect(G_OBJECT(button), "clicked", | |
612 G_CALLBACK(multifield_cancel_cb), data); | |
613 | |
584 /* OK button */ | 614 /* OK button */ |
585 button = gtk_button_new_from_stock(text_to_stock(ok_text)); | 615 button = gtk_button_new_from_stock(text_to_stock(ok_text)); |
586 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | 616 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
587 gtk_widget_show(button); | 617 gtk_widget_show(button); |
588 | 618 |
619 g_signal_connect(G_OBJECT(button), "clicked", | |
620 G_CALLBACK(multifield_ok_cb), data); | |
621 | |
589 gtk_widget_show(win); | 622 gtk_widget_show(win); |
590 | 623 |
591 return data; | 624 return data; |
592 } | 625 } |
593 | 626 |
596 { | 629 { |
597 GaimGtkRequestData *data = (GaimGtkRequestData *)ui_handle; | 630 GaimGtkRequestData *data = (GaimGtkRequestData *)ui_handle; |
598 | 631 |
599 if (data->cbs != NULL) | 632 if (data->cbs != NULL) |
600 g_free(data->cbs); | 633 g_free(data->cbs); |
634 | |
635 if (type == GAIM_REQUEST_FIELDS) | |
636 gaim_request_fields_destroy(data->u.multifield.fields); | |
601 | 637 |
602 gtk_widget_destroy(data->dialog); | 638 gtk_widget_destroy(data->dialog); |
603 | 639 |
604 g_free(data); | 640 g_free(data); |
605 } | 641 } |