| 506 gboolean single_prpl = TRUE; |
506 gboolean single_prpl = TRUE; |
| 507 GList *accounts; |
507 GList *accounts; |
| 508 gboolean enabled = FALSE; |
508 gboolean enabled = FALSE; |
| 509 GaimAccount *first_account = NULL; |
509 GaimAccount *first_account = NULL; |
| 510 const char *first_prpl_type = NULL; |
510 const char *first_prpl_type = NULL; |
| 511 GList *l; |
511 const GList *l; |
| 512 |
512 |
| 513 g_return_if_fail(selector != NULL); |
513 g_return_if_fail(selector != NULL); |
| 514 g_return_if_fail(GAIM_GTK_IS_STATUS_SELECTOR(selector)); |
514 g_return_if_fail(GAIM_GTK_IS_STATUS_SELECTOR(selector)); |
| 515 |
515 |
| 516 #if GTK_CHECK_VERSION(2,4,0) |
516 #if GTK_CHECK_VERSION(2,4,0) |
| 603 load_icon(filename)); |
601 load_icon(filename)); |
| 604 } |
602 } |
| 605 } |
603 } |
| 606 else |
604 else |
| 607 { |
605 { |
| 608 /* TODO: Add "online" and "offline" here? */ |
606 /* what follows is either really ugly, or brilliant depending on |
| 609 add_item(selector, "available", _("Available"), |
607 * how you look at it, and how much you've had to drink */ |
| 610 load_icon("online.png")); |
608 int i; |
| 611 add_item(selector, "away", _("Away"), load_icon("away.png")); |
609 int num_accounts = 0; |
| |
610 int options[GAIM_STATUS_NUM_PRIMITIVES]; |
| |
611 GaimAccount *acct_options[GAIM_STATUS_NUM_PRIMITIVES]; |
| |
612 |
| |
613 for(i=0; i<GAIM_STATUS_NUM_PRIMITIVES; i++) { |
| |
614 options[i] = 0; |
| |
615 acct_options[i] = NULL; |
| |
616 } |
| |
617 |
| |
618 for(accounts = gaim_accounts_get_all(); accounts != NULL; accounts = accounts->next) { |
| |
619 GaimAccount *account = accounts->data; |
| |
620 |
| |
621 if (!gaim_account_get_enabled(account, GAIM_GTK_UI)) |
| |
622 continue; |
| |
623 |
| |
624 num_accounts++; |
| |
625 |
| |
626 for(l = gaim_account_get_status_types(account); l != NULL; l = l->next) { |
| |
627 GaimStatusType *status_type = l->data; |
| |
628 |
| |
629 if (!gaim_status_type_is_user_settable(status_type)) |
| |
630 continue; |
| |
631 |
| |
632 acct_options[gaim_status_type_get_primitive(status_type)] = account; |
| |
633 } |
| |
634 |
| |
635 for(i=0; i<GAIM_STATUS_NUM_PRIMITIVES; i++) { |
| |
636 gaim_debug_misc("gtkstatusselector", "account=%p, acct_options[%d]=%p\n", account, i, acct_options[i]); |
| |
637 if(acct_options[i] == account) |
| |
638 options[i]++; |
| |
639 } |
| |
640 } |
| |
641 |
| |
642 for(i=0; i<GAIM_STATUS_NUM_PRIMITIVES; i++) { |
| |
643 gaim_debug_misc("gtkstatusselector", "%s has %d accounts\n", gaim_primitive_get_name_from_type(i), options[i]); |
| |
644 if(options[i] == num_accounts) { |
| |
645 char *filename = g_strdup_printf("%s.png", gaim_primitive_get_id_from_type(i)); |
| |
646 add_item(selector, gaim_primitive_get_id_from_type(i), gaim_primitive_get_name_from_type(i), load_icon(filename)); |
| |
647 g_free(filename); |
| |
648 } |
| |
649 } |
| 612 } |
650 } |
| 613 |
651 |
| 614 /* TODO: Add saved statuses here? */ |
652 /* TODO: Add saved statuses here? */ |
| 615 |
653 |
| 616 add_item(selector, NULL, _("New Status"), |
654 add_item(selector, NULL, _("New Status"), |