aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen_browser.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-18 23:35:12 +0200
committerMax Kellermann <max@duempel.org>2008-09-18 23:35:12 +0200
commit92cf0efffffeb95fbefc57505d778e6fdbd772d4 (patch)
tree153b81b6b0903d1a32a00ab6d4d71816e49b9924 /src/screen_browser.c
parentcde030e211b3d9ea517403b5d5547b6d374fc470 (diff)
downloadmpd-92cf0efffffeb95fbefc57505d778e6fdbd772d4.tar.gz
mpd-92cf0efffffeb95fbefc57505d778e6fdbd772d4.tar.xz
mpd-92cf0efffffeb95fbefc57505d778e6fdbd772d4.zip
screen_browser: moved code to browser_playlist_changed()
Merge code from all 3 browser screens into one generic browser function.
Diffstat (limited to '')
-rw-r--r--src/screen_browser.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/screen_browser.c b/src/screen_browser.c
index 737b13875..406d205cd 100644
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
@@ -37,7 +37,7 @@
#define HIGHLIGHT (0x01)
/* clear the highlight flag for all items in the filelist */
-void
+static void
clear_highlights(mpdclient_filelist_t *fl)
{
GList *list = g_list_first(fl->list);
@@ -51,7 +51,7 @@ clear_highlights(mpdclient_filelist_t *fl)
}
/* change the highlight flag for a song */
-void
+static void
set_highlight(mpdclient_filelist_t *fl, mpd_Song *song, int highlight)
{
GList *list = g_list_first(fl->list);
@@ -99,6 +99,33 @@ sync_highlights(mpdclient_t *c, mpdclient_filelist_t *fl)
}
}
+/* the playlist have been updated -> fix highlights */
+void
+browser_playlist_changed(struct screen_browser *browser, mpdclient_t *c,
+ int event, gpointer data)
+{
+ if (browser->filelist == NULL)
+ return;
+
+ D("screen_file.c> playlist_callback() [%d]\n", event);
+ switch(event) {
+ case PLAYLIST_EVENT_CLEAR:
+ clear_highlights(browser->filelist);
+ break;
+ case PLAYLIST_EVENT_ADD:
+ set_highlight(browser->filelist, (mpd_Song *) data, 1);
+ break;
+ case PLAYLIST_EVENT_DELETE:
+ set_highlight(browser->filelist, (mpd_Song *) data, 0);
+ break;
+ case PLAYLIST_EVENT_MOVE:
+ break;
+ default:
+ sync_highlights(c, browser->filelist);
+ break;
+ }
+}
+
/* list_window callback */
const char *
browser_lw_callback(unsigned idx, int *highlight, void *data)