Moved logic to notify_message

This commit is contained in:
James Booth
2015-05-10 01:03:34 +01:00
parent d853284f92
commit aaad3ff909
4 changed files with 21 additions and 37 deletions

View File

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