diff options
author | James Booth <boothj5@gmail.com> | 2012-09-24 20:51:10 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-09-24 20:51:10 +0100 |
commit | ff7174db09e9f6687a9fd88bba80fa89e889f2d1 (patch) | |
tree | f1af8f2e7b1c54c27826fd2d7854f22a39410697 | |
parent | 3ecc6433e8bf61057c4cc165b8628ecc2ad25cf3 (diff) | |
download | profani-tty-ff7174db09e9f6687a9fd88bba80fa89e889f2d1.tar.gz |
Init and uninit libnotify
-rw-r--r-- | src/windows.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/windows.c b/src/windows.c index d8aa3487..0aa9ab6a 100644 --- a/src/windows.c +++ b/src/windows.c @@ -145,6 +145,11 @@ gui_refresh(void) void gui_close(void) { +#ifdef HAVE_LIBNOTIFY + if (notify_is_initted()) { + notify_uninit(); + } +#endif endwin(); } @@ -290,17 +295,24 @@ static void _win_notify(const char * const message, int timeout, const char * const category) { - notify_init("Profanity"); - - // create a new notification - NotifyNotification *notification; - notification = notify_notification_new("Profanity", message, NULL); - notify_notification_set_timeout(notification, timeout); - notify_notification_set_category(notification, category); - notify_notification_set_urgency(notification, NOTIFY_URGENCY_NORMAL); - - GError *error = NULL; - notify_notification_show(notification, &error); + gboolean notify_initted = notify_is_initted(); + + if (!notify_initted) { + notify_initted = notify_init("Profanity"); + } + + if (notify_initted) { + NotifyNotification *notification; + notification = notify_notification_new("Profanity", message, NULL); + notify_notification_set_timeout(notification, timeout); + notify_notification_set_category(notification, category); + notify_notification_set_urgency(notification, NOTIFY_URGENCY_NORMAL); + + GError *error = NULL; + notify_notification_show(notification, &error); + } else { + log_error("Libnotify initialisation error."); + } } static void |