diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-02-02 20:07:24 +0100 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-02-02 20:07:24 +0100 |
commit | 674f33345ca886546cb0a57ed338eb13cb2c82b0 (patch) | |
tree | 36fd73ba6e276c158d5ab3816b52baddd7f70c98 | |
parent | 8608664e0d72216d89c271d2892c62544e261027 (diff) |
fixed libnotify support
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | plugins/gtkui/gtkplaylist.c | 32 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 26 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.h | 4 |
4 files changed, 35 insertions, 30 deletions
diff --git a/configure.ac b/configure.ac index d9337fbb..4e2bd679 100644 --- a/configure.ac +++ b/configure.ac @@ -192,10 +192,8 @@ fi AM_CONDITIONAL(HAVE_NOTIFY, test $HAVE_NOTIFY) if test ${HAVE_NOTIFY}; then AC_DEFINE(HAVE_NOTIFY,1,[Use libnotify]) - NOTIFY_DIR="plugins/notification" AC_SUBST(NOTIFY_DEPS_CFLAGS) AC_SUBST(NOTIFY_DEPS_LIBS) - AC_SUBST(NOTIFY_DIR) fi dnl *** OSS output (partly stolen from audacious) @@ -307,7 +305,6 @@ plugins/nullout/Makefile plugins/vtx/Makefile plugins/adplug/Makefile plugins/ffmpeg/Makefile -plugins/notification/Makefile plugins/oss/Makefile deadbeef.desktop ]) diff --git a/plugins/gtkui/gtkplaylist.c b/plugins/gtkui/gtkplaylist.c index 7b0912b9..0a160b97 100644 --- a/plugins/gtkui/gtkplaylist.c +++ b/plugins/gtkui/gtkplaylist.c @@ -16,7 +16,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H -# include <config.h> +# include "../../config.h" +#endif +#if HAVE_NOTIFY +#include <libnotify/notify.h> #endif #include <gtk/gtk.h> @@ -40,6 +43,7 @@ #include "../../session.h" #include "../../deadbeef.h" #include "parser.h" +#include "gtkui.h" #define min(x,y) ((x)<(y)?(x):(y)) #define max(x,y) ((x)>(y)?(x):(y)) @@ -1832,12 +1836,38 @@ struct fromto_t { int to; }; +#if HAVE_NOTIFY +static NotifyNotification* notification; +#endif + static gboolean update_win_title_idle (gpointer data) { struct fromto_t *ft = (struct fromto_t *)data; int from = ft->from; int to = ft->to; free (ft); + + // show notification +#if HAVE_NOTIFY + if (to != -1 && deadbeef->conf_get_int ("libnotify.enable", 0)) { + DB_playItem_t *track = deadbeef->pl_get_for_idx (to); + if (track) { + char cmd [1024]; + deadbeef->pl_format_title (track, -1, cmd, sizeof (cmd), -1, deadbeef->conf_get_str ("libnotify.format", NOTIFY_DEFAULT_FORMAT)); + if (notify_is_initted ()) { + if (notification) { + notify_notification_close (notification, NULL); + } + notification = notify_notification_new ("DeaDBeeF", cmd, NULL, NULL); + if (notification) { + notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT); + notify_notification_show (notification, NULL); + } + } + } + } +#endif + // update window title if (from >= 0 || to >= 0) { if (to >= 0) { diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 279d281f..6b810541 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -58,11 +58,6 @@ static int sb_context_id = -1; static char sb_text[512]; static float last_songpos = -1; -#if HAVE_NOTIFY -#define NOTIFY_DEFAULT_FORMAT "%a - %t" -static NotifyNotification* notification; -#endif - static gboolean update_songinfo (gpointer ctx) { char sbtext_new[512] = "-"; @@ -261,27 +256,6 @@ gtkui_on_activate (DB_event_t *ev, uintptr_t data) { static int gtkui_on_songchanged (DB_event_trackchange_t *ev, uintptr_t data) { gtkpl_songchanged_wrapper (ev->from, ev->to); -#if HAVE_NOTIFY - if (deadbeef->conf_get_int ("libnotify.enable", 0)) { - DB_playItem_t *track = deadbeef->pl_get_for_idx (ev->to); - if (track) { - char cmd [1024]; - deadbeef->pl_format_title (track, -1, cmd, sizeof (cmd), -1, deadbeef->conf_get_str ("libnotify.format", NOTIFY_DEFAULT_FORMAT)); - if (notify_is_initted ()) { - if (notification) { - notify_notification_close (notification, NULL); - } - else { - notification = notify_notification_new ("DeaDBeeF", cmd, NULL, NULL); - } - if (notification) { - notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT); - notify_notification_show (notification, NULL); - } - } - } - } -#endif return 0; } diff --git a/plugins/gtkui/gtkui.h b/plugins/gtkui/gtkui.h index fd8e1166..2031b502 100644 --- a/plugins/gtkui/gtkui.h +++ b/plugins/gtkui/gtkui.h @@ -19,6 +19,10 @@ #ifndef __GTKUI_H #define __GTKUI_H +#if HAVE_NOTIFY +#define NOTIFY_DEFAULT_FORMAT "%a - %t" +#endif + extern DB_functions_t *deadbeef; struct _GSList; |