1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added desktop notification

This commit is contained in:
James Booth 2012-06-28 23:29:46 +01:00
parent a49f2fbef0
commit 18494c3701
2 changed files with 29 additions and 2 deletions

View File

@ -1,10 +1,11 @@
CC = gcc
WARNS = -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-but-set-variable \
-Wno-unused-result
LIBS = -lncurses -L ~/lib -lstrophe -lxml2 -lexpat -lssl -lresolv `pkg-config --libs glib-2.0`
LIBS = -lncurses -L ~/lib -lstrophe -lxml2 -lexpat -lssl -lresolv \
`pkg-config --libs glib-2.0` `pkg-config --libs libnotify`
TESTLIB = -L ~/lib -l headunit `pkg-config --libs glib-2.0`
CPPLIB = -lstdc++
CFLAGS = -I ~/include -O3 $(WARNS) $(LIBS) `pkg-config --cflags glib-2.0`
CFLAGS = -I ~/include -O3 $(WARNS) $(LIBS) `pkg-config --cflags glib-2.0` `pkg-config --cflags libnotify`
OBJS = log.o windows.o title_bar.o status_bar.o input_win.o jabber.o \
profanity.o util.o command.o history.o contact_list.o prof_history.o \
contact.o preferences.o prof_autocomplete.o common.o main.o

View File

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