about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-02-04 00:41:53 +0000
committerJames Booth <boothj5@gmail.com>2016-02-04 00:41:53 +0000
commitc14ef3390690d732c64bf88a37b23dcdebb6e867 (patch)
tree541eee3a0f732e719a5b63970c83af47838208ec /src/ui
parentf8f9ad51979680e9aef316f637d8cf6d3bde1bc5 (diff)
downloadprofani-tty-c14ef3390690d732c64bf88a37b23dcdebb6e867.tar.gz
Tidy notify_message()
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/chatwin.c16
-rw-r--r--src/ui/notifier.c11
-rw-r--r--src/ui/privwin.c16
3 files changed, 12 insertions, 31 deletions
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index 718c6809..b086619e 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -280,20 +280,8 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha
         beep();
     }
 
-    if (!notify) {
-        free(display_name);
-        return;
-    }
-
-    int ui_index = num;
-    if (ui_index == 10) {
-        ui_index = 0;
-    }
-
-    if (prefs_get_boolean(PREF_NOTIFY_CHAT_TEXT)) {
-        notify_message(display_name, ui_index, message);
-    } else {
-        notify_message(display_name, ui_index, NULL);
+    if (notify) {
+        notify_message(display_name, num, message);
     }
 
     free(display_name);
diff --git a/src/ui/notifier.c b/src/ui/notifier.c
index 30497fe3..fda5aedd 100644
--- a/src/ui/notifier.c
+++ b/src/ui/notifier.c
@@ -98,11 +98,16 @@ notify_invite(const char *const from, const char *const room, const char *const
 }
 
 void
-notify_message(const char *const name, int win, const char *const text)
+notify_message(const char *const name, int num, const char *const text)
 {
+    int ui_index = num;
+    if (ui_index == 10) {
+        ui_index = 0;
+    }
+
     GString *message = g_string_new("");
-    g_string_append_printf(message, "%s (win %d)", name, win);
-    if (text) {
+    g_string_append_printf(message, "%s (win %d)", name, ui_index);
+    if (text && prefs_get_boolean(PREF_NOTIFY_CHAT_TEXT)) {
         g_string_append_printf(message, "\n%s", text);
     }
 
diff --git a/src/ui/privwin.c b/src/ui/privwin.c
index 36cc29c7..c47a7565 100644
--- a/src/ui/privwin.c
+++ b/src/ui/privwin.c
@@ -85,20 +85,8 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDat
         beep();
     }
 
-    if (!notify) {
-        jid_destroy(jidp);
-        return;
-    }
-
-    int ui_index = num;
-    if (ui_index == 10) {
-        ui_index = 0;
-    }
-
-    if (prefs_get_boolean(PREF_NOTIFY_CHAT_TEXT)) {
-        notify_message(jidp->resourcepart, ui_index, message);
-    } else {
-        notify_message(jidp->resourcepart, ui_index, NULL);
+    if (notify) {
+        notify_message(jidp->resourcepart, num, message);
     }
 
     jid_destroy(jidp);