about summary refs log tree commit diff stats
path: root/windows.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-06-28 23:29:46 +0100
committerJames Booth <boothj5@gmail.com>2012-06-28 23:29:46 +0100
commit18494c3701334bb64756f218095b6003039c8169 (patch)
tree5e5c19aba450172865dd4784a33ddb6b69dae394 /windows.c
parenta49f2fbef052f3a3f246bdb2e6b539521a29b7c3 (diff)
downloadprofani-tty-18494c3701334bb64756f218095b6003039c8169.tar.gz
Added desktop notification
Diffstat (limited to 'windows.c')
-rw-r--r--windows.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/windows.c b/windows.c
index 11bd97e4..76cb2781 100644
--- a/windows.c
+++ b/windows.c
@@ -25,6 +25,7 @@
 
 #include <ncurses.h>
 #include <glib.h>
+#include <libnotify/notify.h>
 
 #include "ui.h"
 #include "util.h"
@@ -67,6 +68,7 @@ static void _cons_show_incoming_message(const char * const short_from,
 static void _win_handle_switch(const int * const ch);
 static void _win_handle_page(const int * const ch);
 static void _win_resize_all(void);
+static void _win_notify(char * short_from);
 
 void gui_init(void)
 {
@@ -186,12 +188,36 @@ void win_show_incomming_msg(const char * const from, const char * const message)
         _cons_show_incoming_message(short_from, win_index);
         if (prefs_get_flash())
             flash();
+        
+        _win_notify(short_from);
     }
 
     if (prefs_get_beep())
         beep();
 }
 
+static void _win_notify(char * short_from)
+{
+    notify_init("Profanity");
+    
+    // create a new notification
+    NotifyNotification *incoming;
+    incoming = notify_notification_new("Profanity", short_from, NULL);
+
+    // set the timeout of the notification to 3 secs
+    notify_notification_set_timeout(incoming, 3000);
+
+    // set the category so as to tell what kind it is
+    char category[30] = "Incoming message";
+    notify_notification_set_category(incoming, category);
+
+    // set the urgency level of the notification
+    notify_notification_set_urgency (incoming, NOTIFY_URGENCY_CRITICAL);
+
+    GError *error = NULL;
+    notify_notification_show(incoming, &error);
+}
+
 void win_show_outgoing_msg(const char * const from, const char * const to, 
     const char * const message)
 {