summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cde030e)
raw | patch | inline | side by side (parent: cde030e)
author | Max Kellermann <max@duempel.org> | |
Thu, 18 Sep 2008 21:35:12 +0000 (23:35 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Thu, 18 Sep 2008 21:35:12 +0000 (23:35 +0200) |
Merge code from all 3 browser screens into one generic browser
function.
function.
diff --git a/src/screen_artist.c b/src/screen_artist.c
index a839003953ef419922ee4846b04f0ad22cfadd5b..c5d5a268b11b42d0dde51e0e5114f0a70c87fce1 100644 (file)
--- a/src/screen_artist.c
+++ b/src/screen_artist.c
/* the playlist have been updated -> fix highlights */
static void
-playlist_changed_callback(mpdclient_t *c, int event, mpd_unused gpointer data)
+playlist_changed_callback(mpdclient_t *c, int event, gpointer data)
{
- if (browser.filelist == NULL)
- return;
-
- D("screen_artist.c> playlist_callback() [%d]\n", event);
- switch(event) {
- case PLAYLIST_EVENT_CLEAR:
- clear_highlights(browser.filelist);
- break;
- default:
- sync_highlights(c, browser.filelist);
- break;
- }
+ browser_playlist_changed(&browser, c, event, data);
}
/* fetch artists/albums/songs from mpd */
diff --git a/src/screen_browser.c b/src/screen_browser.c
index 737b1387573a9dbacdcf9d3e81248eb1147bb196..406d205cd8cec0df3bfcf747cec7631eb9c3bc24 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
#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);
}
/* 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);
}
}
+/* 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)
diff --git a/src/screen_browser.h b/src/screen_browser.h
index fbe131c5872fc09359e7e563fddfb366f477150a..a867eda0a7a0b34f339fc334051d2b34d42dd904 100644 (file)
--- a/src/screen_browser.h
+++ b/src/screen_browser.h
mpdclient_filelist_t *filelist;
};
-void clear_highlights(mpdclient_filelist_t *filelist);
-void sync_highlights(mpdclient_t *c, mpdclient_filelist_t *filelist);
-void set_highlight(mpdclient_filelist_t *filelist,
- mpd_Song *song,
- int highlight);
+void
+sync_highlights(mpdclient_t *c, mpdclient_filelist_t *fl);
+void
+browser_playlist_changed(struct screen_browser *browser, mpdclient_t *c,
+ int event, gpointer data);
const char *browser_lw_callback(unsigned index, int *highlight, void *filelist);
diff --git a/src/screen_file.c b/src/screen_file.c
index 801c61f9f311fa66a3e128b02bc69af36c2e9aa7..ea20f950695677780bfd1c6dc8f95e2e80e40803 100644 (file)
--- a/src/screen_file.c
+++ b/src/screen_file.c
static void
playlist_changed_callback(mpdclient_t *c, int event, gpointer data)
{
- 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;
- }
+ browser_playlist_changed(&browser, c, event, data);
}
static int
diff --git a/src/screen_search.c b/src/screen_search.c
index 365a23c6f77413520b2383ba50e183c400e72d84..549221e74bbf7f8ef815b33039f7bc439e105537 100644 (file)
--- a/src/screen_search.c
+++ b/src/screen_search.c
/* the playlist have been updated -> fix highlights */
static void
-playlist_changed_callback(mpdclient_t *c, int event, mpd_unused gpointer data)
+playlist_changed_callback(mpdclient_t *c, int event, gpointer data)
{
- if (browser.filelist == NULL)
- return;
- D("screen_search.c> playlist_callback() [%d]\n", event);
- switch(event) {
- case PLAYLIST_EVENT_CLEAR:
- clear_highlights(browser.filelist);
- break;
- default:
- sync_highlights(c, browser.filelist);
- break;
- }
+ browser_playlist_changed(&browser, c, event, data);
}
/* sanity check search mode value */