1
0
Fork 0

Added roster contact themes

This commit is contained in:
James Booth 2016-01-14 22:54:50 +00:00
parent 042ad4758f
commit fbc302317a
20 changed files with 411 additions and 5 deletions

View File

@ -1071,6 +1071,7 @@ cmd_close(ProfWin *window, const char *const command, gchar **args)
} else {
cons_show("Closed %d windows.", count);
}
rosterwin_roster();
return TRUE;
}
@ -1083,6 +1084,7 @@ cmd_close(ProfWin *window, const char *const command, gchar **args)
} else {
cons_show("Closed %d windows.", count);
}
rosterwin_roster();
return TRUE;
}
@ -1141,6 +1143,7 @@ cmd_close(ProfWin *window, const char *const command, gchar **args)
wins_tidy();
}
rosterwin_roster();
return TRUE;
} else {
if (g_strcmp0(args[0], "console") == 0) {
@ -1175,6 +1178,7 @@ cmd_close(ProfWin *window, const char *const command, gchar **args)
wins_tidy();
}
rosterwin_roster();
return TRUE;
}
}

View File

@ -447,6 +447,60 @@ _theme_find(const char *const theme_name)
return path;
}
theme_item_t
theme_roster_unread_presence_attrs(const char *const presence)
{
if (g_strcmp0(presence, "online") == 0) {
return THEME_ROSTER_ONLINE_UNREAD;
} else if (g_strcmp0(presence, "away") == 0) {
return THEME_ROSTER_AWAY_UNREAD;
} else if (g_strcmp0(presence, "chat") == 0) {
return THEME_ROSTER_CHAT_UNREAD;
} else if (g_strcmp0(presence, "dnd") == 0) {
return THEME_ROSTER_DND_UNREAD;
} else if (g_strcmp0(presence, "xa") == 0) {
return THEME_ROSTER_XA_UNREAD;
} else {
return THEME_ROSTER_OFFLINE_UNREAD;
}
}
theme_item_t
theme_roster_active_presence_attrs(const char *const presence)
{
if (g_strcmp0(presence, "online") == 0) {
return THEME_ROSTER_ONLINE_ACTIVE;
} else if (g_strcmp0(presence, "away") == 0) {
return THEME_ROSTER_AWAY_ACTIVE;
} else if (g_strcmp0(presence, "chat") == 0) {
return THEME_ROSTER_CHAT_ACTIVE;
} else if (g_strcmp0(presence, "dnd") == 0) {
return THEME_ROSTER_DND_ACTIVE;
} else if (g_strcmp0(presence, "xa") == 0) {
return THEME_ROSTER_XA_ACTIVE;
} else {
return THEME_ROSTER_OFFLINE_ACTIVE;
}
}
theme_item_t
theme_roster_presence_attrs(const char *const presence)
{
if (g_strcmp0(presence, "online") == 0) {
return THEME_ROSTER_ONLINE;
} else if (g_strcmp0(presence, "away") == 0) {
return THEME_ROSTER_AWAY;
} else if (g_strcmp0(presence, "chat") == 0) {
return THEME_ROSTER_CHAT;
} else if (g_strcmp0(presence, "dnd") == 0) {
return THEME_ROSTER_DND;
} else if (g_strcmp0(presence, "xa") == 0) {
return THEME_ROSTER_XA;
} else {
return THEME_ROSTER_OFFLINE;
}
}
theme_item_t
theme_main_presence_attrs(const char *const presence)
{
@ -554,6 +608,24 @@ theme_attrs(theme_item_t attrs)
case THEME_OTR_TRUSTED: _theme_prep_fgnd("otr.trusted", "green", lookup_str, &bold); break;
case THEME_OTR_UNTRUSTED: _theme_prep_fgnd("otr.untrusted", "yellow", lookup_str, &bold); break;
case THEME_ROSTER_HEADER: _theme_prep_fgnd("roster.header", "yellow", lookup_str, &bold); break;
case THEME_ROSTER_ONLINE: _theme_prep_fgnd("roster.online", "green", lookup_str, &bold); break;
case THEME_ROSTER_OFFLINE: _theme_prep_fgnd("roster.offline", "red", lookup_str, &bold); break;
case THEME_ROSTER_CHAT: _theme_prep_fgnd("roster.chat", "green", lookup_str, &bold); break;
case THEME_ROSTER_AWAY: _theme_prep_fgnd("roster.away", "cyan", lookup_str, &bold); break;
case THEME_ROSTER_DND: _theme_prep_fgnd("roster.dnd", "red", lookup_str, &bold); break;
case THEME_ROSTER_XA: _theme_prep_fgnd("roster.xa", "cyan", lookup_str, &bold); break;
case THEME_ROSTER_ONLINE_ACTIVE: _theme_prep_fgnd("roster.online.active", "green", lookup_str, &bold); break;
case THEME_ROSTER_OFFLINE_ACTIVE: _theme_prep_fgnd("roster.offline.active", "red", lookup_str, &bold); break;
case THEME_ROSTER_CHAT_ACTIVE: _theme_prep_fgnd("roster.chat.active", "green", lookup_str, &bold); break;
case THEME_ROSTER_AWAY_ACTIVE: _theme_prep_fgnd("roster.away.active", "cyan", lookup_str, &bold); break;
case THEME_ROSTER_DND_ACTIVE: _theme_prep_fgnd("roster.dnd.active", "red", lookup_str, &bold); break;
case THEME_ROSTER_XA_ACTIVE: _theme_prep_fgnd("roster.xa.active", "cyan", lookup_str, &bold); break;
case THEME_ROSTER_ONLINE_UNREAD: _theme_prep_fgnd("roster.online.unread", "green", lookup_str, &bold); break;
case THEME_ROSTER_OFFLINE_UNREAD: _theme_prep_fgnd("roster.offline.unread", "red", lookup_str, &bold); break;
case THEME_ROSTER_CHAT_UNREAD: _theme_prep_fgnd("roster.chat.unread", "green", lookup_str, &bold); break;
case THEME_ROSTER_AWAY_UNREAD: _theme_prep_fgnd("roster.away.unread", "cyan", lookup_str, &bold); break;
case THEME_ROSTER_DND_UNREAD: _theme_prep_fgnd("roster.dnd.unread", "red", lookup_str, &bold); break;
case THEME_ROSTER_XA_UNREAD: _theme_prep_fgnd("roster.xa.unread", "cyan", lookup_str, &bold); break;
case THEME_ROSTER_ROOM: _theme_prep_fgnd("roster.room", "green", lookup_str, &bold); break;
case THEME_ROSTER_ROOM_UNREAD: _theme_prep_fgnd("roster.room.unread", "green", lookup_str, &bold); break;
case THEME_OCCUPANTS_HEADER: _theme_prep_fgnd("occupants.header", "yellow", lookup_str, &bold); break;

View File

@ -85,6 +85,24 @@ typedef enum {
THEME_OTR_UNTRUSTED,
THEME_OCCUPANTS_HEADER,
THEME_ROSTER_HEADER,
THEME_ROSTER_ONLINE,
THEME_ROSTER_OFFLINE,
THEME_ROSTER_AWAY,
THEME_ROSTER_CHAT,
THEME_ROSTER_DND,
THEME_ROSTER_XA,
THEME_ROSTER_ONLINE_ACTIVE,
THEME_ROSTER_OFFLINE_ACTIVE,
THEME_ROSTER_AWAY_ACTIVE,
THEME_ROSTER_CHAT_ACTIVE,
THEME_ROSTER_DND_ACTIVE,
THEME_ROSTER_XA_ACTIVE,
THEME_ROSTER_ONLINE_UNREAD,
THEME_ROSTER_OFFLINE_UNREAD,
THEME_ROSTER_AWAY_UNREAD,
THEME_ROSTER_CHAT_UNREAD,
THEME_ROSTER_DND_UNREAD,
THEME_ROSTER_XA_UNREAD,
THEME_ROSTER_ROOM,
THEME_ROSTER_ROOM_UNREAD,
THEME_RECEIPT_SENT,
@ -113,6 +131,10 @@ gboolean theme_load(const char *const theme_name);
GSList* theme_list(void);
void theme_close(void);
int theme_attrs(theme_item_t attrs);
theme_item_t theme_main_presence_attrs(const char *const presence);
theme_item_t theme_roster_unread_presence_attrs(const char *const presence);
theme_item_t theme_roster_active_presence_attrs(const char *const presence);
theme_item_t theme_roster_presence_attrs(const char *const presence);
#endif

View File

@ -427,6 +427,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_m
} else {
_sv_ev_incoming_otr(chatwin, new_win, barejid, resource, message, timestamp);
}
rosterwin_roster();
return;
#endif
#endif
@ -435,6 +436,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_m
#ifdef HAVE_LIBOTR
#ifndef HAVE_LIBGPGME
_sv_ev_incoming_otr(chatwin, new_win, barejid, resource, message, timestamp);
rosterwin_roster();
return;
#endif
#endif
@ -447,6 +449,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_m
} else {
_sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message, timestamp);
}
rosterwin_roster();
return;
#endif
#endif
@ -455,6 +458,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_m
#ifndef HAVE_LIBOTR
#ifndef HAVE_LIBGPGME
_sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message, timestamp);
rosterwin_roster();
return;
#endif
#endif

