comparison pidgin/gtkstatusbox.c @ 30909:25e200cb3532

propagate from branch 'im.pidgin.pidgin' (head dca20e09164518b0f7a773edd7e9649f41d8873d) to branch 'im.pidgin.cpw.malu.xmpp.google_refactor' (head 7823c556f2d1bbca43f5ef9f0fea30cabc5d313f)
author Marcus Lundblad <ml@update.uu.se>
date Tue, 31 Aug 2010 18:28:10 +0000
parents c9a57878ed17
children 5841cbbebc53 917c597beb97
comparison
equal deleted inserted replaced
30908:c44ec533a48c 30909:25e200cb3532
655 * should modify status_box->store 655 * should modify status_box->store
656 */ 656 */
657 static void 657 static void
658 pidgin_status_box_refresh(PidginStatusBox *status_box) 658 pidgin_status_box_refresh(PidginStatusBox *status_box)
659 { 659 {
660 GtkIconSize icon_size;
661 GtkStyle *style; 660 GtkStyle *style;
662 char aa_color[8]; 661 char aa_color[8];
663 PurpleSavedStatus *saved_status; 662 PurpleSavedStatus *saved_status;
664 char *primary, *secondary, *text; 663 char *primary, *secondary, *text;
665 const char *stock = NULL; 664 const char *stock = NULL;
666 GdkPixbuf *emblem = NULL; 665 GdkPixbuf *emblem = NULL;
667 GtkTreePath *path; 666 GtkTreePath *path;
668 gboolean account_status = FALSE; 667 gboolean account_status = FALSE;
669 PurpleAccount *acct = (status_box->account) ? status_box->account : status_box->token_status_account; 668 PurpleAccount *acct = (status_box->account) ? status_box->account : status_box->token_status_account;
670
671 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL);
672 669
673 style = gtk_widget_get_style(GTK_WIDGET(status_box)); 670 style = gtk_widget_get_style(GTK_WIDGET(status_box));
674 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", 671 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x",
675 style->text_aa[GTK_STATE_NORMAL].red >> 8, 672 style->text_aa[GTK_STATE_NORMAL].red >> 8,
676 style->text_aa[GTK_STATE_NORMAL].green >> 8, 673 style->text_aa[GTK_STATE_NORMAL].green >> 8,
967 for (cur = list; cur != NULL; cur = cur->next) 964 for (cur = list; cur != NULL; cur = cur->next)
968 { 965 {
969 PurpleSavedStatus *saved = cur->data; 966 PurpleSavedStatus *saved = cur->data;
970 const gchar *message; 967 const gchar *message;
971 gchar *stripped = NULL; 968 gchar *stripped = NULL;
972 PurpleStatusPrimitive prim; 969 PidginStatusBoxItemType type;
973 PidginStatusBoxItemType type = PIDGIN_STATUS_BOX_TYPE_POPULAR;
974
975 /* Get an appropriate status icon */
976 prim = purple_savedstatus_get_type(saved);
977 970
978 if (purple_savedstatus_is_transient(saved)) 971 if (purple_savedstatus_is_transient(saved))
979 { 972 {
980 /* 973 /*
981 * Transient statuses do not have a title, so the savedstatus 974 * Transient statuses do not have a title, so the savedstatus
982 * API returns the message when purple_savedstatus_get_title() is 975 * API returns the message when purple_savedstatus_get_title() is
983 * called, so we don't need to get the message a second time. 976 * called, so we don't need to get the message a second time.
984 */ 977 */
978 type = PIDGIN_STATUS_BOX_TYPE_POPULAR;
985 } 979 }
986 else 980 else
987 { 981 {
982 type = PIDGIN_STATUS_BOX_TYPE_SAVED_POPULAR;
983
988 message = purple_savedstatus_get_message(saved); 984 message = purple_savedstatus_get_message(saved);
989 if (message != NULL) 985 if (message != NULL)
990 { 986 {
991 stripped = purple_markup_strip_html(message); 987 stripped = purple_markup_strip_html(message);
992 purple_util_chrreplace(stripped, '\n', ' '); 988 purple_util_chrreplace(stripped, '\n', ' ');
993 } 989 }
994 type = PIDGIN_STATUS_BOX_TYPE_SAVED_POPULAR;
995 } 990 }
996 991
997 pidgin_status_box_add(statusbox, type, 992 pidgin_status_box_add(statusbox, type,
998 NULL, purple_savedstatus_get_title(saved), stripped, 993 NULL, purple_savedstatus_get_title(saved), stripped,
999 GINT_TO_POINTER(purple_savedstatus_get_creation_time(saved))); 994 GINT_TO_POINTER(purple_savedstatus_get_creation_time(saved)));
1072 1067
1073 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), 1068 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box),
1074 PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, NULL, 1069 PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, NULL,
1075 purple_status_type_get_name(status_type), 1070 purple_status_type_get_name(status_type),
1076 NULL, 1071 NULL,
1077 GINT_TO_POINTER(purple_status_type_get_primitive(status_type))); 1072 GINT_TO_POINTER(prim));
1078 } 1073 }
1079 } 1074 }
1080 1075
1081 static void 1076 static void
1082 pidgin_status_box_regenerate(PidginStatusBox *status_box, gboolean status_changed) 1077 pidgin_status_box_regenerate(PidginStatusBox *status_box, gboolean status_changed)
1083 { 1078 {
1084 GtkIconSize icon_size;
1085
1086 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL);
1087
1088 /* Unset the model while clearing it */ 1079 /* Unset the model while clearing it */
1089 gtk_tree_view_set_model(GTK_TREE_VIEW(status_box->tree_view), NULL); 1080 gtk_tree_view_set_model(GTK_TREE_VIEW(status_box->tree_view), NULL);
1090 gtk_list_store_clear(status_box->dropdown_store); 1081 gtk_list_store_clear(status_box->dropdown_store);
1091 /* Don't set the model until the new statuses have been added to the box. 1082 /* Don't set the model until the new statuses have been added to the box.
1092 * What is presumably a bug in Gtk < 2.4 causes things to get all confused 1083 * What is presumably a bug in Gtk < 2.4 causes things to get all confused