diff options
author | James Booth <boothj5@gmail.com> | 2016-01-24 17:33:26 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2016-01-24 17:33:26 +0000 |
commit | 5ff36c14c03402c1796dfd29f00e43b5d400e0e5 (patch) | |
tree | 0e1da6c781d5bac4cf3953ba025512e6dd24b92f /src/config | |
parent | 2bda22c3d67893dc9d84cb53683f9e9d83e70cb2 (diff) | |
download | profani-tty-5ff36c14c03402c1796dfd29f00e43b5d400e0e5.tar.gz |
Added roomtrigger colour theme
closes #717
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/preferences.c | 46 | ||||
-rw-r--r-- | src/config/preferences.h | 1 | ||||
-rw-r--r-- | src/config/theme.c | 2 | ||||
-rw-r--r-- | src/config/theme.h | 1 |
4 files changed, 29 insertions, 21 deletions
diff --git a/src/config/preferences.c b/src/config/preferences.c index 10ef4549..f419eff4 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -212,6 +212,29 @@ prefs_do_chat_notify(gboolean current_win, const char *const message) } gboolean +prefs_message_contains_trigger(const char *const message) +{ + gboolean trigger_found = FALSE; + 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); + int i; + 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; + } + g_free(trigger_lower); + } + g_strfreev(triggers); + g_free(message_lower); + + return trigger_found; +} + +gboolean prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const nick, const char *const message) { @@ -258,27 +281,8 @@ 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) { - gboolean trigger_found = FALSE; - 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); - int i; - 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; - } - g_free(trigger_lower); - } - g_strfreev(triggers); - g_free(message_lower); - - if (trigger_found) { - return TRUE; - } + if (notify_trigger && prefs_message_contains_trigger(message)) { + return TRUE; } return FALSE; diff --git a/src/config/preferences.h b/src/config/preferences.h index 4fee90b9..8c94a1e1 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -226,6 +226,7 @@ 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); 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/config/theme.c b/src/config/theme.c index 7222e841..0e790eb2 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -105,6 +105,7 @@ theme_init(const char *const theme_name) g_hash_table_insert(defaults, strdup("receipt.sent"), strdup("red")); g_hash_table_insert(defaults, strdup("roominfo"), strdup("yellow")); g_hash_table_insert(defaults, strdup("roommention"), strdup("yellow")); + g_hash_table_insert(defaults, strdup("roomtrigger"), strdup("yellow")); g_hash_table_insert(defaults, strdup("online"), strdup("green")); g_hash_table_insert(defaults, strdup("offline"), strdup("red")); g_hash_table_insert(defaults, strdup("away"), strdup("cyan")); @@ -727,6 +728,7 @@ theme_attrs(theme_item_t attrs) 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; diff --git a/src/config/theme.h b/src/config/theme.h index f4eac724..c26b84f1 100644 --- a/src/config/theme.h +++ b/src/config/theme.h @@ -68,6 +68,7 @@ typedef enum { THEME_THEM, THEME_ROOMINFO, THEME_ROOMMENTION, + THEME_ROOMTRIGGER, THEME_ONLINE, THEME_OFFLINE, THEME_AWAY, |