diff options
author | 2010-01-04 21:47:18 +0200 | |
---|---|---|
committer | 2010-01-04 21:47:18 +0200 | |
commit | 470763e1cf4ffa3e8a3e4110eadeb8a72e42c8eb (patch) | |
tree | 8b47ac8886cb10f7b2a0ac48f40e3044e703a912 | |
parent | 1d9340c4852cea9328219a1b9a3104f5772e0904 (diff) |
Notifications are replaced with new
-rw-r--r-- | plugins/notification/notification.c | 18 |
1 files 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; } |