pidgin/gtkblist.c

branch
cpw.qulogic.gtk3
changeset 27077
e2f1821141c2
parent 26939
b0b7bd184248
parent 26871
d62964222795
child 27078
71ebf932abf3
equal deleted inserted replaced
26940:4abc42bf44e7 27077:e2f1821141c2
3900 ret = gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), icon, 3900 ret = gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), icon,
3901 icon_size, "GtkTreeView"); 3901 icon_size, "GtkTreeView");
3902 return ret; 3902 return ret;
3903 } 3903 }
3904 3904
3905 static const char *
3906 theme_font_get_color_default(PidginThemeFont *font, const char *def)
3907 {
3908 const char *ret;
3909 if (!font || !(ret = pidgin_theme_font_get_color_describe(font)))
3910 ret = def;
3911 return ret;
3912 }
3913
3914 static const char *
3915 theme_font_get_face_default(PidginThemeFont *font, const char *def)
3916 {
3917 const char *ret;
3918 if (!font || !(ret = pidgin_theme_font_get_font_face(font)))
3919 ret = def;
3920 return ret;
3921 }
3922
3905 gchar * 3923 gchar *
3906 pidgin_blist_get_name_markup(PurpleBuddy *b, gboolean selected, gboolean aliased) 3924 pidgin_blist_get_name_markup(PurpleBuddy *b, gboolean selected, gboolean aliased)
3907 { 3925 {
3908 const char *name, *name_color, *name_font, *status_color, *status_font; 3926 const char *name, *name_color, *name_font, *status_color, *status_font;
3909 char *text = NULL; 3927 char *text = NULL;
3914 struct _pidgin_blist_node *gtkcontactnode = NULL; 3932 struct _pidgin_blist_node *gtkcontactnode = NULL;
3915 char *idletime = NULL, *statustext = NULL, *nametext = NULL; 3933 char *idletime = NULL, *statustext = NULL, *nametext = NULL;
3916 PurpleConversation *conv = find_conversation_with_buddy(b); 3934 PurpleConversation *conv = find_conversation_with_buddy(b);
3917 gboolean hidden_conv = FALSE; 3935 gboolean hidden_conv = FALSE;
3918 gboolean biglist = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons"); 3936 gboolean biglist = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons");
3919 FontColorPair *pair = NULL; 3937 PidginThemeFont *statusfont = NULL, *namefont = NULL;
3920 PidginBlistTheme *theme; 3938 PidginBlistTheme *theme;
3921 3939
3922 if (conv != NULL) { 3940 if (conv != NULL) {
3923 PidginBlistNode *ui = b->node.ui_data; 3941 PidginBlistNode *ui = b->node.ui_data;
3924 if (ui) { 3942 if (ui) {
4032 } 4050 }
4033 } 4051 }
4034 4052
4035 /* choose the colors of the text */ 4053 /* choose the colors of the text */
4036 theme = pidgin_blist_get_theme(); 4054 theme = pidgin_blist_get_theme();
4037 4055 name_color = NULL;
4038 if (purple_presence_is_idle(presence)) { 4056
4039 if (theme) 4057 if (theme) {
4040 pair = pidgin_blist_theme_get_idle_text_info(theme); 4058 if (purple_presence_is_idle(presence)) {
4041 status_color = name_color = (pair != NULL && pair->color != NULL) ? pair->color : "dim grey"; 4059 namefont = statusfont = pidgin_blist_theme_get_idle_text_info(theme);
4042 status_font = name_font = (pair != NULL && pair->font != NULL) ? pair->font : ""; 4060 name_color = "dim grey";
4043 4061 } else if (!purple_presence_is_online(presence)) {
4044 } else if (!purple_presence_is_online(presence)) { 4062 namefont = pidgin_blist_theme_get_offline_text_info(theme);
4045 if (theme) 4063 statusfont = pidgin_blist_theme_get_status_text_info(theme);
4046 pair = pidgin_blist_theme_get_offline_text_info(theme); 4064 } else if (purple_presence_is_available(presence)) {
4047 name_color = (pair != NULL && pair->color != NULL) ? pair->color : NULL; 4065 namefont = pidgin_blist_theme_get_online_text_info(theme);
4048 name_font = (pair != NULL && pair->font != NULL) ? pair->font : ""; 4066 statusfont = pidgin_blist_theme_get_status_text_info(theme);
4049 4067 } else {
4050 if (theme) 4068 namefont = pidgin_blist_theme_get_away_text_info(theme);
4051 pair = pidgin_blist_theme_get_status_text_info(theme); 4069 statusfont = pidgin_blist_theme_get_status_text_info(theme);
4052 status_color = (pair != NULL && pair->color != NULL) ? pair->color : "dim grey"; 4070 }
4053 status_font = (pair != NULL && pair->font != NULL) ? pair->font : ""; 4071 }
4054 4072
4055 } else if (purple_presence_is_available(presence)) { 4073 name_color = theme_font_get_color_default(namefont, name_color);
4056 if (theme) 4074 name_font = theme_font_get_face_default(namefont, "");
4057 pair = pidgin_blist_theme_get_online_text_info(theme); 4075
4058 name_color = (pair != NULL && pair->color != NULL) ? pair->color : NULL; 4076 status_color = theme_font_get_color_default(statusfont, "dim grey");
4059 name_font = (pair != NULL && pair->font != NULL) ? pair->font : ""; 4077 status_font = theme_font_get_face_default(statusfont, "");
4060
4061 if (theme)
4062 pair = pidgin_blist_theme_get_status_text_info(theme);
4063 status_color = (pair != NULL && pair->color != NULL) ? pair->color : "dim grey";
4064 status_font = (pair != NULL && pair->font != NULL) ? pair->font : "";
4065
4066 } else {
4067 if (theme)
4068 pair = pidgin_blist_theme_get_away_text_info(theme);
4069 name_color = (pair != NULL && pair->color != NULL) ? pair->color : NULL;
4070 name_font = (pair != NULL && pair->font != NULL) ? pair->font : "";
4071
4072 if (theme)
4073 pair = pidgin_blist_theme_get_status_text_info(theme);
4074 status_color = (pair != NULL && pair->color != NULL) ? pair->color : "dim grey";
4075 status_font = (pair != NULL && pair->font != NULL) ? pair->font : "";
4076 }
4077 4078
4078 if (aliased && selected) { 4079 if (aliased && selected) {
4079 if (theme) { 4080 if (theme) {
4080 name_color = "black"; 4081 name_color = "black";
4081 status_color = "black"; 4082 status_color = "black";
4649 pidgin_blist_select_notebook_page(gtkblist); 4650 pidgin_blist_select_notebook_page(gtkblist);
4650 update_menu_bar(gtkblist); 4651 update_menu_bar(gtkblist);
4651 } 4652 }
4652 4653
4653 static void 4654 static void
4655 account_actions_changed(PurpleAccount *account, gpointer data)
4656 {
4657 pidgin_blist_update_accounts_menu();
4658 }
4659
4660 static void
4654 account_status_changed(PurpleAccount *account, PurpleStatus *old, 4661 account_status_changed(PurpleAccount *account, PurpleStatus *old,
4655 PurpleStatus *new, PidginBuddyList *gtkblist) 4662 PurpleStatus *new, PidginBuddyList *gtkblist)
4656 { 4663 {
4657 if (!gtkblist) 4664 if (!gtkblist)
4658 return; 4665 return;
5838 PURPLE_CALLBACK(account_status_changed), 5845 PURPLE_CALLBACK(account_status_changed),
5839 gtkblist); 5846 gtkblist);
5840 purple_signal_connect(handle, "account-error-changed", gtkblist, 5847 purple_signal_connect(handle, "account-error-changed", gtkblist,
5841 PURPLE_CALLBACK(update_account_error_state), 5848 PURPLE_CALLBACK(update_account_error_state),
5842 gtkblist); 5849 gtkblist);
5850 purple_signal_connect(handle, "account-actions-changed", gtkblist,
5851 PURPLE_CALLBACK(account_actions_changed), NULL);
5843 5852
5844 handle = pidgin_account_get_handle(); 5853 handle = pidgin_account_get_handle();
5845 purple_signal_connect(handle, "account-modified", gtkblist, 5854 purple_signal_connect(handle, "account-modified", gtkblist,
5846 PURPLE_CALLBACK(account_modified), gtkblist); 5855 PURPLE_CALLBACK(account_modified), gtkblist);
5847 5856
6198 gboolean selected; 6207 gboolean selected;
6199 char group_count[12] = ""; 6208 char group_count[12] = "";
6200 char *mark, *esc; 6209 char *mark, *esc;
6201 PurpleBlistNode *selected_node = NULL; 6210 PurpleBlistNode *selected_node = NULL;
6202 GtkTreeIter iter; 6211 GtkTreeIter iter;
6203 FontColorPair *pair; 6212 PidginThemeFont *pair;
6204 gchar const *text_color, *text_font; 6213 gchar const *text_color, *text_font;
6205 PidginBlistTheme *theme; 6214 PidginBlistTheme *theme;
6206 6215
6207 group = (PurpleGroup*)gnode; 6216 group = (PurpleGroup*)gnode;
6208 6217
6225 pair = pidgin_blist_theme_get_expanded_text_info(theme); 6234 pair = pidgin_blist_theme_get_expanded_text_info(theme);
6226 else 6235 else
6227 pair = pidgin_blist_theme_get_collapsed_text_info(theme); 6236 pair = pidgin_blist_theme_get_collapsed_text_info(theme);
6228 6237
6229 6238
6230 text_color = (selected || pair == NULL || pair->color == NULL) ? NULL : pair->color; 6239 text_color = selected ? NULL : theme_font_get_color_default(pair, NULL);
6231 text_font = (pair == NULL || pair->font == NULL) ? "" : pair->font; 6240 text_font = theme_font_get_face_default(pair, "");
6232 6241
6233 esc = g_markup_escape_text(group->name, -1); 6242 esc = g_markup_escape_text(group->name, -1);
6234 if (text_color) { 6243 if (text_color) {
6235 mark = g_strdup_printf("<span foreground='%s' font_desc='%s'><b>%s</b>%s</span>", 6244 mark = g_strdup_printf("<span foreground='%s' font_desc='%s'><b>%s</b>%s</span>",
6236 text_color, text_font, esc ? esc : "", group_count); 6245 text_color, text_font, esc ? esc : "", group_count);
6284 { 6293 {
6285 time_t idle_secs = purple_presence_get_idle_time(presence); 6294 time_t idle_secs = purple_presence_get_idle_time(presence);
6286 6295
6287 if (idle_secs > 0) 6296 if (idle_secs > 0)
6288 { 6297 {
6289 FontColorPair *pair = NULL; 6298 PidginThemeFont *pair = NULL;
6290 const gchar *textcolor; 6299 const gchar *textcolor;
6291 time_t t; 6300 time_t t;
6292 int ihrs, imin; 6301 int ihrs, imin;
6293 time(&t); 6302 time(&t);
6294 6303
6295 ihrs = (t - idle_secs) / 3600; 6304 ihrs = (t - idle_secs) / 3600;
6296 imin = ((t - idle_secs) / 60) % 60; 6305 imin = ((t - idle_secs) / 60) % 60;
6297 6306
6298 if (!selected && theme != NULL && (pair = pidgin_blist_theme_get_idle_text_info(theme)) != NULL && pair->color != NULL) 6307 if (!selected && theme != NULL && (pair = pidgin_blist_theme_get_idle_text_info(theme)) != NULL)
6299 textcolor = pair->color; 6308 textcolor = pidgin_theme_font_get_color_describe(pair);
6300 else 6309 else
6301 textcolor = NULL; 6310 textcolor = NULL;
6302 6311
6303 if (textcolor) { 6312 if (textcolor) {
6304 idle = g_strdup_printf("<span color='%s' font_desc='%s'>%d:%02d</span>", 6313 idle = g_strdup_printf("<span color='%s' font_desc='%s'>%d:%02d</span>",
6305 textcolor, (pair == NULL || pair->font == NULL) ? "" : pair->font, 6314 textcolor, theme_font_get_face_default(pair, ""),
6306 ihrs, imin); 6315 ihrs, imin);
6307 } else { 6316 } else {
6308 idle = g_strdup_printf("<span font_desc='%s'>%d:%02d</span>", 6317 idle = g_strdup_printf("<span font_desc='%s'>%d:%02d</span>",
6309 (pair == NULL || pair->font == NULL) ? "" : pair->font, 6318 theme_font_get_face_default(pair, ""),
6310 ihrs, imin); 6319 ihrs, imin);
6311 } 6320 }
6312 } 6321 }
6313 } 6322 }
6314 6323
6389 GdkPixbuf *status; 6398 GdkPixbuf *status;
6390 gchar *mark, *tmp; 6399 gchar *mark, *tmp;
6391 const gchar *fg_color, *font; 6400 const gchar *fg_color, *font;
6392 GdkColor *color = NULL; 6401 GdkColor *color = NULL;
6393 PidginBlistTheme *theme = pidgin_blist_get_theme(); 6402 PidginBlistTheme *theme = pidgin_blist_get_theme();
6394 FontColorPair *pair; 6403 PidginThemeFont *pair;
6395 gboolean selected = (gtkblist->selected_node == cnode); 6404 gboolean selected = (gtkblist->selected_node == cnode);
6396 6405
6397 mark = g_markup_escape_text(purple_contact_get_alias(contact), -1); 6406 mark = g_markup_escape_text(purple_contact_get_alias(contact), -1);
6398 6407
6399 theme = pidgin_blist_get_theme(); 6408 theme = pidgin_blist_get_theme();
6402 else { 6411 else {
6403 pair = pidgin_blist_theme_get_contact_text_info(theme); 6412 pair = pidgin_blist_theme_get_contact_text_info(theme);
6404 color = pidgin_blist_theme_get_contact_color(theme); 6413 color = pidgin_blist_theme_get_contact_color(theme);
6405 } 6414 }
6406 6415
6407 font = (pair == NULL || pair->font == NULL) ? "" : pair->font; 6416 font = theme_font_get_face_default(pair, "");
6408 fg_color = (selected || pair == NULL || pair->color == NULL) ? NULL : pair->color; 6417 fg_color = selected ? NULL : theme_font_get_color_default(pair, NULL);
6409 6418
6410 if (fg_color) { 6419 if (fg_color) {
6411 tmp = g_strdup_printf("<span font_desc='%s' color='%s'>%s</span>", 6420 tmp = g_strdup_printf("<span font_desc='%s' color='%s'>%s</span>",
6412 font, fg_color, mark); 6421 font, fg_color, mark);
6413 } else { 6422 } else {
6500 gboolean biglist = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons"); 6509 gboolean biglist = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons");
6501 PidginBlistNode *ui; 6510 PidginBlistNode *ui;
6502 PurpleConversation *conv; 6511 PurpleConversation *conv;
6503 gboolean hidden = FALSE; 6512 gboolean hidden = FALSE;
6504 GdkColor *bgcolor = NULL; 6513 GdkColor *bgcolor = NULL;
6505 FontColorPair *pair; 6514 PidginThemeFont *pair;
6506 PidginBlistTheme *theme; 6515 PidginBlistTheme *theme;
6507 gboolean selected = (gtkblist->selected_node == node); 6516 gboolean selected = (gtkblist->selected_node == node);
6508 gboolean nick_said = FALSE; 6517 gboolean nick_said = FALSE;
6509 6518
6510 if (!insert_node(list, node, &iter)) 6519 if (!insert_node(list, node, &iter))
6538 else if (hidden) 6547 else if (hidden)
6539 pair = pidgin_blist_theme_get_unread_message_text_info(theme); 6548 pair = pidgin_blist_theme_get_unread_message_text_info(theme);
6540 else pair = pidgin_blist_theme_get_online_text_info(theme); 6549 else pair = pidgin_blist_theme_get_online_text_info(theme);
6541 6550
6542 6551
6543 font = (pair == NULL || pair->font == NULL) ? "" : pair->font; 6552 font = theme_font_get_face_default(pair, "");
6544 if (selected || pair == NULL || pair->color == NULL) 6553 if (selected || !(color = theme_font_get_color_default(pair, NULL)))
6545 /* nick_said color is the same as gtkconv:tab-label-attention */ 6554 /* nick_said color is the same as gtkconv:tab-label-attention */
6546 color = (nick_said ? "#006aff" : NULL); 6555 color = (nick_said ? "#006aff" : NULL);
6547 else
6548 color = pair->color;
6549 6556
6550 if (color) { 6557 if (color) {
6551 tmp = g_strdup_printf("<span font_desc='%s' color='%s' weight='%s'>%s</span>", 6558 tmp = g_strdup_printf("<span font_desc='%s' color='%s' weight='%s'>%s</span>",
6552 font, color, hidden ? "bold" : "normal", mark); 6559 font, color, hidden ? "bold" : "normal", mark);
6553 } else { 6560 } else {

mercurial