diff options
author | Max Kellermann <max@duempel.org> | 2008-10-01 09:38:25 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-01 09:38:25 +0200 |
commit | e1c9ec5a639075ec0b1f0ac50543626d28db7cd6 (patch) | |
tree | 327a6996cf28b81a7bf19ae1f5aaa87271760124 | |
parent | eaf6040b4488b82d57f4bde69dca0e736a815192 (diff) | |
download | mpd-e1c9ec5a639075ec0b1f0ac50543626d28db7cd6.tar.gz mpd-e1c9ec5a639075ec0b1f0ac50543626d28db7cd6.tar.xz mpd-e1c9ec5a639075ec0b1f0ac50543626d28db7cd6.zip |
screen_artist: added reload_lists()
Some callers of update_metalist() want to reload the list contents.
Add an optimized function reload_lists() which does not modify the
global variables "mode", "artist", "album".
-rw-r--r-- | src/screen_artist.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/screen_artist.c b/src/screen_artist.c index 5dbb2c03b..340d8f22a 100644 --- a/src/screen_artist.c +++ b/src/screen_artist.c @@ -258,6 +258,26 @@ update_metalist(mpdclient_t *c, char *m_artist, char *m_album) } } +static void +reload_lists(struct mpdclient *c) +{ + free_lists(c); + + switch (mode) { + case LIST_ARTISTS: + load_artist_list(c); + break; + + case LIST_ALBUMS: + load_album_list(c); + break; + + case LIST_SONGS: + load_song_list(c); + break; + } +} + /* db updated */ static void browse_callback(mpdclient_t *c, int event, mpd_unused gpointer data) @@ -265,7 +285,7 @@ browse_callback(mpdclient_t *c, int event, mpd_unused gpointer data) switch(event) { case BROWSE_DB_UPDATED: D("screen_artist.c> browse_callback() [BROWSE_DB_UPDATED]\n"); - update_metalist(c, g_strdup(artist), g_strdup(album)); + reload_lists(c); break; default: break; @@ -301,7 +321,7 @@ open(mpd_unused screen_t *screen, mpdclient_t *c) static gboolean callback_installed = FALSE; if (metalist == NULL && browser.filelist == NULL) - update_metalist(c, NULL, NULL); + reload_lists(c); if (!callback_installed) { mpdclient_install_browse_callback(c, browse_callback); callback_installed = TRUE; @@ -544,7 +564,7 @@ artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) /* continue and update... */ case CMD_SCREEN_UPDATE: - update_metalist(c, g_strdup(artist), g_strdup(album)); + reload_lists(c); screen_status_printf(_("Screen updated!")); return 0; |