pidgin/gtkblist.c

branch
sadrul.gtkblist-theme
changeset 26803
d48e945e622f
parent 26785
a4411d5d13d1
child 26840
1a8bbe7c3c97
equal deleted inserted replaced
26802:a7048e1c0eaa 26803:d48e945e622f
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";
6194 gboolean selected; 6195 gboolean selected;
6195 char group_count[12] = ""; 6196 char group_count[12] = "";
6196 char *mark, *esc; 6197 char *mark, *esc;
6197 PurpleBlistNode *selected_node = NULL; 6198 PurpleBlistNode *selected_node = NULL;
6198 GtkTreeIter iter; 6199 GtkTreeIter iter;
6199 FontColorPair *pair; 6200 PidginThemeFont *pair;
6200 gchar const *text_color, *text_font; 6201 gchar const *text_color, *text_font;
6201 PidginBlistTheme *theme; 6202 PidginBlistTheme *theme;
6202 6203
6203 group = (PurpleGroup*)gnode; 6204 group = (PurpleGroup*)gnode;
6204 6205
6221 pair = pidgin_blist_theme_get_expanded_text_info(theme); 6222 pair = pidgin_blist_theme_get_expanded_text_info(theme);
6222 else 6223 else
6223 pair = pidgin_blist_theme_get_collapsed_text_info(theme); 6224 pair = pidgin_blist_theme_get_collapsed_text_info(theme);
6224 6225
6225 6226
6226 text_color = (selected || pair == NULL || pair->color == NULL) ? NULL : pair->color; 6227 text_color = selected ? NULL : theme_font_get_color_default(pair, NULL);
6227 text_font = (pair == NULL || pair->font == NULL) ? "" : pair->font; 6228 text_font = theme_font_get_face_default(pair, "");
6228 6229
6229 esc = g_markup_escape_text(group->name, -1); 6230 esc = g_markup_escape_text(group->name, -1);
6230 if (text_color) { 6231 if (text_color) {
6231 mark = g_strdup_printf("<span foreground='%s' font_desc='%s'><b>%s</b>%s</span>", 6232 mark = g_strdup_printf("<span foreground='%s' font_desc='%s'><b>%s</b>%s</span>",
6232 text_color, text_font, esc ? esc : "", group_count); 6233 text_color, text_font, esc ? esc : "", group_count);
6280 { 6281 {
6281 time_t idle_secs = purple_presence_get_idle_time(presence); 6282 time_t idle_secs = purple_presence_get_idle_time(presence);
6282 6283
6283 if (idle_secs > 0) 6284 if (idle_secs > 0)
6284 { 6285 {
6285 FontColorPair *pair = NULL; 6286 PidginThemeFont *pair = NULL;
6286 const gchar *textcolor; 6287 const gchar *textcolor;
6287 time_t t; 6288 time_t t;
6288 int ihrs, imin; 6289 int ihrs, imin;
6289 time(&t); 6290 time(&t);
6290 6291
6291 ihrs = (t - idle_secs) / 3600; 6292 ihrs = (t - idle_secs) / 3600;
6292 imin = ((t - idle_secs) / 60) % 60; 6293 imin = ((t - idle_secs) / 60) % 60;
6293 6294
6294 if (!selected && theme != NULL && (pair = pidgin_blist_theme_get_idle_text_info(theme)) != NULL && pair->color != NULL) 6295 if (!selected && theme != NULL && (pair = pidgin_blist_theme_get_idle_text_info(theme)) != NULL)
6295 textcolor = pair->color; 6296 textcolor = pidgin_theme_font_get_color_describe(pair);
6296 else 6297 else
6297 textcolor = NULL; 6298 textcolor = NULL;
6298 6299
6299 if (textcolor) { 6300 if (textcolor) {
6300 idle = g_strdup_printf("<span color='%s' font_desc='%s'>%d:%02d</span>", 6301 idle = g_strdup_printf("<span color='%s' font_desc='%s'>%d:%02d</span>",
6301 textcolor, (pair == NULL || pair->font == NULL) ? "" : pair->font, 6302 textcolor, theme_font_get_face_default(pair, ""),
6302 ihrs, imin); 6303 ihrs, imin);
6303 } else { 6304 } else {
6304 idle = g_strdup_printf("<span font_desc='%s'>%d:%02d</span>", 6305 idle = g_strdup_printf("<span font_desc='%s'>%d:%02d</span>",
6305 (pair == NULL || pair->font == NULL) ? "" : pair->font, 6306 theme_font_get_face_default(pair, ""),
6306 ihrs, imin); 6307 ihrs, imin);
6307 } 6308 }
6308 } 6309 }
6309 } 6310 }
6310 6311
6385 GdkPixbuf *status; 6386 GdkPixbuf *status;
6386 gchar *mark, *tmp; 6387 gchar *mark, *tmp;
6387 const gchar *fg_color, *font; 6388 const gchar *fg_color, *font;
6388 GdkColor *color = NULL; 6389 GdkColor *color = NULL;
6389 PidginBlistTheme *theme = pidgin_blist_get_theme(); 6390 PidginBlistTheme *theme = pidgin_blist_get_theme();
6390 FontColorPair *pair; 6391 PidginThemeFont *pair;
6391 gboolean selected = (gtkblist->selected_node == cnode); 6392 gboolean selected = (gtkblist->selected_node == cnode);
6392 6393
6393 mark = g_markup_escape_text(purple_contact_get_alias(contact), -1); 6394 mark = g_markup_escape_text(purple_contact_get_alias(contact), -1);
6394 6395
6395 theme = pidgin_blist_get_theme(); 6396 theme = pidgin_blist_get_theme();
6398 else { 6399 else {
6399 pair = pidgin_blist_theme_get_contact_text_info(theme); 6400 pair = pidgin_blist_theme_get_contact_text_info(theme);
6400 color = pidgin_blist_theme_get_contact_color(theme); 6401 color = pidgin_blist_theme_get_contact_color(theme);
6401 } 6402 }
6402 6403
6403 font = (pair == NULL || pair->font == NULL) ? "" : pair->font; 6404 font = theme_font_get_face_default(pair, "");
6404 fg_color = (selected || pair == NULL || pair->color == NULL) ? NULL : pair->color; 6405 fg_color = selected ? NULL : theme_font_get_color_default(pair, NULL);
6405 6406
6406 if (fg_color) { 6407 if (fg_color) {
6407 tmp = g_strdup_printf("<span font_desc='%s' color='%s'>%s</span>", 6408 tmp = g_strdup_printf("<span font_desc='%s' color='%s'>%s</span>",
6408 font, fg_color, mark); 6409 font, fg_color, mark);
6409 } else { 6410 } else {
6496 gboolean biglist = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons"); 6497 gboolean biglist = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons");
6497 PidginBlistNode *ui; 6498 PidginBlistNode *ui;
6498 PurpleConversation *conv; 6499 PurpleConversation *conv;
6499 gboolean hidden = FALSE; 6500 gboolean hidden = FALSE;
6500 GdkColor *bgcolor = NULL; 6501 GdkColor *bgcolor = NULL;
6501 FontColorPair *pair; 6502 PidginThemeFont *pair;
6502 PidginBlistTheme *theme; 6503 PidginBlistTheme *theme;
6503 gboolean selected = (gtkblist->selected_node == node); 6504 gboolean selected = (gtkblist->selected_node == node);
6504 gboolean nick_said = FALSE; 6505 gboolean nick_said = FALSE;
6505 6506
6506 if (!insert_node(list, node, &iter)) 6507 if (!insert_node(list, node, &iter))
6534 else if (hidden) 6535 else if (hidden)
6535 pair = pidgin_blist_theme_get_unread_message_text_info(theme); 6536 pair = pidgin_blist_theme_get_unread_message_text_info(theme);
6536 else pair = pidgin_blist_theme_get_online_text_info(theme); 6537 else pair = pidgin_blist_theme_get_online_text_info(theme);
6537 6538
6538 6539
6539 font = (pair == NULL || pair->font == NULL) ? "" : pair->font; 6540 font = theme_font_get_face_default(pair, "");
6540 if (selected || pair == NULL || pair->color == NULL) 6541 if (selected || !(color = theme_font_get_color_default(pair, NULL)))
6541 /* nick_said color is the same as gtkconv:tab-label-attention */ 6542 /* nick_said color is the same as gtkconv:tab-label-attention */
6542 color = (nick_said ? "#006aff" : NULL); 6543 color = (nick_said ? "#006aff" : NULL);
6543 else
6544 color = pair->color;
6545 6544
6546 if (color) { 6545 if (color) {
6547 tmp = g_strdup_printf("<span font_desc='%s' color='%s' weight='%s'>%s</span>", 6546 tmp = g_strdup_printf("<span font_desc='%s' color='%s' weight='%s'>%s</span>",
6548 font, color, hidden ? "bold" : "normal", mark); 6547 font, color, hidden ? "bold" : "normal", mark);
6549 } else { 6548 } else {

mercurial