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;