1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

xep-0392: colorize roster

This commit is contained in:
Michael Vetter 2019-12-19 14:02:24 +01:00
parent 46478df097
commit c302af99b7
2 changed files with 19 additions and 3 deletions

View File

@ -144,6 +144,7 @@ typedef enum {
PREF_CONSOLE_PRIVATE,
PREF_CONSOLE_CHAT,
PREF_COLOR_NICK,
PREF_ROSTER_COLOR_NICK,
PREF_BOOKMARK_INVITE,
PREF_PLUGINS_SOURCEPATH,
PREF_ROOM_LIST_CACHE,

View File

@ -367,8 +367,17 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
}
theme_item_t presence_colour = _get_roster_theme(theme_type, presence);
int colour;
if (prefs_get_boolean(PREF_ROSTER_COLOR_NICK)) {
colour = theme_hash_attrs(name);
}
if (prefs_get_boolean(PREF_ROSTER_COLOR_NICK)) {
wattron(layout->subwin, colour);
} else {
wattron(layout->subwin, theme_attrs(presence_colour));
}
GString *msg = g_string_new(" ");
int indent = prefs_get_roster_contact_indent();
int current_indent = 0;
@ -404,7 +413,12 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
win_sub_print(layout->subwin, msg->str, FALSE, wrap, current_indent);
g_string_free(msg, TRUE);
if (prefs_get_boolean(PREF_ROSTER_COLOR_NICK)) {
wattroff(layout->subwin, colour);
} else {
wattroff(layout->subwin, theme_attrs(presence_colour));
}
if (prefs_get_boolean(PREF_ROSTER_RESOURCE)) {
_rosterwin_resources(layout, contact, current_indent, theme_type, unread);
@ -412,10 +426,11 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
if (unread > 0) {
GString *unreadmsg = g_string_new("");
g_string_append_printf(unreadmsg, " (%d)", unread);
wattron(layout->subwin, theme_attrs(presence_colour));
win_sub_print(layout->subwin, unreadmsg->str, FALSE, wrap, current_indent);
g_string_free(unreadmsg, TRUE);
wattroff(layout->subwin, theme_attrs(presence_colour));
wattroff(layout->subwin, theme_attrs(colour));
}
_rosterwin_presence(layout, presence, status, current_indent);