Mercurial > pidgin.yaz
comparison finch/gntrequest.c @ 26959:ab298d237562
propagate from branch 'im.pidgin.pidgin.2.5.5.veracode' (head 1744a346c5951c97b5d6ec102b49606f3dd918cc)
to branch 'im.pidgin.pidgin' (head f4e1d87650834d9a82d09020df0fb030f25854e0)
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Thu, 14 May 2009 21:16:58 +0000 |
parents | 1c73d2ef9ddc |
children | 710cbace0076 |
comparison
equal
deleted
inserted
replaced
25846:c7ec8f3b39d3 | 26959:ab298d237562 |
---|---|
37 #include "finch.h" | 37 #include "finch.h" |
38 #include "gntrequest.h" | 38 #include "gntrequest.h" |
39 #include "debug.h" | 39 #include "debug.h" |
40 #include "util.h" | 40 #include "util.h" |
41 | 41 |
42 /* XXX: Until gobjectification ... */ | |
43 #undef FINCH_GET_DATA | |
44 #undef FINCH_SET_DATA | |
45 #define FINCH_GET_DATA(obj) purple_request_field_get_ui_data(obj) | |
46 #define FINCH_SET_DATA(obj, data) purple_request_field_set_ui_data(obj, data) | |
47 | |
42 typedef struct | 48 typedef struct |
43 { | 49 { |
44 void *user_data; | 50 void *user_data; |
45 GntWidget *dialog; | 51 GntWidget *dialog; |
46 GCallback *cbs; | 52 GCallback *cbs; |
391 | 397 |
392 purple_request_close(PURPLE_REQUEST_FIELDS, button); | 398 purple_request_close(PURPLE_REQUEST_FIELDS, button); |
393 } | 399 } |
394 | 400 |
395 static void | 401 static void |
396 update_selected_account(GntEntry *screenname, const char *start, const char *end, | 402 update_selected_account(GntEntry *username, const char *start, const char *end, |
397 GntComboBox *accountlist) | 403 GntComboBox *accountlist) |
398 { | 404 { |
399 GList *accounts = gnt_tree_get_rows(GNT_TREE(accountlist->dropdown)); | 405 GList *accounts = gnt_tree_get_rows(GNT_TREE(accountlist->dropdown)); |
400 const char *name = gnt_entry_get_text(screenname); | 406 const char *name = gnt_entry_get_text(username); |
401 while (accounts) { | 407 while (accounts) { |
402 if (purple_find_buddy(accounts->data, name)) { | 408 if (purple_find_buddy(accounts->data, name)) { |
403 gnt_combo_box_set_selected(accountlist, accounts->data); | 409 gnt_combo_box_set_selected(accountlist, accounts->data); |
404 gnt_widget_draw(GNT_WIDGET(accountlist)); | 410 gnt_widget_draw(GNT_WIDGET(accountlist)); |
405 break; | 411 break; |
417 purple_request_field_bool_get_default_value(field)); | 423 purple_request_field_bool_get_default_value(field)); |
418 return check; | 424 return check; |
419 } | 425 } |
420 | 426 |
421 static GntWidget* | 427 static GntWidget* |
422 create_string_field(PurpleRequestField *field, GntWidget **screenname) | 428 create_string_field(PurpleRequestField *field, GntWidget **username) |
423 { | 429 { |
424 const char *hint = purple_request_field_get_type_hint(field); | 430 const char *hint = purple_request_field_get_type_hint(field); |
425 GntWidget *entry = gnt_entry_new( | 431 GntWidget *entry = gnt_entry_new( |
426 purple_request_field_string_get_default_value(field)); | 432 purple_request_field_string_get_default_value(field)); |
427 gnt_entry_set_masked(GNT_ENTRY(entry), | 433 gnt_entry_set_masked(GNT_ENTRY(entry), |
433 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) | 439 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) |
434 continue; | 440 continue; |
435 gnt_entry_add_suggest(GNT_ENTRY(entry), purple_buddy_get_name((PurpleBuddy*)node)); | 441 gnt_entry_add_suggest(GNT_ENTRY(entry), purple_buddy_get_name((PurpleBuddy*)node)); |
436 } | 442 } |
437 gnt_entry_set_always_suggest(GNT_ENTRY(entry), TRUE); | 443 gnt_entry_set_always_suggest(GNT_ENTRY(entry), TRUE); |
438 if (screenname) | 444 if (username) |
439 *screenname = entry; | 445 *username = entry; |
440 } else if (hint && !strcmp(hint, "group")) { | 446 } else if (hint && !strcmp(hint, "group")) { |
441 PurpleBlistNode *node; | 447 PurpleBlistNode *node; |
442 for (node = purple_blist_get_root(); node; | 448 for (node = purple_blist_get_root(); node; |
443 node = purple_blist_node_get_sibling_next(node)) { | 449 node = purple_blist_node_get_sibling_next(node)) { |
444 if (PURPLE_BLIST_NODE_IS_GROUP(node)) | 450 if (PURPLE_BLIST_NODE_IS_GROUP(node)) |
567 PurpleAccount *account, const char *who, PurpleConversation *conv, | 573 PurpleAccount *account, const char *who, PurpleConversation *conv, |
568 void *userdata) | 574 void *userdata) |
569 { | 575 { |
570 GntWidget *window, *box; | 576 GntWidget *window, *box; |
571 GList *grlist; | 577 GList *grlist; |
572 GntWidget *screenname = NULL, *accountlist = NULL; | 578 GntWidget *username = NULL, *accountlist = NULL; |
573 | 579 |
574 window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_FIELDS); | 580 window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_FIELDS); |
575 | 581 |
576 /* This is how it's going to work: the request-groups are going to be | 582 /* This is how it's going to work: the request-groups are going to be |
577 * stacked vertically one after the other. A GntLine will be separating | 583 * stacked vertically one after the other. A GntLine will be separating |
615 { | 621 { |
616 FINCH_SET_DATA(field, create_boolean_field(field)); | 622 FINCH_SET_DATA(field, create_boolean_field(field)); |
617 } | 623 } |
618 else if (type == PURPLE_REQUEST_FIELD_STRING) | 624 else if (type == PURPLE_REQUEST_FIELD_STRING) |
619 { | 625 { |
620 FINCH_SET_DATA(field, create_string_field(field, &screenname)); | 626 FINCH_SET_DATA(field, create_string_field(field, &username)); |
621 } | 627 } |
622 else if (type == PURPLE_REQUEST_FIELD_INTEGER) | 628 else if (type == PURPLE_REQUEST_FIELD_INTEGER) |
623 { | 629 { |
624 FINCH_SET_DATA(field, create_integer_field(field)); | 630 FINCH_SET_DATA(field, create_integer_field(field)); |
625 } | 631 } |
631 { | 637 { |
632 FINCH_SET_DATA(field, create_list_field(field)); | 638 FINCH_SET_DATA(field, create_list_field(field)); |
633 } | 639 } |
634 else if (type == PURPLE_REQUEST_FIELD_ACCOUNT) | 640 else if (type == PURPLE_REQUEST_FIELD_ACCOUNT) |
635 { | 641 { |
636 accountlist = FINCH_SET_DATA(field, create_account_field(field)); | 642 accountlist = create_account_field(field); |
643 FINCH_SET_DATA(field, accountlist); | |
637 } | 644 } |
638 else | 645 else |
639 { | 646 { |
640 FINCH_SET_DATA(field, gnt_label_new_with_format(_("Not implemented yet."), | 647 FINCH_SET_DATA(field, gnt_label_new_with_format(_("Not implemented yet."), |
641 GNT_TEXT_FLAG_BOLD)); | 648 GNT_TEXT_FLAG_BOLD)); |
653 gnt_box_add_widget(GNT_BOX(window), box); | 660 gnt_box_add_widget(GNT_BOX(window), box); |
654 | 661 |
655 setup_default_callback(window, cancel_cb, userdata); | 662 setup_default_callback(window, cancel_cb, userdata); |
656 gnt_widget_show(window); | 663 gnt_widget_show(window); |
657 | 664 |
658 if (screenname && accountlist) { | 665 if (username && accountlist) { |
659 g_signal_connect(screenname, "completion", G_CALLBACK(update_selected_account), accountlist); | 666 g_signal_connect(username, "completion", G_CALLBACK(update_selected_account), accountlist); |
660 } | 667 } |
661 | 668 |
662 g_object_set_data(G_OBJECT(window), "fields", allfields); | 669 g_object_set_data(G_OBJECT(window), "fields", allfields); |
663 | 670 |
664 return window; | 671 return window; |