From: Max Kellermann Date: Wed, 1 Oct 2008 07:24:59 +0000 (+0200) Subject: screen_artist: moved code to artist_lw_cmd() X-Git-Tag: v0.12_alpha1~134 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f1621fda772bc464a4a224e586882d4f6635643c;p=ncmpc.git screen_artist: moved code to artist_lw_cmd() To unify the code, wrap list_window_cmd() in artist_lw_cmd(), which properly checks the current mode. --- diff --git a/src/screen_artist.c b/src/screen_artist.c index 07a3f8f..03b4fed 100644 --- a/src/screen_artist.c +++ b/src/screen_artist.c @@ -286,15 +286,32 @@ add_query(mpdclient_t *c, int table, char *_filter) } } +static int +artist_lw_cmd(command_t cmd) +{ + switch (mode) { + case LIST_ARTISTS: + case LIST_ALBUMS: + return list_window_cmd(browser.lw, metalist_length, cmd); + + case LIST_SONGS: + return list_window_cmd(browser.lw, + filelist_length(browser.filelist), + cmd); + } + + assert(0); + return 0; +} + static int artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) { char *selected; int ret; - if (browser.filelist == NULL && metalist != NULL && - list_window_cmd(browser.lw, metalist_length, cmd)) { - list_window_paint(browser.lw, artist_lw_callback, metalist); + if (artist_lw_cmd(cmd)) { + artist_repaint(); wrefresh(browser.lw->w); return 1; } @@ -467,15 +484,6 @@ artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) break; } - if (browser.filelist != NULL && - list_window_cmd(browser.lw, filelist_length(browser.filelist), - cmd)) { - list_window_paint(browser.lw, browser_lw_callback, - browser.filelist); - wrefresh(browser.lw->w); - return 1; - } - return 0; }