Mercurial > audlegacy
changeset 1509:ae369659010a trunk
[svn] Added awareness of the difference between stopped and playing.
author | deitarion |
---|---|
date | Sun, 06 Aug 2006 02:52:27 -0700 |
parents | 2e1e5dae8f4c |
children | c9ac8b6679c9 |
files | ChangeLog Plugins/General/notify/notify.c |
diffstat | 2 files changed, 35 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sun Aug 06 01:54:32 2006 -0700 +++ b/ChangeLog Sun Aug 06 02:52:27 2006 -0700 @@ -1,3 +1,13 @@ +2006-08-06 08:54:32 +0000 William Pitcock <nenolod@nenolod.net> + revision [1930] + - prepare to add an optional libxml2 dependency + + + Changes: Modified: + +188 -0 trunk/m4/libxml.m4 + +2 -0 trunk/mk/rules.mk.in + + 2006-08-06 08:53:29 +0000 William Pitcock <nenolod@nenolod.net> revision [1928] - incomplete stuff
--- a/Plugins/General/notify/notify.c Sun Aug 06 01:54:32 2006 -0700 +++ b/Plugins/General/notify/notify.c Sun Aug 06 02:52:27 2006 -0700 @@ -10,6 +10,7 @@ #include <libnotify/notify.h> #include "audacious/plugin.h" #include "audacious/playlist.h" +#include "audacious/input.h" #include "config.h" @@ -20,6 +21,7 @@ static gint notify_playlist_pos = -1; static gchar *previous_title = NULL; +static gboolean was_playing = FALSE; /* our API. */ static void do_notification(gchar *summary, gchar *message, gchar *icon_uri); @@ -44,6 +46,10 @@ static void init(void) { + /* + TODO: I assume 100 means 100ms checking interval? Why not 200? + It would be twice as efficient and the user shouldn't notice any difference. + */ timeout_tag = gtk_timeout_add(100, watchdog_func, NULL); } @@ -63,9 +69,20 @@ gint pos = playlist_get_position(); gchar *title = playlist_get_songtitle(pos); - if ((title != NULL && previous_title != NULL && - g_strcasecmp(title, previous_title)) || - (title == NULL && pos != notify_playlist_pos)) + /* + Trigger a notice if a song is now playing and one of the following is true: + 1. it has a different title from the last time this ran + 2. there is no title but it's a different playlist position + 3. the player was stopped the last time this ran + (listed in the order they are checked) + + FIXME: The same song twice in a row will only get announced once. + Proposed Remedy: Add a check for playback progress. + */ + if (ip_data.playing && + ((title != NULL && previous_title != NULL && + g_strcasecmp(title, previous_title)) || + (title == NULL && pos != notify_playlist_pos) || (! was_playing))) { gchar *tmpbuf; TitleInput *tuple; @@ -75,6 +92,10 @@ if (tuple == NULL) return TRUE; + /* + FIXME: This is useless for formats without metadata. + Proposed Remedy: playlist_get_filename(pos) instead of _("Unknown Track") + */ tmpbuf = g_markup_printf_escaped("<b>%s</b>\n<i>%s</i>\n%s", (tuple->performer ? tuple->performer : _("Unknown Artist")), (tuple->album_name ? tuple->album_name : _("Unknown Album")), @@ -93,6 +114,7 @@ } previous_title = g_strdup(title); + was_playing = ip_data.playing; return TRUE; }