From da84aec5138fa60c8444e50e24df2dd4875a0d45 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 23 Apr 2013 00:18:56 +0100 Subject: [PATCH] Reminders for chat room invites - WIP --- src/ui/notifier.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/ui/notifier.c b/src/ui/notifier.c index 5bf4defb..941feba9 100644 --- a/src/ui/notifier.c +++ b/src/ui/notifier.c @@ -91,16 +91,35 @@ void notify_remind(void) { gint unread = ui_unread(); + //gint open = jabber_open_invites(); + gint open = 0; + + GString *text = g_string_new(""); + if (unread > 0) { - char message[20]; if (unread == 1) { - sprintf(message, "1 unread message"); + g_string_append(text, "1 unread message"); } else { - snprintf(message, sizeof(message), "%d unread messages", unread); + g_string_append_printf(text, "%d unread messages", unread); } - _notify(message, 5000, "Incoming message"); } + if (open > 0) { + if (unread > 0) { + g_string_append(text, "\n"); + } + if (open == 1) { + g_string_append(text, "1 open invite"); + } else { + g_string_append_printf(text, "%d open invites", open); + } + } + + if ((unread > 0) || (open > 0)) { + _notify(text->str, 5000, "Incoming message"); + } + + g_string_free(text, TRUE); } static void