1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-23 21:45:30 +00:00

Added roomtrigger colour theme

closes #717
This commit is contained in:
James Booth 2016-01-24 17:33:26 +00:00
parent 2bda22c3d6
commit 5ff36c14c0
7 changed files with 34 additions and 22 deletions

View File

@ -211,6 +211,29 @@ prefs_do_chat_notify(gboolean current_win, const char *const message)
return FALSE;
}
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;

View File

@ -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);

View File

@ -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;

View File

@ -68,6 +68,7 @@ typedef enum {
THEME_THEM,
THEME_ROOMINFO,
THEME_ROOMMENTION,
THEME_ROOMTRIGGER,
THEME_ONLINE,
THEME_OFFLINE,
THEME_AWAY,

View File

@ -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");

View File

@ -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);
}

View File

@ -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