about summary refs log tree commit diff stats
path: root/src/ui/notifier.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-05-10 01:03:34 +0100
committerJames Booth <boothj5@gmail.com>2015-05-10 01:03:34 +0100
commitaaad3ff90903e05f075076dc87b4ec9e66b4a773 (patch)
tree41154e5b3d9e51d8321cca3d93731d02b17a1d93 /src/ui/notifier.c
parentd853284f92fb93067b724446f256cefcccd4b67c (diff)
downloadprofani-tty-aaad3ff90903e05f075076dc87b4ec9e66b4a773.tar.gz
Moved logic to notify_message
Diffstat (limited to 'src/ui/notifier.c')
-rw-r--r--src/ui/notifier.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/ui/notifier.c b/src/ui/notifier.c
index d3389bc5..76290daf 100644
--- a/src/ui/notifier.c
+++ b/src/ui/notifier.c
@@ -48,10 +48,10 @@
 #include "log.h"
 #include "muc.h"
 #include "ui/ui.h"
+#include "ui/windows.h"
 #include "config/preferences.h"
 
-static void _notify(const char * const message, int timeout,
-    const char * const category);
+static void _notify(const char * const message, int timeout, const char * const category);
 
 static GTimer *remind_timer;
 
@@ -99,17 +99,25 @@ notify_invite(const char * const from, const char * const room,
 }
 
 void
-notify_message(const char * const handle, int win, const char * const text)
+notify_message(ProfWin *window, const char * const name, const char * const text)
 {
-    GString *message = g_string_new("");
-    g_string_append_printf(message, "%s (win %d)", handle, win);
-    if (text) {
-        g_string_append_printf(message, "\n%s", text);
+    int num = wins_get_num(window);
+    if (num == 10) {
+        num = 0;
     }
 
-    _notify(message->str, 10000, "incoming message");
+    gboolean is_current = wins_is_current(window);
+    if (!is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_MESSAGE_CURRENT)) ) {
+        GString *message = g_string_new("");
+        g_string_append_printf(message, "%s (win %d)", name, num);
 
-    g_string_free(message, TRUE);
+        if (prefs_get_boolean(PREF_NOTIFY_MESSAGE_TEXT) && text) {
+            g_string_append_printf(message, "\n%s", text);
+        }
+
+        _notify(message->str, 10000, "incoming message");
+        g_string_free(message, TRUE);
+    }
 }
 
 void