about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-05-10 01:08:30 +0100
committerJames Booth <boothj5@gmail.com>2015-05-10 01:08:30 +0100
commit487f5da17d516a3b9e94dc6b54b60d26256d000a (patch)
treee29c0668f4e64d2c4ae926fe4bcdfb8da38bdcb6 /src/ui
parentacd2d2309f164a4902c3cfd7dc5b1ed5d2f7aa71 (diff)
parentaaad3ff90903e05f075076dc87b4ec9e66b4a773 (diff)
downloadprofani-tty-487f5da17d516a3b9e94dc6b54b60d26256d000a.tar.gz
Merge branch 'master' into openpgp
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/core.c28
-rw-r--r--src/ui/notifier.c26
-rw-r--r--src/ui/ui.h2
3 files changed, 20 insertions, 36 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index cb295244..36b73f33 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -473,20 +473,8 @@ ui_incoming_msg(const char * const barejid, const char * const resource, const c
         beep();
     }
 
-    int ui_index = num;
-    if (ui_index == 10) {
-        ui_index = 0;
-    }
-
     if (prefs_get_boolean(PREF_NOTIFY_MESSAGE)) {
-        gboolean is_current = wins_is_current(window);
-        if ( !is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_MESSAGE_CURRENT)) ) {
-            if (prefs_get_boolean(PREF_NOTIFY_MESSAGE_TEXT)) {
-                notify_message(display_name, ui_index, message);
-            } else {
-                notify_message(display_name, ui_index, NULL);
-            }
-        }
+        notify_message(window, display_name, message);
     }
 
     free(display_name);
@@ -525,24 +513,12 @@ ui_incoming_private_msg(const char * const fulljid, const char * const message,
         }
     }
 
-    int ui_index = num;
-    if (ui_index == 10) {
-        ui_index = 0;
-    }
-
     if (prefs_get_boolean(PREF_BEEP)) {
         beep();
     }
 
     if (prefs_get_boolean(PREF_NOTIFY_MESSAGE)) {
-        gboolean is_current = wins_is_current(window);
-        if ( !is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_MESSAGE_CURRENT)) ) {
-            if (prefs_get_boolean(PREF_NOTIFY_MESSAGE_TEXT)) {
-                notify_message(display_from, ui_index, message);
-            } else {
-                notify_message(display_from, ui_index, NULL);
-            }
-        }
+        notify_message(window, display_from, message);
     }
 
     free(display_from);
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
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 48b8d393..0ee21be4 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -342,7 +342,7 @@ void notifier_initialise(void);
 void notifier_uninit(void);
 
 void notify_typing(const char * const handle);
-void notify_message(const char * const handle, int win, const char * const text);
+void notify_message(ProfWin *window, const char * const name, const char * const text);
 void notify_room_message(const char * const handle, const char * const room,
     int win, const char * const text);
 void notify_remind(void);