about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-01-24 17:33:26 +0000
committerJames Booth <boothj5@gmail.com>2016-01-24 17:33:26 +0000
commit5ff36c14c03402c1796dfd29f00e43b5d400e0e5 (patch)
tree0e1da6c781d5bac4cf3953ba025512e6dd24b92f
parent2bda22c3d67893dc9d84cb53683f9e9d83e70cb2 (diff)
downloadprofani-tty-5ff36c14c03402c1796dfd29f00e43b5d400e0e5.tar.gz
Added roomtrigger colour theme
closes #717
-rw-r--r--src/config/preferences.c46
-rw-r--r--src/config/preferences.h1
-rw-r--r--src/config/theme.c2
-rw-r--r--src/config/theme.h1
-rw-r--r--src/ui/console.c1
-rw-r--r--src/ui/mucwin.c2
-rw-r--r--themes/boothj53
7 files changed, 34 insertions, 22 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,
diff --git a/src/ui/console.c b/src/ui/console.c
index bd8b9171..6fd6fc38 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -2125,6 +2125,7 @@ cons_theme_properties(void)
 
     _cons_theme_prop(THEME_ROOMINFO, "roominfo");
     _cons_theme_prop(THEME_ROOMMENTION, "roommention");
+    _cons_theme_prop(THEME_ROOMTRIGGER, "roomtrigger");
 
     _cons_theme_prop(THEME_ROSTER_HEADER, "roster.header");
     _cons_theme_prop(THEME_ROSTER_CHAT, "roster.chat");
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index 4674b198..37da10dd 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -366,6 +366,8 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
     if (g_strcmp0(nick, my_nick) != 0) {
         if (g_strrstr(message, my_nick)) {
             win_print(window, '-', 0, NULL, NO_ME, THEME_ROOMMENTION, nick, message);
+        } else if (prefs_message_contains_trigger(message)) {
+            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/themes/boothj5 b/themes/boothj5
index 2a627787..da42f125 100644
--- a/themes/boothj5
+++ b/themes/boothj5
@@ -42,7 +42,8 @@ typing=yellow
 gone=red
 error=red
 roominfo=yellow
-roommention=bold_red
+roommention=bold_magenta
+roomtrigger=bold_cyan
 me=blue
 them=bold_green
 roster.header=bold_yellow