| 512 ret = combo; |
512 ret = combo; |
| 513 } |
513 } |
| 514 return ret; |
514 return ret; |
| 515 } |
515 } |
| 516 |
516 |
| |
517 static void |
| |
518 add_account_to_combo(GntWidget *combo, PurpleAccount *account) { |
| |
519 char *text = NULL; |
| |
520 |
| |
521 text = g_strdup_printf("%s (%s)", |
| |
522 purple_account_get_username(account), |
| |
523 purple_account_get_protocol_name(account)); |
| |
524 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), account, text); |
| |
525 g_free(text); |
| |
526 } |
| |
527 |
| 517 static GntWidget* |
528 static GntWidget* |
| 518 create_account_field(PurpleRequestField *field) |
529 create_account_field(PurpleRequestField *field) |
| 519 { |
530 { |
| 520 gboolean all; |
531 gboolean all; |
| 521 PurpleAccount *def; |
532 PurpleAccount *def; |
| 522 GList *list; |
|
| 523 GntWidget *combo = gnt_combo_box_new(); |
533 GntWidget *combo = gnt_combo_box_new(); |
| 524 |
534 |
| 525 all = purple_request_field_account_get_show_all(field); |
535 all = purple_request_field_account_get_show_all(field); |
| 526 def = purple_request_field_account_get_value(field); |
536 def = purple_request_field_account_get_value(field); |
| 527 if (!def) { |
537 if (!def) { |
| 528 def = purple_request_field_account_get_default_value(field); |
538 def = purple_request_field_account_get_default_value(field); |
| 529 } |
539 } |
| 530 |
540 |
| 531 if(all) { |
541 if(all) { |
| 532 PurpleAccountManager *manager = purple_account_manager_get_default(); |
542 GListModel *manager_model = NULL; |
| 533 list = purple_account_manager_get_all(manager); |
543 guint n_items = 0; |
| |
544 |
| |
545 manager_model = purple_account_manager_get_default_as_model(); |
| |
546 n_items = g_list_model_get_n_items(manager_model); |
| |
547 for(guint index = 0; index < n_items; index++) { |
| |
548 PurpleAccount *account; |
| |
549 |
| |
550 account = g_list_model_get_item(manager_model, index); |
| |
551 add_account_to_combo(combo, account); |
| |
552 |
| |
553 if(account == def) { |
| |
554 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), account); |
| |
555 } |
| |
556 |
| |
557 g_object_unref(account); |
| |
558 } |
| 534 } else { |
559 } else { |
| 535 list = purple_connections_get_all(); |
560 GList *list = purple_connections_get_all(); |
| 536 } |
561 for(; list; list = list->next) { |
| 537 |
562 PurpleAccount *account = NULL; |
| 538 for(; list; list = list->next) { |
563 |
| 539 PurpleAccount *account; |
|
| 540 char *text; |
|
| 541 |
|
| 542 if (all) |
|
| 543 account = list->data; |
|
| 544 else |
|
| 545 account = purple_connection_get_account(list->data); |
564 account = purple_connection_get_account(list->data); |
| 546 |
565 add_account_to_combo(combo, account); |
| 547 text = g_strdup_printf("%s (%s)", |
566 |
| 548 purple_account_get_username(account), |
567 if(account == def) { |
| 549 purple_account_get_protocol_name(account)); |
568 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), account); |
| 550 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), account, text); |
569 } |
| 551 g_free(text); |
570 } |
| 552 if (account == def) |
571 } |
| 553 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), account); |
572 |
| 554 } |
|
| 555 gnt_widget_set_size(combo, 20, 3); /* ew */ |
573 gnt_widget_set_size(combo, 20, 3); /* ew */ |
| 556 return combo; |
574 return combo; |
| 557 } |
575 } |
| 558 |
576 |
| 559 static void |
577 static void |