Code

screen_artist: moved code to artist_lw_cmd()
authorMax Kellermann <max@duempel.org>
Wed, 1 Oct 2008 07:24:59 +0000 (09:24 +0200)
committerMax Kellermann <max@duempel.org>
Wed, 1 Oct 2008 07:24:59 +0000 (09:24 +0200)
To unify the code, wrap list_window_cmd() in artist_lw_cmd(), which
properly checks the current mode.

src/screen_artist.c

index 07a3f8f649f95788131293d2bd03cc48fdbd92bf..03b4fed421ab69165d61a4776f750f389e834875 100644 (file)
@@ -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;
 }