diff options
author | James Booth <boothj5@gmail.com> | 2013-05-23 00:10:55 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-05-23 00:10:55 +0100 |
commit | 486cbd62450c1ba51aab3046f3c55c6f5890eb96 (patch) | |
tree | 931f639c20334720f3d5afbfa9d963296c5b3ce1 | |
parent | 0ced96f57848e017d52190139a94bb2c2caeed78 (diff) | |
download | profani-tty-486cbd62450c1ba51aab3046f3c55c6f5890eb96.tar.gz |
Added room name, and window index to desktop message notifications
closes #176
-rw-r--r-- | src/ui/core.c | 16 | ||||
-rw-r--r-- | src/ui/notifier.c | 21 | ||||
-rw-r--r-- | src/ui/notifier.h | 4 |
3 files changed, 34 insertions, 7 deletions
diff --git a/src/ui/core.c b/src/ui/core.c index f4d95abe..66aa7467 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -426,10 +426,15 @@ ui_incoming_msg(const char * const from, const char * const message, } } + int ui_index = win_index + 1; + if (ui_index == 10) { + ui_index = 0; + } + if (prefs_get_boolean(PREF_BEEP)) beep(); if (prefs_get_boolean(PREF_NOTIFY_MESSAGE)) - notify_message(display_from); + notify_message(display_from, ui_index); FREE_SET_NULL(display_from); } @@ -1227,12 +1232,19 @@ ui_room_message(const char * const room_jid, const char * const nick, windows[win_index]->unread++; } + int ui_index = win_index + 1; + if (ui_index == 10) { + ui_index = 0; + } + if (strcmp(nick, muc_get_room_nick(room_jid)) != 0) { if (prefs_get_boolean(PREF_BEEP)) { beep(); } if (prefs_get_boolean(PREF_NOTIFY_MESSAGE)) { - notify_message(nick); + Jid *jidp = jid_create(room_jid); + notify_room_message(nick, jidp->localpart, ui_index); + jid_destroy(jidp); } } } diff --git a/src/ui/notifier.c b/src/ui/notifier.c index 2b114569..f43c8c25 100644 --- a/src/ui/notifier.c +++ b/src/ui/notifier.c @@ -84,12 +84,25 @@ notify_invite(const char * const from, const char * const room, } void -notify_message(const char * const handle) +notify_message(const char * const handle, int win) { - char message[strlen(handle) + 1 + 10]; - sprintf(message, "%s: message.", handle); + char message[strlen(handle) + 1 + 14]; + sprintf(message, "%s: message (%d).", handle, win); - _notify(message, 10000, "Incoming message"); + _notify(message, 10000, "incoming message"); +} + +void +notify_room_message(const char * const handle, const char * const room, int win) +{ + GString *text = g_string_new(""); + + g_string_append_printf(text, "Room: %s\n", room); + g_string_append_printf(text, "%s: message (%d).", handle, win); + + _notify(text->str, 10000, "incoming message"); + + g_string_free(text, FALSE); } void diff --git a/src/ui/notifier.h b/src/ui/notifier.h index 0995e8ba..9db789e8 100644 --- a/src/ui/notifier.h +++ b/src/ui/notifier.h @@ -24,7 +24,9 @@ void notifier_init(void); void notifier_uninit(void); void notify_typing(const char * const handle); -void notify_message(const char * const handle); +void notify_message(const char * const handle, int win); +void notify_room_message(const char * const handle, const char * const room, + int win); void notify_remind(void); void notify_invite(const char * const from, const char * const room, const char * const reason); |