From 953ebbb214f5f5f4cfc5aeaea3dc9959a8a0d8f2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 30 Sep 2009 19:09:54 +0200 Subject: [PATCH] screen_play: added helper function playlist_selected_song() --- src/screen_play.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/screen_play.c b/src/screen_play.c index 72335fc..8bbe60b 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -72,6 +72,15 @@ playlist_repaint(void) wrefresh(lw->w); } +static const struct mpd_song * +playlist_selected_song(void) +{ + return !lw->range_selection && + lw->selected < playlist_length(playlist) + ? playlist_get(playlist, lw->selected) + : NULL; +} + static void playlist_changed_callback(struct mpdclient *c, int event, gpointer data) { @@ -745,8 +754,8 @@ play_cmd(struct mpdclient *c, command_t cmd) #ifdef ENABLE_SONG_SCREEN case CMD_SCREEN_SONG: - if (lw->selected < playlist_length(&c->playlist)) { - screen_song_switch(c, playlist_get(&c->playlist, lw->selected)); + if (playlist_selected_song()) { + screen_song_switch(c, playlist_selected_song()); return true; } @@ -754,8 +763,8 @@ play_cmd(struct mpdclient *c, command_t cmd) #endif case CMD_LOCATE: - if (lw->selected < playlist_length(&c->playlist)) { - screen_file_goto_song(c, playlist_get(&c->playlist, lw->selected)); + if (playlist_selected_song()) { + screen_file_goto_song(c, playlist_selected_song()); return true; } -- 2.30.2