From 5ff9fbd81091f09222235542f2cf2a707df54f7a Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 24 Jan 2016 23:06:22 +0000 Subject: [PATCH 1/5] Tidy handling room mention and room triggers --- src/config/preferences.c | 30 +++++++++++------------------- src/config/preferences.h | 5 +++-- src/event/server_events.c | 25 ++++++++++++++++++------- src/ui/mucwin.c | 7 ++++--- src/ui/ui.h | 2 +- 5 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/config/preferences.c b/src/config/preferences.c index f419eff4..7e798dc8 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -211,10 +211,11 @@ prefs_do_chat_notify(gboolean current_win, const char *const message) return FALSE; } -gboolean -prefs_message_contains_trigger(const char *const message) +GList* +prefs_message_get_triggers(const char *const message) { - gboolean trigger_found = FALSE; + GList *result = NULL; + char *message_lower = g_utf8_strdown(message, -1); gsize len = 0; gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL); @@ -222,21 +223,20 @@ prefs_message_contains_trigger(const char *const message) for (i = 0; i < len; i++) { char *trigger_lower = g_utf8_strdown(triggers[i], -1); if (g_strrstr(message_lower, trigger_lower)) { - trigger_found = TRUE; g_free(trigger_lower); - break; + result = g_list_append(result, strdup(triggers[i])); } g_free(trigger_lower); } g_strfreev(triggers); g_free(message_lower); - return trigger_found; + return result; } gboolean -prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const nick, - const char *const message) +prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const nick, const char *const message, + gboolean mention, gboolean trigger_found) { gboolean notify_current = prefs_get_boolean(PREF_NOTIFY_ROOM_CURRENT); gboolean notify_window = FALSE; @@ -263,16 +263,8 @@ prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char } else { notify_mention = prefs_get_boolean(PREF_NOTIFY_ROOM_MENTION); } - if (notify_mention) { - char *message_lower = g_utf8_strdown(message, -1); - char *nick_lower = g_utf8_strdown(nick, -1); - if (g_strrstr(message_lower, nick_lower)) { - g_free(message_lower); - g_free(nick_lower); - return TRUE; - } - g_free(message_lower); - g_free(nick_lower); + if (notify_mention && mention) { + return TRUE; } gboolean notify_trigger = FALSE; @@ -281,7 +273,7 @@ prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char } else { notify_trigger = prefs_get_boolean(PREF_NOTIFY_ROOM_TRIGGER); } - if (notify_trigger && prefs_message_contains_trigger(message)) { + if (notify_trigger && trigger_found) { return TRUE; } diff --git a/src/config/preferences.h b/src/config/preferences.h index 8c94a1e1..61ccbb11 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -225,8 +225,9 @@ void prefs_free_string(char *pref); void prefs_set_string(preference_t pref, char *value); gboolean prefs_do_chat_notify(gboolean current_win, const char *const message); -gboolean prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const nick, const char *const message); -gboolean prefs_message_contains_trigger(const char *const message); +gboolean prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const nick, + const char *const message, gboolean mention, gboolean trigger_found); +GList* prefs_message_get_triggers(const char *const message); void prefs_set_room_notify(const char *const roomjid, gboolean value); void prefs_set_room_notify_mention(const char *const roomjid, gboolean value); diff --git a/src/event/server_events.c b/src/event/server_events.c index faeb1bfe..9f343e50 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -230,8 +230,7 @@ sv_ev_room_history(const char *const room_jid, const char *const nick, } void -sv_ev_room_message(const char *const room_jid, const char *const nick, - const char *const message) +sv_ev_room_message(const char *const room_jid, const char *const nick, const char *const message) { if (prefs_get_boolean(PREF_GRLOG)) { Jid *jid = jid_create(jabber_get_fulljid()); @@ -244,13 +243,25 @@ sv_ev_room_message(const char *const room_jid, const char *const nick, return; } - mucwin_message(mucwin, nick, message); + char *mynick = muc_nick(mucwin->roomjid); + + gboolean mention = FALSE; + char *message_lower = g_utf8_strdown(message, -1); + char *mynick_lower = g_utf8_strdown(mynick, -1); + if (g_strrstr(message_lower, mynick_lower)) { + mention = TRUE; + } + g_free(message_lower); + g_free(mynick_lower); + + GList *triggers = prefs_message_get_triggers(message); + + mucwin_message(mucwin, nick, message, mention, triggers != NULL); ProfWin *window = (ProfWin*)mucwin; gboolean is_current = wins_is_current(window); int num = wins_get_num(window); - char *my_nick = muc_nick(mucwin->roomjid); - gboolean notify = prefs_do_room_notify(is_current, mucwin->roomjid, my_nick, message); + gboolean notify = prefs_do_room_notify(is_current, mucwin->roomjid, mynick, message, mention, triggers != NULL); // currently in groupchat window if (wins_is_current(window)) { @@ -267,7 +278,7 @@ sv_ev_room_message(const char *const room_jid, const char *const nick, } prefs_free_string(muc_show); - if (prefs_get_boolean(PREF_FLASH) && (strcmp(nick, my_nick) != 0)) { + if (prefs_get_boolean(PREF_FLASH) && (strcmp(nick, mynick) != 0)) { flash(); } @@ -280,7 +291,7 @@ sv_ev_room_message(const char *const room_jid, const char *const nick, rosterwin_roster(); // don't notify self messages - if (strcmp(nick, my_nick) == 0) { + if (strcmp(nick, mynick) == 0) { return; } diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 37da10dd..a24daa59 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -356,7 +356,8 @@ mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp, } void -mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const message) +mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const message, gboolean mention, + gboolean trigger_found) { assert(mucwin != NULL); @@ -364,9 +365,9 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes char *my_nick = muc_nick(mucwin->roomjid); if (g_strcmp0(nick, my_nick) != 0) { - if (g_strrstr(message, my_nick)) { + if (mention) { win_print(window, '-', 0, NULL, NO_ME, THEME_ROOMMENTION, nick, message); - } else if (prefs_message_contains_trigger(message)) { + } else if (trigger_found) { win_print(window, '-', 0, NULL, NO_ME, THEME_ROOMTRIGGER, nick, message); } else { win_print(window, '-', 0, NULL, NO_ME, THEME_TEXT_THEM, nick, message); diff --git a/src/ui/ui.h b/src/ui/ui.h index 8fea6eb1..86f68d3c 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -158,7 +158,7 @@ void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char const char *const role, const char *const affiliation, const char *const actor, const char *const reason); void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char *const presence); void mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp, const char *const message); -void mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const message); +void mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const message, gboolean mention, gboolean trigger_found); void mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const subject); void mucwin_requires_config(ProfMucWin *mucwin); void mucwin_info(ProfMucWin *mucwin); From 628119680955dfe693dc4109551385f454999771 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 24 Jan 2016 23:08:29 +0000 Subject: [PATCH 2/5] Fixed tests --- tests/unittests/ui/stub_ui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 4235e10f..3ae1227c 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -185,7 +185,7 @@ void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char const char * const affiliation, const char * const actor, const char * const reason) {} void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char * const presence) {} void mucwin_history(ProfMucWin *mucwin, const char * const nick, GDateTime *timestamp, const char * const message) {} -void mucwin_message(ProfMucWin *mucwin, const char * const nick, const char * const message) {} +void mucwin_message(ProfMucWin *mucwin, const char * const nick, const char * const message, gboolean mention, gboolean trigger_found) {} void mucwin_subject(ProfMucWin *mucwin, const char * const nick, const char * const subject) {} void mucwin_requires_config(ProfMucWin *mucwin) {} void ui_room_destroy(const char * const roomjid) {} From b6e9a09c64ca4438aa066759caf9a4008edadd46 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 24 Jan 2016 23:47:17 +0000 Subject: [PATCH 3/5] Show console messages for room mention and triggers closes #719 --- src/config/preferences.c | 1 - src/event/server_events.c | 13 ++++----- src/ui/console.c | 55 +++++++++++++++++++++++++++++++----- src/ui/ui.h | 3 +- tests/unittests/ui/stub_ui.c | 2 +- 5 files changed, 57 insertions(+), 17 deletions(-) diff --git a/src/config/preferences.c b/src/config/preferences.c index 7e798dc8..bb85c682 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -223,7 +223,6 @@ prefs_message_get_triggers(const char *const message) for (i = 0; i < len; i++) { char *trigger_lower = g_utf8_strdown(triggers[i], -1); if (g_strrstr(message_lower, trigger_lower)) { - g_free(trigger_lower); result = g_list_append(result, strdup(triggers[i])); } g_free(trigger_lower); diff --git a/src/event/server_events.c b/src/event/server_events.c index 9f343e50..64f82dc0 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -270,13 +270,8 @@ sv_ev_room_message(const char *const room_jid, const char *const nick, const cha // not currently on groupchat window } else { status_bar_new(num); - char *muc_show = prefs_get_string(PREF_CONSOLE_MUC); - if (g_strcmp0(muc_show, "all") == 0) { - cons_show_incoming_room_message(nick, mucwin->roomjid, num); - } else if (g_strcmp0(muc_show, "first") == 0 && mucwin->unread == 0) { - cons_show_incoming_room_message(NULL, mucwin->roomjid, num); - } - prefs_free_string(muc_show); + + cons_show_incoming_room_message(nick, mucwin->roomjid, num, mention, triggers, mucwin->unread); if (prefs_get_boolean(PREF_FLASH) && (strcmp(nick, mynick) != 0)) { flash(); @@ -288,6 +283,10 @@ sv_ev_room_message(const char *const room_jid, const char *const nick, const cha } } + if (triggers) { + g_list_free_full(triggers, free); + } + rosterwin_roster(); // don't notify self messages diff --git a/src/ui/console.c b/src/ui/console.c index 6fd6fc38..2be41b14 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -301,8 +301,27 @@ cons_show_typing(const char *const barejid) cons_alert(); } +char* +_room_triggers_to_string(GList *triggers) +{ + GString *triggers_str = g_string_new(""); + GList *curr = triggers; + while (curr) { + g_string_append_printf(triggers_str, "\"%s\"", (char*)curr->data); + curr = g_list_next(curr); + if (curr) { + g_string_append(triggers_str, ", "); + } + } + + char *result = triggers_str->str; + g_string_free(triggers_str, FALSE); + return result; +} + void -cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index) +cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index, gboolean mention, + GList *triggers, int unread) { ProfWin *const console = wins_get_console(); @@ -311,13 +330,35 @@ cons_show_incoming_room_message(const char *const nick, const char *const room, ui_index = 0; } - if (nick) { - win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s in %s (win %d)", nick, room, ui_index); - } else { - win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s (win %d)", room, ui_index); - } + char *muc_show = prefs_get_string(PREF_CONSOLE_MUC); - cons_alert(); + if (g_strcmp0(muc_show, "all") == 0) { + if (mention) { + win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room mention: %s in %s (win %d)", nick, room, ui_index); + } else if (triggers) { + char *triggers_str = _room_triggers_to_string(triggers); + win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); + free(triggers_str); + } else { + win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s in %s (win %d)", nick, room, ui_index); + } + cons_alert(); + + } else if (g_strcmp0(muc_show, "first") == 0) { + if (mention) { + win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room mention: %s in %s (win %d)", nick, room, ui_index); + cons_alert(); + } else if (triggers) { + char *triggers_str = _room_triggers_to_string(triggers); + win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); + free(triggers_str); + cons_alert(); + } else if (unread == 0) { + win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s (win %d)", room, ui_index); + cons_alert(); + } + } + prefs_free_string(muc_show); } void diff --git a/src/ui/ui.h b/src/ui/ui.h index 86f68d3c..835fd890 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -257,7 +257,8 @@ void cons_show_disco_info(const char *from, GSList *identities, GSList *features void cons_show_room_invite(const char *const invitor, const char *const room, const char *const reason); void cons_check_version(gboolean not_available_msg); void cons_show_typing(const char *const barejid); -void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index); +void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index, + gboolean mention, GList *triggers, int unread); void cons_show_incoming_message(const char *const short_from, const int win_index); void cons_show_incoming_private_message(const char *const nick, const char *const room, const int win_index); void cons_show_room_invites(GSList *invites); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 3ae1227c..015e0024 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -394,7 +394,7 @@ void cons_show_room_invite(const char * const invitor, const char * const room, const char * const reason) {} void cons_check_version(gboolean not_available_msg) {} void cons_show_typing(const char * const barejid) {} -void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index) {} +void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index, gboolean mention, GList *triggers, int unread) {} void cons_show_incoming_message(const char * const short_from, const int win_index) {} void cons_show_room_invites(GSList *invites) {} void cons_show_received_subs(void) {} From 0ae975c27f2b5f9a47a7434138c0ae328b06a7a6 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 25 Jan 2016 00:19:26 +0000 Subject: [PATCH 4/5] Added themes for roster room mention and triggers closes #718 --- src/config/theme.c | 4 ++++ src/config/theme.h | 2 ++ src/event/server_events.c | 7 +++++++ src/ui/console.c | 2 ++ src/ui/rosterwin.c | 12 ++++++++++-- src/ui/win_types.h | 2 ++ src/ui/window.c | 2 ++ src/window_list.c | 2 ++ theme_template | 2 ++ themes/aqua | 2 ++ themes/batman | 2 ++ themes/bios | 2 ++ themes/boothj5 | 6 ++++-- themes/forest | 2 ++ themes/headache | 2 ++ themes/joker | 2 ++ themes/mono | 2 ++ themes/orange | 2 ++ themes/original | 2 ++ themes/original_bright | 2 ++ themes/shade | 2 ++ themes/spawn | 2 ++ themes/whiteness | 2 ++ 23 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/config/theme.c b/src/config/theme.c index 0e790eb2..10bbb0af 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -142,6 +142,8 @@ theme_init(const char *const theme_name) g_hash_table_insert(defaults, strdup("roster.xa.unread"), strdup("cyan")); g_hash_table_insert(defaults, strdup("roster.room"), strdup("green")); g_hash_table_insert(defaults, strdup("roster.room.unread"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.room.trigger"), strdup("green")); + g_hash_table_insert(defaults, strdup("roster.room.mention"), strdup("green")); g_hash_table_insert(defaults, strdup("occupants.header"), strdup("yellow")); } @@ -765,6 +767,8 @@ theme_attrs(theme_item_t attrs) 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_ROSTER_ROOM_TRIGGER: _theme_prep_fgnd("roster.room.trigger", "green", lookup_str, &bold); break; + case THEME_ROSTER_ROOM_MENTION: _theme_prep_fgnd("roster.room.mention", "green", lookup_str, &bold); break; case THEME_OCCUPANTS_HEADER: _theme_prep_fgnd("occupants.header", "yellow", lookup_str, &bold); break; case THEME_WHITE: g_string_append(lookup_str, "white"); bold = FALSE; break; case THEME_WHITE_BOLD: g_string_append(lookup_str, "white"); bold = TRUE; break; diff --git a/src/config/theme.h b/src/config/theme.h index c26b84f1..e6a72dde 100644 --- a/src/config/theme.h +++ b/src/config/theme.h @@ -106,6 +106,8 @@ typedef enum { THEME_ROSTER_XA_UNREAD, THEME_ROSTER_ROOM, THEME_ROSTER_ROOM_UNREAD, + THEME_ROSTER_ROOM_TRIGGER, + THEME_ROSTER_ROOM_MENTION, THEME_RECEIPT_SENT, THEME_NONE, THEME_WHITE, diff --git a/src/event/server_events.c b/src/event/server_events.c index 64f82dc0..57416496 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -281,6 +281,13 @@ sv_ev_room_message(const char *const room_jid, const char *const nick, const cha if (notify) { mucwin->notify = TRUE; } + + if (mention) { + mucwin->unread_mentions = TRUE; + } + if (triggers) { + mucwin->unread_triggers = TRUE; + } } if (triggers) { diff --git a/src/ui/console.c b/src/ui/console.c index 2be41b14..a5a9800d 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -2189,6 +2189,8 @@ cons_theme_properties(void) _cons_theme_prop(THEME_ROSTER_OFFLINE_UNREAD, "roster.offline.unread"); _cons_theme_prop(THEME_ROSTER_ROOM, "roster.room"); _cons_theme_prop(THEME_ROSTER_ROOM_UNREAD, "roster.room.unread"); + _cons_theme_prop(THEME_ROSTER_ROOM_TRIGGER, "roster.room.trigger"); + _cons_theme_prop(THEME_ROSTER_ROOM_MENTION, "roster.room.mention"); _cons_theme_prop(THEME_OCCUPANTS_HEADER, "occupants.header"); diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c index d7c8875b..7dfad1e1 100644 --- a/src/ui/rosterwin.c +++ b/src/ui/rosterwin.c @@ -479,7 +479,11 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) { GString *msg = g_string_new(" "); - if (mucwin->unread > 0) { + if (mucwin->unread_mentions) { + wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_MENTION)); + } else if (mucwin->unread_triggers) { + wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_TRIGGER)); + } else if (mucwin->unread > 0) { wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_UNREAD)); } else { wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM)); @@ -514,7 +518,11 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) win_sub_print(layout->subwin, msg->str, FALSE, wrap, current_indent); g_string_free(msg, TRUE); - if (mucwin->unread > 0) { + if (mucwin->unread_mentions) { + wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_MENTION)); + } else if (mucwin->unread_triggers) { + wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_TRIGGER)); + } else if (mucwin->unread > 0) { wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_UNREAD)); } else { wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM)); diff --git a/src/ui/win_types.h b/src/ui/win_types.h index 94901957..53b5f49a 100644 --- a/src/ui/win_types.h +++ b/src/ui/win_types.h @@ -117,6 +117,8 @@ typedef struct prof_muc_win_t { ProfWin window; char *roomjid; int unread; + gboolean unread_mentions; + gboolean unread_triggers; gboolean notify; gboolean showjid; unsigned long memcheck; diff --git a/src/ui/window.c b/src/ui/window.c index d749ac84..8af57cfd 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -181,6 +181,8 @@ win_create_muc(const char *const roomjid) new_win->roomjid = strdup(roomjid); new_win->unread = 0; + new_win->unread_mentions = FALSE; + new_win->unread_triggers = FALSE; new_win->notify = FALSE; if (prefs_get_boolean(PREF_OCCUPANTS_JID)) { new_win->showjid = TRUE; diff --git a/src/window_list.c b/src/window_list.c index efb6e331..2acfd0fb 100644 --- a/src/window_list.c +++ b/src/window_list.c @@ -228,6 +228,8 @@ wins_set_current_by_num(int i) ProfMucWin *mucwin = (ProfMucWin*) window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); mucwin->unread = 0; + mucwin->unread_mentions = FALSE; + mucwin->unread_triggers = FALSE; mucwin->notify = FALSE; } else if (window->type == WIN_PRIVATE) { ProfPrivateWin *privatewin = (ProfPrivateWin*) window; diff --git a/theme_template b/theme_template index b363c041..eb5a0fe8 100644 --- a/theme_template +++ b/theme_template @@ -67,6 +67,8 @@ roster.dnd.unread= roster.offline.unread= roster.room= roster.room.unread= +roster.room.trigger= +roster.room.mention= occupants.header= receipt.sent= diff --git a/themes/aqua b/themes/aqua index dbfd9d30..ecdfac16 100644 --- a/themes/aqua +++ b/themes/aqua @@ -67,5 +67,7 @@ roster.dnd.unread=blue roster.offline.unread=bold_black roster.room=cyan roster.room.unread=bold_cyan +roster.room.mention=bold_blue +roster.room.trigger=bold_blue occupants.header=bold_white receipt.sent=white diff --git a/themes/batman b/themes/batman index 87cb3e30..937e0ad3 100644 --- a/themes/batman +++ b/themes/batman @@ -67,5 +67,7 @@ roster.dnd.unread=green roster.offline.unread=bold_black roster.room=green roster.room.unread=green +roster.room.mention=green +roster.room.trigger=green occupants.header=yellow receipt.sent=red diff --git a/themes/bios b/themes/bios index 2dfd4975..51d63c84 100644 --- a/themes/bios +++ b/themes/bios @@ -67,6 +67,8 @@ roster.dnd.unread=bold_red roster.offline.unread=bold_blue roster.room=bold_red roster.room.unread=bold_magenta +roster.room.mention=bold_magenta +roster.room.trigger=bold_magenta occupants.header=bold_magenta receipt.sent=bold_blue diff --git a/themes/boothj5 b/themes/boothj5 index 2327fdf0..ac6c4666 100644 --- a/themes/boothj5 +++ b/themes/boothj5 @@ -42,8 +42,8 @@ typing=yellow gone=red error=red roominfo=yellow -roommention=bold_magenta -roomtrigger=bold_red +roommention=bold_cyan +roomtrigger=bold_blue me=blue them=bold_green roster.header=bold_yellow @@ -67,6 +67,8 @@ roster.dnd.unread=bold_magenta roster.offline.unread=bold_red roster.room=green roster.room.unread=bold_green +roster.room.mention=bold_cyan +roster.room.trigger=bold_blue occupants.header=bold_yellow receipt.sent=bold_black diff --git a/themes/forest b/themes/forest index 9d687f3c..cd289d44 100644 --- a/themes/forest +++ b/themes/forest @@ -67,5 +67,7 @@ roster.dnd.unread=bold_black roster.offline.unread=bold_black roster.room=green roster.room.unread=bold_green +roster.room.mention=bold_green +roster.room.trigger=bold_green occupants.header=bold_green receipt.sent=bold_black diff --git a/themes/headache b/themes/headache index 7686d99d..8f95e796 100644 --- a/themes/headache +++ b/themes/headache @@ -67,5 +67,7 @@ roster.dnd.unread=bold_magenta roster.offline.unread=bold_green roster.room=red roster.room.unread=bold_red +roster.room.mention=bold_red +roster.room.trigger=bold_red occupants.header=bold_cyan receipt.sent=red diff --git a/themes/joker b/themes/joker index 0f4db59f..400dc0a7 100644 --- a/themes/joker +++ b/themes/joker @@ -67,5 +67,7 @@ roster.dnd.unread=green roster.offline.unread=bold_black roster.room=green roster.room.unread=green +roster.room.mention=green +roster.room.trigger=green occupants.header=magenta receipt.sent=red diff --git a/themes/mono b/themes/mono index c74d7509..392d458a 100644 --- a/themes/mono +++ b/themes/mono @@ -67,5 +67,7 @@ roster.dnd.unread=white roster.offline.unread=white roster.room=white roster.room.unread=white +roster.room.mention=white +roster.room.trigger=white occupants.header=white receipt.sent=white diff --git a/themes/orange b/themes/orange index 220f448e..a7875ec9 100644 --- a/themes/orange +++ b/themes/orange @@ -67,5 +67,7 @@ roster.dnd.unread=white roster.offline.unread=white roster.room=blue roster.room.unread=blue +roster.room.mention=blue +roster.room.trigger=blue occupants.header=black receipt.sent=red diff --git a/themes/original b/themes/original index ab6f5b44..c9433d34 100644 --- a/themes/original +++ b/themes/original @@ -67,5 +67,7 @@ roster.dnd.unread=red roster.offline.unread=red roster.room=green roster.room.unread=green +roster.room.mention=green +roster.room.trigger=green occupants.header=yellow receipt.sent=red diff --git a/themes/original_bright b/themes/original_bright index 032a8a8a..4e0dd8e8 100644 --- a/themes/original_bright +++ b/themes/original_bright @@ -67,5 +67,7 @@ roster.dnd.unread=bold_red roster.offline.unread=bold_red roster.room=bold_green roster.room.unread=bold_green +roster.room.mention=bold_green +roster.room.trigger=bold_green occupants.header=bold_yellow receipt.sent=bold_red diff --git a/themes/shade b/themes/shade index 9bc4d2eb..cd343727 100644 --- a/themes/shade +++ b/themes/shade @@ -67,5 +67,7 @@ roster.dnd.unread=green roster.offline.unread=white roster.room=green roster.room.unread=green +roster.room.mention=green +roster.room.trigger=green occupants.header=magenta receipt.sent=red diff --git a/themes/spawn b/themes/spawn index e04ab5f5..be3fb5ed 100644 --- a/themes/spawn +++ b/themes/spawn @@ -67,5 +67,7 @@ roster.dnd.unread=green roster.offline.unread=bold_black roster.room=green roster.room.unread=green +roster.room.mention=green +roster.room.trigger=green occupants.header=white receipt.sent=red diff --git a/themes/whiteness b/themes/whiteness index 22d70ef4..883038f6 100644 --- a/themes/whiteness +++ b/themes/whiteness @@ -67,5 +67,7 @@ roster.dnd.unread=red roster.offline.unread=red roster.room=green roster.room.unread=green +roster.room.mention=green +roster.room.trigger=green occupants.header=black receipt.sent=red From 45a1c66e87afbedb4d4f0c417461a3a29b5d032d Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 25 Jan 2016 00:27:56 +0000 Subject: [PATCH 5/5] Themes: Tidy foreground colour loading --- src/config/theme.c | 141 +++++++++++++++++++++++---------------------- 1 file changed, 71 insertions(+), 70 deletions(-) diff --git a/src/config/theme.c b/src/config/theme.c index 10bbb0af..e04a5d4a 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -655,10 +655,11 @@ _theme_prep_bgnd(char *setting, char *def, GString *lookup_str) } static void -_theme_prep_fgnd(char *setting, char *def, GString *lookup_str, gboolean *bold) +_theme_prep_fgnd(char *setting, GString *lookup_str, gboolean *bold) { gchar *val = g_key_file_get_string(theme, "colours", setting, NULL); if (!val) { + char *def = g_hash_table_lookup(defaults, setting); g_string_append(lookup_str, def); } else { if (g_str_has_prefix(val, "bold_")) { @@ -701,75 +702,75 @@ theme_attrs(theme_item_t attrs) // get forground colour switch (attrs) { - case THEME_TEXT: _theme_prep_fgnd("main.text", "white", lookup_str, &bold); break; - case THEME_TEXT_ME: _theme_prep_fgnd("main.text.me", "white", lookup_str, &bold); break; - case THEME_TEXT_THEM: _theme_prep_fgnd("main.text.them", "white", lookup_str, &bold); break; - case THEME_SPLASH: _theme_prep_fgnd("main.splash", "cyan", lookup_str, &bold); break; - case THEME_ERROR: _theme_prep_fgnd("error", "red", lookup_str, &bold); break; - case THEME_INCOMING: _theme_prep_fgnd("incoming", "yellow", lookup_str, &bold); break; - case THEME_INPUT_TEXT: _theme_prep_fgnd("input.text", "white", lookup_str, &bold); break; - case THEME_TIME: _theme_prep_fgnd("main.time", "white", lookup_str, &bold); break; - case THEME_TITLE_TEXT: _theme_prep_fgnd("titlebar.text", "white", lookup_str, &bold); break; - case THEME_TITLE_BRACKET: _theme_prep_fgnd("titlebar.brackets", "cyan", lookup_str, &bold); break; - case THEME_TITLE_UNENCRYPTED: _theme_prep_fgnd("titlebar.unencrypted", "red", lookup_str, &bold); break; - case THEME_TITLE_ENCRYPTED: _theme_prep_fgnd("titlebar.encrypted", "white", lookup_str, &bold); break; - case THEME_TITLE_UNTRUSTED: _theme_prep_fgnd("titlebar.untrusted", "yellow", lookup_str, &bold); break; - case THEME_TITLE_TRUSTED: _theme_prep_fgnd("titlebar.trusted", "white", lookup_str, &bold); break; - case THEME_TITLE_ONLINE: _theme_prep_fgnd("titlebar.online", "white", lookup_str, &bold); break; - case THEME_TITLE_OFFLINE: _theme_prep_fgnd("titlebar.offline", "white", lookup_str, &bold); break; - case THEME_TITLE_AWAY: _theme_prep_fgnd("titlebar.away", "white", lookup_str, &bold); break; - case THEME_TITLE_CHAT: _theme_prep_fgnd("titlebar.chat", "white", lookup_str, &bold); break; - case THEME_TITLE_DND: _theme_prep_fgnd("titlebar.dnd", "white", lookup_str, &bold); break; - case THEME_TITLE_XA: _theme_prep_fgnd("titlebar.xa", "white", lookup_str, &bold); break; - case THEME_STATUS_TEXT: _theme_prep_fgnd("statusbar.text", "white", lookup_str, &bold); break; - case THEME_STATUS_BRACKET: _theme_prep_fgnd("statusbar.brackets", "cyan", lookup_str, &bold); break; - case THEME_STATUS_ACTIVE: _theme_prep_fgnd("statusbar.active", "cyan", lookup_str, &bold); break; - case THEME_STATUS_NEW: _theme_prep_fgnd("statusbar.new", "white", lookup_str, &bold); break; - case THEME_ME: _theme_prep_fgnd("me", "yellow", lookup_str, &bold); break; - case THEME_THEM: _theme_prep_fgnd("them", "green", lookup_str, &bold); break; - case THEME_RECEIPT_SENT: _theme_prep_fgnd("receipt.sent", "red", lookup_str, &bold); break; - case THEME_ROOMINFO: _theme_prep_fgnd("roominfo", "yellow", lookup_str, &bold); break; - case THEME_ROOMMENTION: _theme_prep_fgnd("roommention", "yellow", lookup_str, &bold); break; - case THEME_ROOMTRIGGER: _theme_prep_fgnd("roomtrigger", "yellow", lookup_str, &bold); break; - case THEME_ONLINE: _theme_prep_fgnd("online", "green", lookup_str, &bold); break; - case THEME_OFFLINE: _theme_prep_fgnd("offline", "red", lookup_str, &bold); break; - case THEME_AWAY: _theme_prep_fgnd("away", "cyan", lookup_str, &bold); break; - case THEME_CHAT: _theme_prep_fgnd("chat", "green", lookup_str, &bold); break; - case THEME_DND: _theme_prep_fgnd("dnd", "red", lookup_str, &bold); break; - case THEME_XA: _theme_prep_fgnd("xa", "cyan", lookup_str, &bold); break; - case THEME_TYPING: _theme_prep_fgnd("typing", "yellow", lookup_str, &bold); break; - case THEME_GONE: _theme_prep_fgnd("gone", "red", lookup_str, &bold); break; - case THEME_SUBSCRIBED: _theme_prep_fgnd("subscribed", "green", lookup_str, &bold); break; - case THEME_UNSUBSCRIBED: _theme_prep_fgnd("unsubscribed", "red", lookup_str, &bold); break; - case THEME_OTR_STARTED_TRUSTED: _theme_prep_fgnd("otr.started.trusted", "green", lookup_str, &bold); break; - case THEME_OTR_STARTED_UNTRUSTED: _theme_prep_fgnd("otr.started.untrusted", "yellow", lookup_str, &bold); break; - case THEME_OTR_ENDED: _theme_prep_fgnd("otr.ended", "red", lookup_str, &bold); break; - 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_ROSTER_ROOM_TRIGGER: _theme_prep_fgnd("roster.room.trigger", "green", lookup_str, &bold); break; - case THEME_ROSTER_ROOM_MENTION: _theme_prep_fgnd("roster.room.mention", "green", lookup_str, &bold); break; - case THEME_OCCUPANTS_HEADER: _theme_prep_fgnd("occupants.header", "yellow", lookup_str, &bold); break; + case THEME_TEXT: _theme_prep_fgnd("main.text", lookup_str, &bold); break; + case THEME_TEXT_ME: _theme_prep_fgnd("main.text.me", lookup_str, &bold); break; + case THEME_TEXT_THEM: _theme_prep_fgnd("main.text.them", lookup_str, &bold); break; + case THEME_SPLASH: _theme_prep_fgnd("main.splash", lookup_str, &bold); break; + case THEME_ERROR: _theme_prep_fgnd("error", lookup_str, &bold); break; + case THEME_INCOMING: _theme_prep_fgnd("incoming", lookup_str, &bold); break; + case THEME_INPUT_TEXT: _theme_prep_fgnd("input.text", lookup_str, &bold); break; + case THEME_TIME: _theme_prep_fgnd("main.time", lookup_str, &bold); break; + case THEME_TITLE_TEXT: _theme_prep_fgnd("titlebar.text", lookup_str, &bold); break; + case THEME_TITLE_BRACKET: _theme_prep_fgnd("titlebar.brackets", lookup_str, &bold); break; + case THEME_TITLE_UNENCRYPTED: _theme_prep_fgnd("titlebar.unencrypted", lookup_str, &bold); break; + case THEME_TITLE_ENCRYPTED: _theme_prep_fgnd("titlebar.encrypted", lookup_str, &bold); break; + case THEME_TITLE_UNTRUSTED: _theme_prep_fgnd("titlebar.untrusted", lookup_str, &bold); break; + case THEME_TITLE_TRUSTED: _theme_prep_fgnd("titlebar.trusted", lookup_str, &bold); break; + case THEME_TITLE_ONLINE: _theme_prep_fgnd("titlebar.online", lookup_str, &bold); break; + case THEME_TITLE_OFFLINE: _theme_prep_fgnd("titlebar.offline", lookup_str, &bold); break; + case THEME_TITLE_AWAY: _theme_prep_fgnd("titlebar.away", lookup_str, &bold); break; + case THEME_TITLE_CHAT: _theme_prep_fgnd("titlebar.chat", lookup_str, &bold); break; + case THEME_TITLE_DND: _theme_prep_fgnd("titlebar.dnd", lookup_str, &bold); break; + case THEME_TITLE_XA: _theme_prep_fgnd("titlebar.xa", lookup_str, &bold); break; + case THEME_STATUS_TEXT: _theme_prep_fgnd("statusbar.text", lookup_str, &bold); break; + case THEME_STATUS_BRACKET: _theme_prep_fgnd("statusbar.brackets", lookup_str, &bold); break; + case THEME_STATUS_ACTIVE: _theme_prep_fgnd("statusbar.active", lookup_str, &bold); break; + case THEME_STATUS_NEW: _theme_prep_fgnd("statusbar.new", lookup_str, &bold); break; + case THEME_ME: _theme_prep_fgnd("me", lookup_str, &bold); break; + case THEME_THEM: _theme_prep_fgnd("them", lookup_str, &bold); break; + case THEME_RECEIPT_SENT: _theme_prep_fgnd("receipt.sent", lookup_str, &bold); break; + case THEME_ROOMINFO: _theme_prep_fgnd("roominfo", lookup_str, &bold); break; + case THEME_ROOMMENTION: _theme_prep_fgnd("roommention", lookup_str, &bold); break; + case THEME_ROOMTRIGGER: _theme_prep_fgnd("roomtrigger", lookup_str, &bold); break; + case THEME_ONLINE: _theme_prep_fgnd("online", lookup_str, &bold); break; + case THEME_OFFLINE: _theme_prep_fgnd("offline", lookup_str, &bold); break; + case THEME_AWAY: _theme_prep_fgnd("away", lookup_str, &bold); break; + case THEME_CHAT: _theme_prep_fgnd("chat", lookup_str, &bold); break; + case THEME_DND: _theme_prep_fgnd("dnd", lookup_str, &bold); break; + case THEME_XA: _theme_prep_fgnd("xa", lookup_str, &bold); break; + case THEME_TYPING: _theme_prep_fgnd("typing", lookup_str, &bold); break; + case THEME_GONE: _theme_prep_fgnd("gone", lookup_str, &bold); break; + case THEME_SUBSCRIBED: _theme_prep_fgnd("subscribed", lookup_str, &bold); break; + case THEME_UNSUBSCRIBED: _theme_prep_fgnd("unsubscribed", lookup_str, &bold); break; + case THEME_OTR_STARTED_TRUSTED: _theme_prep_fgnd("otr.started.trusted", lookup_str, &bold); break; + case THEME_OTR_STARTED_UNTRUSTED: _theme_prep_fgnd("otr.started.untrusted", lookup_str, &bold); break; + case THEME_OTR_ENDED: _theme_prep_fgnd("otr.ended", lookup_str, &bold); break; + case THEME_OTR_TRUSTED: _theme_prep_fgnd("otr.trusted", lookup_str, &bold); break; + case THEME_OTR_UNTRUSTED: _theme_prep_fgnd("otr.untrusted", lookup_str, &bold); break; + case THEME_ROSTER_HEADER: _theme_prep_fgnd("roster.header", lookup_str, &bold); break; + case THEME_ROSTER_ONLINE: _theme_prep_fgnd("roster.online", lookup_str, &bold); break; + case THEME_ROSTER_OFFLINE: _theme_prep_fgnd("roster.offline", lookup_str, &bold); break; + case THEME_ROSTER_CHAT: _theme_prep_fgnd("roster.chat", lookup_str, &bold); break; + case THEME_ROSTER_AWAY: _theme_prep_fgnd("roster.away", lookup_str, &bold); break; + case THEME_ROSTER_DND: _theme_prep_fgnd("roster.dnd", lookup_str, &bold); break; + case THEME_ROSTER_XA: _theme_prep_fgnd("roster.xa", lookup_str, &bold); break; + case THEME_ROSTER_ONLINE_ACTIVE: _theme_prep_fgnd("roster.online.active", lookup_str, &bold); break; + case THEME_ROSTER_OFFLINE_ACTIVE: _theme_prep_fgnd("roster.offline.active", lookup_str, &bold); break; + case THEME_ROSTER_CHAT_ACTIVE: _theme_prep_fgnd("roster.chat.active", lookup_str, &bold); break; + case THEME_ROSTER_AWAY_ACTIVE: _theme_prep_fgnd("roster.away.active", lookup_str, &bold); break; + case THEME_ROSTER_DND_ACTIVE: _theme_prep_fgnd("roster.dnd.active", lookup_str, &bold); break; + case THEME_ROSTER_XA_ACTIVE: _theme_prep_fgnd("roster.xa.active", lookup_str, &bold); break; + case THEME_ROSTER_ONLINE_UNREAD: _theme_prep_fgnd("roster.online.unread", lookup_str, &bold); break; + case THEME_ROSTER_OFFLINE_UNREAD: _theme_prep_fgnd("roster.offline.unread", lookup_str, &bold); break; + case THEME_ROSTER_CHAT_UNREAD: _theme_prep_fgnd("roster.chat.unread", lookup_str, &bold); break; + case THEME_ROSTER_AWAY_UNREAD: _theme_prep_fgnd("roster.away.unread", lookup_str, &bold); break; + case THEME_ROSTER_DND_UNREAD: _theme_prep_fgnd("roster.dnd.unread", lookup_str, &bold); break; + case THEME_ROSTER_XA_UNREAD: _theme_prep_fgnd("roster.xa.unread", lookup_str, &bold); break; + case THEME_ROSTER_ROOM: _theme_prep_fgnd("roster.room", lookup_str, &bold); break; + case THEME_ROSTER_ROOM_UNREAD: _theme_prep_fgnd("roster.room.unread", lookup_str, &bold); break; + case THEME_ROSTER_ROOM_TRIGGER: _theme_prep_fgnd("roster.room.trigger", lookup_str, &bold); break; + case THEME_ROSTER_ROOM_MENTION: _theme_prep_fgnd("roster.room.mention", lookup_str, &bold); break; + case THEME_OCCUPANTS_HEADER: _theme_prep_fgnd("occupants.header", lookup_str, &bold); break; case THEME_WHITE: g_string_append(lookup_str, "white"); bold = FALSE; break; case THEME_WHITE_BOLD: g_string_append(lookup_str, "white"); bold = TRUE; break; case THEME_GREEN: g_string_append(lookup_str, "green"); bold = FALSE; break;