From 470763e1cf4ffa3e8a3e4110eadeb8a72e42c8eb Mon Sep 17 00:00:00 2001 From: Viktor Semykin Date: Mon, 4 Jan 2010 21:47:18 +0200 Subject: Notifications are replaced with new --- plugins/notification/notification.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/plugins/notification/notification.c b/plugins/notification/notification.c index 28df06fc..91028350 100644 --- a/plugins/notification/notification.c +++ b/plugins/notification/notification.c @@ -5,6 +5,15 @@ static DB_misc_t plugin; static DB_functions_t *deadbeef; +static NotifyNotification *ntf; + +static void +show_notification (const char *summary, const char *body) +{ + notify_notification_close (ntf, NULL); + notify_notification_update (ntf, summary, body, NULL); + notify_notification_show (ntf, NULL); +} static int songchanged (DB_event_trackchange_t *ev, uintptr_t data) { @@ -13,16 +22,14 @@ songchanged (DB_event_trackchange_t *ev, uintptr_t data) { const char *album = deadbeef->pl_find_meta (track, "album"); const char *title = deadbeef->pl_find_meta (track, "title"); char body [1024]; - GError *err; snprintf (body, sizeof (body), "%s - %s", artist, album); - NotifyNotification *ntf = notify_notification_new (title, body, NULL, NULL); - notify_notification_set_timeout (ntf, NOTIFY_EXPIRES_DEFAULT); - notify_notification_show (ntf, NULL); + show_notification (title, body); return 0; } static int notification_stop (void) { + notify_notification_close (ntf, NULL); deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_SONGCHANGED, DB_CALLBACK (songchanged), 0); } @@ -30,6 +37,9 @@ static int notification_start (void) { notify_init ("deadbeef"); + ntf = notify_notification_new (NULL, NULL, NULL, NULL); + notify_notification_set_timeout (ntf, NOTIFY_EXPIRES_DEFAULT); + deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_SONGCHANGED, DB_CALLBACK (songchanged), 0); return 1; } -- cgit v1.2.3