View File

@ -42,6 +42,12 @@
#include "config/preferences.h"
#include "roster_list.h"
typedef enum {
ROSTER_CONTACT,
ROSTER_CONTACT_ACTIVE,
ROSTER_CONTACT_UNREAD
} roster_contact_theme_t;
static void
_rosterwin_presence(ProfLayoutSplit *layout, theme_item_t colour, const char *presence, const char *status,
int current_indent)
@ -126,7 +132,7 @@ _rosterwin_presence(ProfLayoutSplit *layout, theme_item_t colour, const char *pr
}
static void
_rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_indent)
_rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_indent, roster_contact_theme_t theme_type)
{
gboolean join = prefs_get_boolean(PREF_ROSTER_RESOURCE_JOIN);
@ -135,7 +141,13 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde
if (join && (g_list_length(resources) == 1)) {
Resource *resource = resources->data;
const char *resource_presence = string_from_resource_presence(resource->presence);
theme_item_t resource_presence_colour = theme_main_presence_attrs(resource_presence);
theme_item_t resource_presence_colour;
switch (theme_type) {
case ROSTER_CONTACT: resource_presence_colour = theme_roster_presence_attrs(resource_presence); break;
case ROSTER_CONTACT_ACTIVE: resource_presence_colour = theme_roster_active_presence_attrs(resource_presence); break;
case ROSTER_CONTACT_UNREAD: resource_presence_colour = theme_roster_unread_presence_attrs(resource_presence); break;
}
wattron(layout->subwin, theme_attrs(resource_presence_colour));
GString *msg = g_string_new("");
@ -167,7 +179,13 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde
while (curr_resource) {
Resource *resource = curr_resource->data;
const char *resource_presence = string_from_resource_presence(resource->presence);
theme_item_t resource_presence_colour = theme_main_presence_attrs(resource_presence);
theme_item_t resource_presence_colour;
switch (theme_type) {
case ROSTER_CONTACT: resource_presence_colour = theme_roster_presence_attrs(resource_presence); break;
case ROSTER_CONTACT_ACTIVE: resource_presence_colour = theme_roster_active_presence_attrs(resource_presence); break;
case ROSTER_CONTACT_UNREAD: resource_presence_colour = theme_roster_unread_presence_attrs(resource_presence); break;
}
wattron(layout->subwin, theme_attrs(resource_presence_colour));
GString *msg = g_string_new(" ");
@ -213,8 +231,24 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
const char *name = p_contact_name_or_jid(contact);
const char *presence = p_contact_presence(contact);
const char *status = p_contact_status(contact);
const char *barejid = p_contact_barejid(contact);
theme_item_t presence_colour = theme_main_presence_attrs(presence);
roster_contact_theme_t theme_type = ROSTER_CONTACT;
ProfChatWin *chatwin = wins_get_chat(barejid);
if (chatwin) {
if (chatwin->unread > 0) {
theme_type = ROSTER_CONTACT_UNREAD;
} else {
theme_type = ROSTER_CONTACT_ACTIVE;
}
}
theme_item_t presence_colour;
switch (theme_type) {
case ROSTER_CONTACT: presence_colour = theme_roster_presence_attrs(presence); break;
case ROSTER_CONTACT_ACTIVE: presence_colour = theme_roster_active_presence_attrs(presence); break;
case ROSTER_CONTACT_UNREAD: presence_colour = theme_roster_unread_presence_attrs(presence); break;
}
wattron(layout->subwin, theme_attrs(presence_colour));
GString *msg = g_string_new(" ");
@ -239,7 +273,7 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
wattroff(layout->subwin, theme_attrs(presence_colour));
if (prefs_get_boolean(PREF_ROSTER_RESOURCE)) {
_rosterwin_resources(layout, contact, current_indent);
_rosterwin_resources(layout, contact, current_indent, theme_type);
} else if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || prefs_get_boolean(PREF_ROSTER_STATUS)) {
_rosterwin_presence(layout, presence_colour, presence, status, current_indent);
}

View File

@ -46,6 +46,24 @@ roommention=
me=
them=
roster.header=
roster.chat=
roster.online=
roster.away=
roster.xa=
roster.dnd=
roster.offline=
roster.chat.active=
roster.online.active=
roster.away.active=
roster.xa.active=
roster.dnd.active=
roster.offline.active=
roster.chat.unread=
roster.online.unread=
roster.away.unread=
roster.xa.unread=
roster.dnd.unread=
roster.offline.unread=
roster.room=
roster.room.unread=
occupants.header=

View File

@ -46,6 +46,24 @@ roommention=bold_blue
me=cyan
them=white
roster.header=bold_white
roster.chat=white
roster.online=bold_cyan
roster.away=bold_blue
roster.xa=cyan
roster.dnd=blue
roster.offline=bold_black
roster.chat.active=white
roster.online.active=bold_cyan
roster.away.active=bold_blue
roster.xa.active=cyan
roster.dnd.active=blue
roster.offline.active=bold_black
roster.chat.unread=white
roster.online.unread=bold_cyan
roster.away.unread=bold_blue
roster.xa.unread=cyan
roster.dnd.unread=blue
roster.offline.unread=bold_black
roster.room=cyan
roster.room.unread=bold_cyan
occupants.header=bold_white

View File

@ -46,6 +46,24 @@ subscribed=magenta
unsubscribed=black_bold
roommention=cyan
roster.header=yellow
roster.chat=green
roster.online=green
roster.away=yellow
roster.xa=yellow
roster.dnd=green
roster.offline=bold_black
roster.chat.active=green
roster.online.active=green
roster.away.active=yellow
roster.xa.active=yellow
roster.dnd.active=green
roster.offline.active=bold_black
roster.chat.unread=green
roster.online.unread=green
roster.away.unread=yellow
roster.xa.unread=yellow
roster.dnd.unread=green
roster.offline.unread=bold_black
roster.room=green
roster.room.unread=green
occupants.header=yellow

View File

@ -46,6 +46,24 @@ roommention=bold_red
me=blue
them=bold_green
roster.header=bold_yellow
roster.chat=white
roster.online=green
roster.away=cyan
roster.xa=blue
roster.dnd=magenta
roster.offline=red
roster.chat.active=white
roster.online.active=green
roster.away.active=cyan
roster.xa.active=blue
roster.dnd.active=magenta
roster.offline.active=red
roster.chat.unread=bold_white
roster.online.unread=bold_green
roster.away.unread=bold_cyan
roster.xa.unread=bold_blue
roster.dnd.unread=bold_magenta
roster.offline.unread=bold_red
roster.room=green
roster.room.unread=bold_green
occupants.header=bold_yellow

View File

@ -46,6 +46,24 @@ roommention=bold_cyan
me=blue
them=bold_blue
roster.header=bold_green
roster.chat=green
roster.online=green
roster.away=blue
roster.xa=blue
roster.dnd=bold_black
roster.offline=bold_black
roster.chat.active=green
roster.online.active=green
roster.away.active=blue
roster.xa.active=blue
roster.dnd.active=bold_black
roster.offline.active=bold_black
roster.chat.unread=green
roster.online.unread=green
roster.away.unread=blue
roster.xa.unread=blue
roster.dnd.unread=bold_black
roster.offline.unread=bold_black
roster.room=green
roster.room.unread=bold_green
occupants.header=bold_green

View File

@ -46,6 +46,24 @@ roommention=bold_green
me=green
them=bold_green
roster.header=bold_green
roster.chat=bold_green
roster.online=bold_green
roster.away=green
roster.xa=green
roster.dnd=green
roster.offline=green
roster.chat.active=bold_green
roster.online.active=bold_green
roster.away.active=green
roster.xa.active=green
roster.dnd.active=green
roster.offline.active=green
roster.chat.unread=bold_green
roster.online.unread=bold_green
roster.away.unread=green
roster.xa.unread=green
roster.dnd.unread=green
roster.offline.unread=green
roster.room=green
roster.room=bold_green
occupants.header=bold_green

View File

@ -46,6 +46,24 @@ roommention=bold_green
me=white
them=white
roster.header=bold_cyan
roster.chat=green
roster.online=red
roster.away=cyan
roster.xa=cyan
roster.dnd=magenta
roster.offline=green
roster.chat.active=green
roster.online.active=red
roster.away.active=cyan
roster.xa.active=cyan
roster.dnd.active=magenta
roster.offline.active=green
roster.chat.unread=bold_green
roster.online.unread=bold_red
roster.away.unread=bold_cyan
roster.xa.unread=bold_cyan
roster.dnd.unread=bold_magenta
roster.offline.unread=bold_green
roster.room=red
roster.room.unread=bold_red
occupants.header=bold_cyan

View File

@ -46,6 +46,24 @@ roommention=green
me=magenta
them=green
roster.header=magenta
roster.chat=green
roster.online=green
roster.away=yellow
roster.xa=yellow
roster.dnd=green
roster.offline=bold_black
roster.chat.active=green
roster.online.active=green
roster.away.active=yellow
roster.xa.active=yellow
roster.dnd.active=green
roster.offline.active=bold_black
roster.chat.unread=green
roster.online.unread=green
roster.away.unread=yellow
roster.xa.unread=yellow
roster.dnd.unread=green
roster.offline.unread=bold_black
roster.room=green
roster.room.unread=green
occupants.header=magenta

View File

@ -46,6 +46,24 @@ roommention=white
me=white
them=white
roster.header=white
roster.chat=white
roster.online=white
roster.away=white
roster.xa=white
roster.dnd=white
roster.offline=white
roster.chat.active=white
roster.online.active=white
roster.away.active=white
roster.xa.active=white
roster.dnd.active=white
roster.offline.active=white
roster.chat.unread=white
roster.online.unread=white
roster.away.unread=white
roster.xa.unread=white
roster.dnd.unread=white
roster.offline.unread=white
roster.room=white
roster.room.unread=white
occupants.header=white

View File

@ -46,6 +46,24 @@ roommention=blue
me=black
them=black
roster.header=black
roster.chat=blue
roster.online=blue
roster.away=white
roster.xa=white
roster.dnd=white
roster.offline=white
roster.chat.active=blue
roster.online.active=blue
roster.away.active=white
roster.xa.active=white
roster.dnd.active=white
roster.offline.active=white
roster.chat.unread=blue
roster.online.unread=blue
roster.away.unread=white
roster.xa.unread=white
roster.dnd.unread=white
roster.offline.unread=white
roster.room=blue
roster.room.unread=blue
occupants.header=black

View File

@ -46,6 +46,24 @@ roommention=yellow
me=yellow
them=green
roster.header=yellow
roster.chat=green
roster.online=green
roster.away=cyan
roster.xa=cyan
roster.dnd=red
roster.offline=red
roster.chat.active=green
roster.online.active=green
roster.away.active=cyan
roster.xa.active=cyan
roster.dnd.active=red
roster.offline.active=red
roster.chat.unread=green
roster.online.unread=green
roster.away.unread=cyan
roster.xa.unread=cyan
roster.dnd.unread=red
roster.offline.unread=red
roster.room=green
roster.room.unread=green
occupants.header=yellow

View File

@ -46,6 +46,24 @@ roommention=bold_yellow
me=bold_yellow
them=bold_green
roster.header=bold_yellow
roster.chat=bold_green
roster.online=bold_green
roster.away=bold_cyan
roster.xa=bold_cyan
roster.dnd=bold_red
roster.offline=bold_red
roster.chat.active=bold_green
roster.online.active=bold_green
roster.away.active=bold_cyan
roster.xa.active=bold_cyan
roster.dnd.active=bold_red
roster.offline.active=bold_red
roster.chat.unread=bold_green
roster.online.unread=bold_green
roster.away.unread=bold_cyan
roster.xa.unread=bold_cyan
roster.dnd.unread=bold_red
roster.offline.unread=bold_red
roster.room=bold_green
roster.room.unread=bold_green
occupants.header=bold_yellow

View File

@ -46,6 +46,24 @@ roommention=green
me=bold_black
them=magenta
roster.header=magenta
roster.chat=green
roster.online=green
roster.away=yellow
roster.xa=yellow
roster.dnd=green
roster.offline=white
roster.chat.active=green
roster.online.active=green
roster.away.active=yellow
roster.xa.active=yellow
roster.dnd.active=green
roster.offline.active=white
roster.chat.unread=green
roster.online.unread=green
roster.away.unread=yellow
roster.xa.unread=yellow
roster.dnd.unread=green
roster.offline.unread=white
roster.room=green
roster.room.unread=green
occupants.header=magenta

View File

@ -46,6 +46,24 @@ roommention=red
me=green
them=yellow
roster.header=white
roster.chat=green
roster.online=green
roster.away=yellow
roster.xa=yellow
roster.dnd=green
roster.offline=bold_black
roster.chat.active=green
roster.online.active=green
roster.away.active=yellow
roster.xa.active=yellow
roster.dnd.active=green
roster.offline.active=bold_black
roster.chat.unread=green
roster.online.unread=green
roster.away.unread=yellow
roster.xa.unread=yellow
roster.dnd.unread=green
roster.offline.unread=bold_black
roster.room=green
roster.room.unread=green
occupants.header=white

View File

@ -46,6 +46,24 @@ roommention=yellow
me=black
them=black
roster.header=black
roster.chat=green
roster.online=green
roster.away=cyan
roster.xa=cyan
roster.dnd=red
roster.offline=red
roster.chat.active=green
roster.online.active=green
roster.away.active=cyan
roster.xa.active=cyan
roster.dnd.active=red
roster.offline.active=red
roster.chat.unread=green
roster.online.unread=green
roster.away.unread=cyan
roster.xa.unread=cyan
roster.dnd.unread=red
roster.offline.unread=red
roster.room=green
roster.room.unread=green
occupants.header=black