Mercurial > pidgin.yaz
comparison gtk/gtkstatusbox.c @ 14739:63d5b71d0c68
[gaim-migrate @ 17495]
This should fix the statusbox issues that were keeping us from releasing beta
4 (and which were just really annoying). Thakn sadrul for most of this, I just
added the if (index == -1) bit. Anyway, the way this works now is that for
saved/popular statuses the primitive underlying that status is where the
dropdown for the statusbox starts. If we don't like that we can change it but
I'm not sure we'll find something better.
Also, this might plug a couple leaks, I'm not really sure but it certainly
looks right.
Up next, the patch to make the docklet use the per-protocol statuses in the
top section.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Tue, 17 Oct 2006 08:13:41 +0000 |
parents | 05c34aabdcc3 |
children | f453cc774882 |
comparison
equal
deleted
inserted
replaced
14738:e1cfdb131c62 | 14739:63d5b71d0c68 |
---|---|
694 * was changed programmatically. | 694 * was changed programmatically. |
695 */ | 695 */ |
696 gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE); | 696 gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE); |
697 | 697 |
698 /* | 698 /* |
699 * If the saved_status is transient, is Available, Away, Invisible | 699 * If there is a token-account, then select the primitive from the |
700 * or Offline, and it does not have an substatuses, then select | 700 * dropdown using a loop. Otherwise select from the default list. |
701 * the primitive in the dropdown menu. Otherwise select the | |
702 * popular status in the dropdown menu. | |
703 */ | 701 */ |
704 primitive = gaim_savedstatus_get_type(saved_status); | 702 primitive = gaim_savedstatus_get_type(saved_status); |
705 if (!status_box->token_status_account && gaim_savedstatus_is_transient(saved_status) && | 703 if (!status_box->token_status_account) |
706 ((primitive == GAIM_STATUS_AVAILABLE) || (primitive == GAIM_STATUS_AWAY) || | |
707 (primitive == GAIM_STATUS_INVISIBLE) || (primitive == GAIM_STATUS_OFFLINE)) && | |
708 (!gaim_savedstatus_has_substatuses(saved_status))) | |
709 { | 704 { |
710 index = get_statusbox_index(status_box, saved_status); | 705 index = get_statusbox_index(status_box, saved_status); |
711 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), index); | 706 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), index); |
707 if (index == -1) | |
708 gtk_gaim_status_box_refresh(status_box); | |
712 } | 709 } |
713 else | 710 else |
714 { | 711 { |
715 GtkTreeIter iter; | 712 GtkTreeIter iter; |
716 GtkGaimStatusBoxItemType type; | 713 GtkGaimStatusBoxItemType type; |
726 { | 723 { |
727 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, | 724 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
728 TYPE_COLUMN, &type, | 725 TYPE_COLUMN, &type, |
729 DATA_COLUMN, &data, | 726 DATA_COLUMN, &data, |
730 -1); | 727 -1); |
731 if (status_box->token_status_account && gaim_savedstatus_is_transient(saved_status) | 728 if (type == GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE && primitive == GPOINTER_TO_INT(data)) |
732 && type == GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE && primitive == GPOINTER_TO_INT(data)) | |
733 { | 729 { |
734 char *name; | 730 char *name; |
735 const char *acct_status_name = gaim_status_get_name( | 731 const char *acct_status_name = gaim_status_get_name( |
736 gaim_account_get_active_status(status_box->token_status_account)); | 732 gaim_account_get_active_status(status_box->token_status_account)); |
737 | 733 |
738 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, | 734 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
739 TEXT_COLUMN, &name, -1); | 735 TEXT_COLUMN, &name, -1); |
740 | 736 |
741 if (!gaim_savedstatus_has_substatuses(saved_status) | 737 if (!strcmp(name, acct_status_name)) |
742 || !strcmp(name, acct_status_name)) | |
743 { | 738 { |
744 /* Found! */ | 739 /* Found! */ |
745 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(status_box), &iter); | 740 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(status_box), &iter); |
746 g_free(name); | 741 g_free(name); |
747 break; | 742 break; |
748 } | 743 } |
749 g_free(name); | 744 g_free(name); |
750 } | |
751 else if ((type == GTK_GAIM_STATUS_BOX_TYPE_POPULAR) && | |
752 (GPOINTER_TO_INT(data) == gaim_savedstatus_get_creation_time(saved_status))) | |
753 { | |
754 /* Found! */ | |
755 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(status_box), &iter); | |
756 break; | |
757 } | 745 } |
758 } | 746 } |
759 while (gtk_tree_model_iter_next(GTK_TREE_MODEL(status_box->dropdown_store), &iter)); | 747 while (gtk_tree_model_iter_next(GTK_TREE_MODEL(status_box->dropdown_store), &iter)); |
760 } | 748 } |
761 } | 749 } |
982 | 970 |
983 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, pixbuf, _("Available"), NULL, GINT_TO_POINTER(GAIM_STATUS_AVAILABLE)); | 971 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, pixbuf, _("Available"), NULL, GINT_TO_POINTER(GAIM_STATUS_AVAILABLE)); |
984 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, pixbuf2, _("Away"), NULL, GINT_TO_POINTER(GAIM_STATUS_AWAY)); | 972 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, pixbuf2, _("Away"), NULL, GINT_TO_POINTER(GAIM_STATUS_AWAY)); |
985 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, pixbuf4, _("Invisible"), NULL, GINT_TO_POINTER(GAIM_STATUS_INVISIBLE)); | 973 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, pixbuf4, _("Invisible"), NULL, GINT_TO_POINTER(GAIM_STATUS_INVISIBLE)); |
986 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, pixbuf3, _("Offline"), NULL, GINT_TO_POINTER(GAIM_STATUS_OFFLINE)); | 974 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, pixbuf3, _("Offline"), NULL, GINT_TO_POINTER(GAIM_STATUS_OFFLINE)); |
975 | |
976 if (pixbuf2) g_object_unref(G_OBJECT(pixbuf2)); | |
977 if (pixbuf3) g_object_unref(G_OBJECT(pixbuf3)); | |
978 if (pixbuf4) g_object_unref(G_OBJECT(pixbuf4)); | |
987 } | 979 } |
988 | 980 |
989 add_popular_statuses(status_box); | 981 add_popular_statuses(status_box); |
990 | 982 |
991 gtk_gaim_status_box_add_separator(GTK_GAIM_STATUS_BOX(status_box)); | 983 gtk_gaim_status_box_add_separator(GTK_GAIM_STATUS_BOX(status_box)); |
992 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_CUSTOM, pixbuf, _("New..."), NULL, NULL); | 984 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_CUSTOM, pixbuf, _("New..."), NULL, NULL); |
993 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_SAVED, pixbuf, _("Saved..."), NULL, NULL); | 985 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_SAVED, pixbuf, _("Saved..."), NULL, NULL); |
986 if (pixbuf) g_object_unref(G_OBJECT(pixbuf)); | |
994 | 987 |
995 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); | 988 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); |
996 status_menu_refresh_iter(status_box); | 989 status_menu_refresh_iter(status_box); |
997 | 990 |
998 } else { | 991 } else { |