Mercurial > pidgin.yaz
comparison pidgin/gtkstatusbox.c @ 26817:3912f55a1633
propagate from branch 'im.pidgin.pidgin' (head fbb4fe5da444943eecc76bdcd6c8ba967790b6c8)
to branch 'im.pidgin.cpw.darkrain42.xmpp.bosh' (head 601bc627c9430320848361f0ed81c6c4c6ee53e0)
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Tue, 28 Apr 2009 18:43:57 +0000 |
parents | f7b409c896cd |
children | 12fdc06d73be |
comparison
equal
deleted
inserted
replaced
26743:de9816c970fe | 26817:3912f55a1633 |
---|---|
96 | 96 |
97 enum { | 97 enum { |
98 /** A PidginStatusBoxItemType */ | 98 /** A PidginStatusBoxItemType */ |
99 TYPE_COLUMN, | 99 TYPE_COLUMN, |
100 | 100 |
101 /** This is the stock-id for the icon. */ | |
102 ICON_STOCK_COLUMN, | |
103 | |
101 /** | 104 /** |
102 * This is a GdkPixbuf (the other columns are strings). | 105 * This is a GdkPixbuf (the other columns are strings). |
103 * This column is visible. | 106 * This column is visible. |
104 */ | 107 */ |
105 ICON_COLUMN, | 108 ICON_COLUMN, |
534 if (statusbox->active_row) | 537 if (statusbox->active_row) |
535 gtk_tree_row_reference_free(statusbox->active_row); | 538 gtk_tree_row_reference_free(statusbox->active_row); |
536 | 539 |
537 for (i = 0; i < G_N_ELEMENTS(statusbox->connecting_pixbufs); i++) { | 540 for (i = 0; i < G_N_ELEMENTS(statusbox->connecting_pixbufs); i++) { |
538 if (statusbox->connecting_pixbufs[i] != NULL) | 541 if (statusbox->connecting_pixbufs[i] != NULL) |
539 gdk_pixbuf_unref(statusbox->connecting_pixbufs[i]); | 542 g_object_unref(G_OBJECT(statusbox->connecting_pixbufs[i])); |
540 } | 543 } |
541 | 544 |
542 for (i = 0; i < G_N_ELEMENTS(statusbox->typing_pixbufs); i++) { | 545 for (i = 0; i < G_N_ELEMENTS(statusbox->typing_pixbufs); i++) { |
543 if (statusbox->typing_pixbufs[i] != NULL) | 546 if (statusbox->typing_pixbufs[i] != NULL) |
544 gdk_pixbuf_unref(statusbox->typing_pixbufs[i]); | 547 g_object_unref(G_OBJECT(statusbox->typing_pixbufs[i])); |
545 } | 548 } |
546 | 549 |
547 g_object_unref(G_OBJECT(statusbox->store)); | 550 g_object_unref(G_OBJECT(statusbox->store)); |
548 g_object_unref(G_OBJECT(statusbox->dropdown_store)); | 551 g_object_unref(G_OBJECT(statusbox->dropdown_store)); |
549 G_OBJECT_CLASS(parent_class)->finalize(obj); | 552 G_OBJECT_CLASS(parent_class)->finalize(obj); |
598 ) | 601 ) |
599 ); | 602 ); |
600 } | 603 } |
601 | 604 |
602 static GdkPixbuf * | 605 static GdkPixbuf * |
603 pidgin_status_box_get_pixbuf(PidginStatusBox *status_box, PurpleStatusPrimitive prim) | 606 pidgin_status_box_get_pixbuf(PidginStatusBox *status_box, const char *stock) |
604 { | 607 { |
605 GdkPixbuf *pixbuf; | 608 GdkPixbuf *pixbuf; |
606 GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); | 609 GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); |
607 if (prim == PURPLE_STATUS_UNAVAILABLE) | 610 |
608 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), PIDGIN_STOCK_STATUS_BUSY, | 611 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), stock, |
609 icon_size, "PidginStatusBox"); | 612 icon_size, "PidginStatusBox"); |
610 else if (prim == PURPLE_STATUS_AWAY) | 613 |
611 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), PIDGIN_STOCK_STATUS_AWAY, | |
612 icon_size, "PidginStatusBox"); | |
613 else if (prim == PURPLE_STATUS_EXTENDED_AWAY) | |
614 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), PIDGIN_STOCK_STATUS_XA, | |
615 icon_size, "PidginStatusBox"); | |
616 else if (prim == PURPLE_STATUS_INVISIBLE) | |
617 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), PIDGIN_STOCK_STATUS_INVISIBLE, | |
618 icon_size, "PidginStatusBox"); | |
619 else if (prim == PURPLE_STATUS_OFFLINE) | |
620 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), PIDGIN_STOCK_STATUS_OFFLINE, | |
621 icon_size, "PidginStatusBox"); | |
622 else | |
623 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), PIDGIN_STOCK_STATUS_AVAILABLE, | |
624 icon_size, "PidginStatusBox"); | |
625 return pixbuf; | 614 return pixbuf; |
626 } | 615 } |
627 | 616 |
628 /** | 617 /** |
629 * This updates the text displayed on the status box so that it shows | 618 * This updates the text displayed on the status box so that it shows |
636 GtkIconSize icon_size; | 625 GtkIconSize icon_size; |
637 GtkStyle *style; | 626 GtkStyle *style; |
638 char aa_color[8]; | 627 char aa_color[8]; |
639 PurpleSavedStatus *saved_status; | 628 PurpleSavedStatus *saved_status; |
640 char *primary, *secondary, *text; | 629 char *primary, *secondary, *text; |
641 GdkPixbuf *pixbuf, *emblem = NULL; | 630 const char *stock = NULL; |
631 GdkPixbuf *pixbuf = NULL, *emblem = NULL; | |
642 GtkTreePath *path; | 632 GtkTreePath *path; |
643 gboolean account_status = FALSE; | 633 gboolean account_status = FALSE; |
644 PurpleAccount *acct = (status_box->account) ? status_box->account : status_box->token_status_account; | 634 PurpleAccount *acct = (status_box->account) ? status_box->account : status_box->token_status_account; |
645 | 635 |
646 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); | 636 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); |
720 else | 710 else |
721 { | 711 { |
722 PurpleStatusType *status_type; | 712 PurpleStatusType *status_type; |
723 PurpleStatusPrimitive prim; | 713 PurpleStatusPrimitive prim; |
724 if (account_status) { | 714 if (account_status) { |
725 status_type = purple_status_get_type(purple_account_get_active_status(acct)); | 715 status_type = purple_status_get_type(purple_account_get_active_status(acct)); |
726 prim = purple_status_type_get_primitive(status_type); | 716 prim = purple_status_type_get_primitive(status_type); |
727 } else { | 717 } else { |
728 prim = purple_savedstatus_get_type(saved_status); | 718 prim = purple_savedstatus_get_type(saved_status); |
729 } | 719 } |
730 | 720 |
731 pixbuf = pidgin_status_box_get_pixbuf(status_box, prim); | 721 stock = pidgin_stock_id_from_status_primitive(prim); |
722 if (stock) | |
723 pixbuf = pidgin_status_box_get_pixbuf(status_box, stock); | |
732 } | 724 } |
733 | 725 |
734 if (status_box->account != NULL) { | 726 if (status_box->account != NULL) { |
735 text = g_strdup_printf("%s - <span size=\"smaller\" color=\"%s\">%s</span>", | 727 text = g_strdup_printf("%s - <span size=\"smaller\" color=\"%s\">%s</span>", |
736 purple_account_get_username(status_box->account), | 728 purple_account_get_username(status_box->account), |
748 /* | 740 /* |
749 * Only two columns are used in this list store (does it | 741 * Only two columns are used in this list store (does it |
750 * really need to be a list store?) | 742 * really need to be a list store?) |
751 */ | 743 */ |
752 gtk_list_store_set(status_box->store, &(status_box->iter), | 744 gtk_list_store_set(status_box->store, &(status_box->iter), |
745 ICON_STOCK_COLUMN, (gpointer)stock, | |
753 ICON_COLUMN, pixbuf, | 746 ICON_COLUMN, pixbuf, |
754 TEXT_COLUMN, text, | 747 TEXT_COLUMN, text, |
755 EMBLEM_COLUMN, emblem, | 748 EMBLEM_COLUMN, emblem, |
756 EMBLEM_VISIBLE_COLUMN, (emblem != NULL), | 749 EMBLEM_VISIBLE_COLUMN, (emblem != NULL), |
757 -1); | 750 -1); |
758 if ((status_box->typing == 0) && (!status_box->connecting)) | 751 if (pixbuf && (status_box->typing == 0) && (!status_box->connecting)) |
759 g_object_unref(pixbuf); | 752 g_object_unref(pixbuf); |
760 g_free(text); | 753 g_free(text); |
761 if (emblem) | 754 if (emblem) |
762 g_object_unref(emblem); | 755 g_object_unref(emblem); |
763 | 756 |
922 | 915 |
923 static void | 916 static void |
924 add_popular_statuses(PidginStatusBox *statusbox) | 917 add_popular_statuses(PidginStatusBox *statusbox) |
925 { | 918 { |
926 GList *list, *cur; | 919 GList *list, *cur; |
927 GdkPixbuf *pixbuf; | |
928 | 920 |
929 list = purple_savedstatuses_get_popular(6); | 921 list = purple_savedstatuses_get_popular(6); |
930 if (list == NULL) | 922 if (list == NULL) |
931 /* Odd... oh well, nothing we can do about it. */ | 923 /* Odd... oh well, nothing we can do about it. */ |
932 return; | 924 return; |
941 PurpleStatusPrimitive prim; | 933 PurpleStatusPrimitive prim; |
942 PidginStatusBoxItemType type = PIDGIN_STATUS_BOX_TYPE_POPULAR; | 934 PidginStatusBoxItemType type = PIDGIN_STATUS_BOX_TYPE_POPULAR; |
943 | 935 |
944 /* Get an appropriate status icon */ | 936 /* Get an appropriate status icon */ |
945 prim = purple_savedstatus_get_type(saved); | 937 prim = purple_savedstatus_get_type(saved); |
946 | |
947 | |
948 pixbuf = pidgin_status_box_get_pixbuf(statusbox, prim); | |
949 | 938 |
950 if (purple_savedstatus_is_transient(saved)) | 939 if (purple_savedstatus_is_transient(saved)) |
951 { | 940 { |
952 /* | 941 /* |
953 * Transient statuses do not have a title, so the savedstatus | 942 * Transient statuses do not have a title, so the savedstatus |
965 } | 954 } |
966 type = PIDGIN_STATUS_BOX_TYPE_SAVED_POPULAR; | 955 type = PIDGIN_STATUS_BOX_TYPE_SAVED_POPULAR; |
967 } | 956 } |
968 | 957 |
969 pidgin_status_box_add(statusbox, type, | 958 pidgin_status_box_add(statusbox, type, |
970 pixbuf, purple_savedstatus_get_title(saved), stripped, | 959 NULL, purple_savedstatus_get_title(saved), stripped, |
971 GINT_TO_POINTER(purple_savedstatus_get_creation_time(saved))); | 960 GINT_TO_POINTER(purple_savedstatus_get_creation_time(saved))); |
972 g_free(stripped); | 961 g_free(stripped); |
973 if (pixbuf != NULL) | |
974 g_object_unref(G_OBJECT(pixbuf)); | |
975 } | 962 } |
976 | 963 |
977 g_list_free(list); | 964 g_list_free(list); |
978 } | 965 } |
979 | 966 |
1030 static void | 1017 static void |
1031 add_account_statuses(PidginStatusBox *status_box, PurpleAccount *account) | 1018 add_account_statuses(PidginStatusBox *status_box, PurpleAccount *account) |
1032 { | 1019 { |
1033 /* Per-account */ | 1020 /* Per-account */ |
1034 GList *l; | 1021 GList *l; |
1035 GdkPixbuf *pixbuf; | |
1036 | 1022 |
1037 for (l = purple_account_get_status_types(account); l != NULL; l = l->next) | 1023 for (l = purple_account_get_status_types(account); l != NULL; l = l->next) |
1038 { | 1024 { |
1039 PurpleStatusType *status_type = (PurpleStatusType *)l->data; | 1025 PurpleStatusType *status_type = (PurpleStatusType *)l->data; |
1040 PurpleStatusPrimitive prim; | 1026 PurpleStatusPrimitive prim; |
1043 purple_status_type_is_independent(status_type)) | 1029 purple_status_type_is_independent(status_type)) |
1044 continue; | 1030 continue; |
1045 | 1031 |
1046 prim = purple_status_type_get_primitive(status_type); | 1032 prim = purple_status_type_get_primitive(status_type); |
1047 | 1033 |
1048 pixbuf = pidgin_status_box_get_pixbuf(status_box, prim); | |
1049 | |
1050 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), | 1034 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), |
1051 PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf, | 1035 PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, NULL, |
1052 purple_status_type_get_name(status_type), | 1036 purple_status_type_get_name(status_type), |
1053 NULL, | 1037 NULL, |
1054 GINT_TO_POINTER(purple_status_type_get_primitive(status_type))); | 1038 GINT_TO_POINTER(purple_status_type_get_primitive(status_type))); |
1055 if (pixbuf != NULL) | |
1056 g_object_unref(pixbuf); | |
1057 } | 1039 } |
1058 } | 1040 } |
1059 | 1041 |
1060 static void | 1042 static void |
1061 pidgin_status_box_regenerate(PidginStatusBox *status_box) | 1043 pidgin_status_box_regenerate(PidginStatusBox *status_box) |
1062 { | 1044 { |
1063 GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4, *pixbuf5; | |
1064 GtkIconSize icon_size; | 1045 GtkIconSize icon_size; |
1065 | 1046 |
1066 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); | 1047 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); |
1067 | 1048 |
1068 /* Unset the model while clearing it */ | 1049 /* Unset the model while clearing it */ |
1073 * if we do this here. */ | 1054 * if we do this here. */ |
1074 /* gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); */ | 1055 /* gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); */ |
1075 | 1056 |
1076 if (status_box->account == NULL) | 1057 if (status_box->account == NULL) |
1077 { | 1058 { |
1078 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_AVAILABLE, | |
1079 icon_size, "PidginStatusBox"); | |
1080 /* Do all the currently enabled accounts have the same statuses? | 1059 /* Do all the currently enabled accounts have the same statuses? |
1081 * If so, display them instead of our global list. | 1060 * If so, display them instead of our global list. |
1082 */ | 1061 */ |
1083 if (status_box->token_status_account) { | 1062 if (status_box->token_status_account) { |
1084 add_account_statuses(status_box, status_box->token_status_account); | 1063 add_account_statuses(status_box, status_box->token_status_account); |
1085 } else { | 1064 } else { |
1086 /* Global */ | 1065 /* Global */ |
1087 pixbuf2 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_AWAY, | 1066 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, NULL, _("Available"), NULL, GINT_TO_POINTER(PURPLE_STATUS_AVAILABLE)); |
1088 icon_size, "PidginStatusBox"); | 1067 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, NULL, _("Away"), NULL, GINT_TO_POINTER(PURPLE_STATUS_AWAY)); |
1089 pixbuf3 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_OFFLINE, | 1068 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, NULL, _("Do not disturb"), NULL, GINT_TO_POINTER(PURPLE_STATUS_UNAVAILABLE)); |
1090 icon_size, "PidginStatusBox"); | 1069 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, NULL, _("Invisible"), NULL, GINT_TO_POINTER(PURPLE_STATUS_INVISIBLE)); |
1091 pixbuf4 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_INVISIBLE, | 1070 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, NULL, _("Offline"), NULL, GINT_TO_POINTER(PURPLE_STATUS_OFFLINE)); |
1092 icon_size, "PidginStatusBox"); | |
1093 pixbuf5 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_BUSY, | |
1094 icon_size, "PidginStatusBox"); | |
1095 | |
1096 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf, _("Available"), NULL, GINT_TO_POINTER(PURPLE_STATUS_AVAILABLE)); | |
1097 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf2, _("Away"), NULL, GINT_TO_POINTER(PURPLE_STATUS_AWAY)); | |
1098 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf5, _("Do not disturb"), NULL, GINT_TO_POINTER(PURPLE_STATUS_UNAVAILABLE)); | |
1099 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf4, _("Invisible"), NULL, GINT_TO_POINTER(PURPLE_STATUS_INVISIBLE)); | |
1100 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf3, _("Offline"), NULL, GINT_TO_POINTER(PURPLE_STATUS_OFFLINE)); | |
1101 | |
1102 if (pixbuf2) g_object_unref(G_OBJECT(pixbuf2)); | |
1103 if (pixbuf3) g_object_unref(G_OBJECT(pixbuf3)); | |
1104 if (pixbuf4) g_object_unref(G_OBJECT(pixbuf4)); | |
1105 if (pixbuf5) g_object_unref(G_OBJECT(pixbuf5)); | |
1106 } | 1071 } |
1107 | 1072 |
1108 add_popular_statuses(status_box); | 1073 add_popular_statuses(status_box); |
1109 | 1074 |
1110 pidgin_status_box_add_separator(PIDGIN_STATUS_BOX(status_box)); | 1075 pidgin_status_box_add_separator(PIDGIN_STATUS_BOX(status_box)); |
1111 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_CUSTOM, NULL, _("New status..."), NULL, NULL); | 1076 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_CUSTOM, NULL, _("New status..."), NULL, NULL); |
1112 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_SAVED, NULL, _("Saved statuses..."), NULL, NULL); | 1077 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_SAVED, NULL, _("Saved statuses..."), NULL, NULL); |
1113 if (pixbuf) g_object_unref(G_OBJECT(pixbuf)); | |
1114 | 1078 |
1115 status_menu_refresh_iter(status_box); | 1079 status_menu_refresh_iter(status_box); |
1116 pidgin_status_box_refresh(status_box); | 1080 pidgin_status_box_refresh(status_box); |
1117 | 1081 |
1118 } else { | 1082 } else { |
1200 g_object_set(G_OBJECT(status_box->icon_rend), "xpad", 3, NULL); | 1164 g_object_set(G_OBJECT(status_box->icon_rend), "xpad", 3, NULL); |
1201 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); | 1165 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); |
1202 | 1166 |
1203 for (i = 0; i < G_N_ELEMENTS(status_box->connecting_pixbufs); i++) { | 1167 for (i = 0; i < G_N_ELEMENTS(status_box->connecting_pixbufs); i++) { |
1204 if (status_box->connecting_pixbufs[i] != NULL) | 1168 if (status_box->connecting_pixbufs[i] != NULL) |
1205 gdk_pixbuf_unref(status_box->connecting_pixbufs[i]); | 1169 g_object_unref(G_OBJECT(status_box->connecting_pixbufs[i])); |
1206 } | 1170 } |
1207 | 1171 |
1208 status_box->connecting_index = 0; | 1172 status_box->connecting_index = 0; |
1209 | 1173 |
1210 #define CACHE_ANIMATION_CONNECT(index) \ | 1174 #define CACHE_ANIMATION_CONNECT(index) \ |
1223 | 1187 |
1224 #undef CACHE_ANIMATION_CONNECT | 1188 #undef CACHE_ANIMATION_CONNECT |
1225 | 1189 |
1226 for (i = 0; i < G_N_ELEMENTS(status_box->typing_pixbufs); i++) { | 1190 for (i = 0; i < G_N_ELEMENTS(status_box->typing_pixbufs); i++) { |
1227 if (status_box->typing_pixbufs[i] != NULL) | 1191 if (status_box->typing_pixbufs[i] != NULL) |
1228 gdk_pixbuf_unref(status_box->typing_pixbufs[i]); | 1192 g_object_unref(G_OBJECT(status_box->typing_pixbufs[i])); |
1229 } | 1193 } |
1230 | 1194 |
1231 status_box->typing_index = 0; | 1195 status_box->typing_index = 0; |
1232 | 1196 |
1233 #define CACHE_ANIMATION_TYPING(index) \ | 1197 #define CACHE_ANIMATION_TYPING(index) \ |
1776 status_box->hbox = gtk_hbox_new(FALSE, 6); | 1740 status_box->hbox = gtk_hbox_new(FALSE, 6); |
1777 status_box->cell_view = gtk_cell_view_new(); | 1741 status_box->cell_view = gtk_cell_view_new(); |
1778 status_box->vsep = gtk_vseparator_new(); | 1742 status_box->vsep = gtk_vseparator_new(); |
1779 status_box->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); | 1743 status_box->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); |
1780 | 1744 |
1781 status_box->store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, | 1745 status_box->store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, |
1782 G_TYPE_STRING, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN); | 1746 G_TYPE_STRING, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN); |
1783 status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, | 1747 status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING, |
1784 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_BOOLEAN); | 1748 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_BOOLEAN); |
1785 | 1749 |
1786 gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store)); | 1750 gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store)); |
1787 gtk_list_store_append(status_box->store, &(status_box->iter)); | 1751 gtk_list_store_append(status_box->store, &(status_box->iter)); |
1788 | 1752 |
1853 gtk_tree_view_append_column (GTK_TREE_VIEW (status_box->tree_view), | 1817 gtk_tree_view_append_column (GTK_TREE_VIEW (status_box->tree_view), |
1854 status_box->column); | 1818 status_box->column); |
1855 gtk_tree_view_column_pack_start(status_box->column, icon_rend, FALSE); | 1819 gtk_tree_view_column_pack_start(status_box->column, icon_rend, FALSE); |
1856 gtk_tree_view_column_pack_start(status_box->column, text_rend, TRUE); | 1820 gtk_tree_view_column_pack_start(status_box->column, text_rend, TRUE); |
1857 gtk_tree_view_column_pack_start(status_box->column, emblem_rend, FALSE); | 1821 gtk_tree_view_column_pack_start(status_box->column, emblem_rend, FALSE); |
1858 gtk_tree_view_column_set_attributes(status_box->column, icon_rend, "pixbuf", ICON_COLUMN, NULL); | 1822 gtk_tree_view_column_set_attributes(status_box->column, icon_rend, "pixbuf", ICON_COLUMN, "stock-id", ICON_STOCK_COLUMN, NULL); |
1859 gtk_tree_view_column_set_attributes(status_box->column, text_rend, "markup", TEXT_COLUMN, NULL); | 1823 gtk_tree_view_column_set_attributes(status_box->column, text_rend, "markup", TEXT_COLUMN, NULL); |
1860 gtk_tree_view_column_set_attributes(status_box->column, emblem_rend, "stock-id", EMBLEM_COLUMN, "visible", EMBLEM_VISIBLE_COLUMN, NULL); | 1824 gtk_tree_view_column_set_attributes(status_box->column, emblem_rend, "stock-id", EMBLEM_COLUMN, "visible", EMBLEM_VISIBLE_COLUMN, NULL); |
1861 gtk_container_add(GTK_CONTAINER(status_box->scrolled_window), status_box->tree_view); | 1825 gtk_container_add(GTK_CONTAINER(status_box->scrolled_window), status_box->tree_view); |
1862 gtk_widget_show(status_box->tree_view); | 1826 gtk_widget_show(status_box->tree_view); |
1863 gtk_tree_view_set_search_column(GTK_TREE_VIEW(status_box->tree_view), TEXT_COLUMN); | 1827 gtk_tree_view_set_search_column(GTK_TREE_VIEW(status_box->tree_view), TEXT_COLUMN); |
1872 status_box->text_rend = gtk_cell_renderer_text_new(); | 1836 status_box->text_rend = gtk_cell_renderer_text_new(); |
1873 emblem_rend = gtk_cell_renderer_pixbuf_new(); | 1837 emblem_rend = gtk_cell_renderer_pixbuf_new(); |
1874 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE); | 1838 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE); |
1875 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); | 1839 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); |
1876 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), emblem_rend, FALSE); | 1840 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), emblem_rend, FALSE); |
1877 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, NULL); | 1841 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, "stock-id", ICON_STOCK_COLUMN, NULL); |
1878 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); | 1842 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); |
1879 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), emblem_rend, "pixbuf", EMBLEM_COLUMN, "visible", EMBLEM_VISIBLE_COLUMN, NULL); | 1843 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), emblem_rend, "pixbuf", EMBLEM_COLUMN, "visible", EMBLEM_VISIBLE_COLUMN, NULL); |
1880 #if GTK_CHECK_VERSION(2, 6, 0) | 1844 #if GTK_CHECK_VERSION(2, 6, 0) |
1881 g_object_set(status_box->text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); | 1845 g_object_set(status_box->text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
1882 #endif | 1846 #endif |
2131 /** | 2095 /** |
2132 * Add a row to the dropdown menu. | 2096 * Add a row to the dropdown menu. |
2133 * | 2097 * |
2134 * @param status_box The status box itself. | 2098 * @param status_box The status box itself. |
2135 * @param type A PidginStatusBoxItemType. | 2099 * @param type A PidginStatusBoxItemType. |
2136 * @param pixbuf The icon to associate with this row in the menu. | 2100 * @param pixbuf The icon to associate with this row in the menu. The |
2101 * function will try to decide a pixbuf if none is given. | |
2137 * @param title The title of this item. For the primitive entries, | 2102 * @param title The title of this item. For the primitive entries, |
2138 * this is something like "Available" or "Away." For | 2103 * this is something like "Available" or "Away." For |
2139 * the saved statuses, this is something like | 2104 * the saved statuses, this is something like |
2140 * "My favorite away message!" This should be | 2105 * "My favorite away message!" This should be |
2141 * plaintext (non-markedup) (this function escapes it). | 2106 * plaintext (non-markedup) (this function escapes it). |
2147 * menu. For primitives this is the value of the | 2112 * menu. For primitives this is the value of the |
2148 * PurpleStatusPrimitive. For saved statuses this is the | 2113 * PurpleStatusPrimitive. For saved statuses this is the |
2149 * creation timestamp. | 2114 * creation timestamp. |
2150 */ | 2115 */ |
2151 void | 2116 void |
2152 pidgin_status_box_add(PidginStatusBox *status_box, PidginStatusBoxItemType type, GdkPixbuf *pixbuf, const char *title, const char *desc, gpointer data) | 2117 pidgin_status_box_add(PidginStatusBox *status_box, PidginStatusBoxItemType type, GdkPixbuf *pixbuf, |
2118 const char *title, const char *desc, gpointer data) | |
2153 { | 2119 { |
2154 GtkTreeIter iter; | 2120 GtkTreeIter iter; |
2155 char *text; | 2121 char *text; |
2122 const char *stock = NULL; | |
2156 | 2123 |
2157 if (desc == NULL) | 2124 if (desc == NULL) |
2158 { | 2125 { |
2159 text = g_markup_escape_text(title, -1); | 2126 text = g_markup_escape_text(title, -1); |
2160 } | 2127 } |
2177 aa_color, escaped_desc); | 2144 aa_color, escaped_desc); |
2178 g_free(escaped_title); | 2145 g_free(escaped_title); |
2179 g_free(escaped_desc); | 2146 g_free(escaped_desc); |
2180 } | 2147 } |
2181 | 2148 |
2149 if (!pixbuf) { | |
2150 PurpleStatusPrimitive prim = PURPLE_STATUS_UNSET; | |
2151 if (type == PIDGIN_STATUS_BOX_TYPE_PRIMITIVE) { | |
2152 prim = GPOINTER_TO_INT(data); | |
2153 } else if (type == PIDGIN_STATUS_BOX_TYPE_SAVED_POPULAR || | |
2154 type == PIDGIN_STATUS_BOX_TYPE_POPULAR) { | |
2155 PurpleSavedStatus *saved = purple_savedstatus_find_by_creation_time(GPOINTER_TO_INT(data)); | |
2156 if (saved) { | |
2157 prim = purple_savedstatus_get_type(saved); | |
2158 } | |
2159 } | |
2160 | |
2161 stock = pidgin_stock_id_from_status_primitive(prim); | |
2162 if (stock) | |
2163 pixbuf = pidgin_status_box_get_pixbuf(status_box, stock); | |
2164 } | |
2165 | |
2182 gtk_list_store_append(status_box->dropdown_store, &iter); | 2166 gtk_list_store_append(status_box->dropdown_store, &iter); |
2183 gtk_list_store_set(status_box->dropdown_store, &iter, | 2167 gtk_list_store_set(status_box->dropdown_store, &iter, |
2184 TYPE_COLUMN, type, | 2168 TYPE_COLUMN, type, |
2169 ICON_STOCK_COLUMN, stock, | |
2185 ICON_COLUMN, pixbuf, | 2170 ICON_COLUMN, pixbuf, |
2186 TEXT_COLUMN, text, | 2171 TEXT_COLUMN, text, |
2187 TITLE_COLUMN, title, | 2172 TITLE_COLUMN, title, |
2188 DESC_COLUMN, desc, | 2173 DESC_COLUMN, desc, |
2189 DATA_COLUMN, data, | 2174 DATA_COLUMN, data, |