From: Max Kellermann Date: Sat, 17 Oct 2009 22:57:11 +0000 (+0200) Subject: mpdclient: removed mpdclient_cmd_play() X-Git-Tag: release-0.16~91 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4b487197fc27641a7fb984e8bf9823f34f1e4146;p=ncmpc.git mpdclient: removed mpdclient_cmd_play() Call mpdclient_run_play_id() directly. --- diff --git a/src/mpdclient.c b/src/mpdclient.c index 748baed..dbe931c 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -261,23 +261,6 @@ mpdclient_put_connection(struct mpdclient *c) /*** MPD Commands **********************************************************/ /****************************************************************************/ -bool -mpdclient_cmd_play(struct mpdclient *c, gint idx) -{ - struct mpd_connection *connection = mpdclient_get_connection(c); - const struct mpd_song *song = playlist_get_song(&c->playlist, idx); - - if (connection == NULL) - return false; - - if (song) - mpd_send_play_id(connection, mpd_song_get_id(song)); - else - mpd_send_play(connection); - - return mpdclient_finish_command(c); -} - bool mpdclient_cmd_crop(struct mpdclient *c) { diff --git a/src/mpdclient.h b/src/mpdclient.h index 6c8758f..9f22d26 100644 --- a/src/mpdclient.h +++ b/src/mpdclient.h @@ -92,9 +92,6 @@ mpdclient_ui_error(const char *message); /*** MPD Commands **********************************************************/ -bool -mpdclient_cmd_play(struct mpdclient *c, gint index); - bool mpdclient_cmd_crop(struct mpdclient *c); diff --git a/src/screen_queue.c b/src/screen_queue.c index 491d332..0130520 100644 --- a/src/screen_queue.c +++ b/src/screen_queue.c @@ -616,8 +616,16 @@ handle_mouse_event(struct mpdclient *c) if (bstate & BUTTON1_CLICKED) { /* play */ - if (lw->selected < playlist_length(playlist)) - mpdclient_cmd_play(c, lw->start + row); + const struct mpd_song *song = screen_queue_selected_song(); + if (song != NULL) { + struct mpd_connection *connection = + mpdclient_get_connection(c); + + if (connection != NULL && + !mpd_run_play_id(connection, + mpd_song_get_id(song))) + mpdclient_handle_error(c); + } } else if (bstate & BUTTON3_CLICKED) { /* delete */ if (lw->selected == old_selected) @@ -640,6 +648,7 @@ screen_queue_cmd(struct mpdclient *c, command_t cmd) static command_t cached_cmd = CMD_NONE; command_t prev_cmd = cached_cmd; struct list_window_range range; + const struct mpd_song *song; cached_cmd = cmd; @@ -729,7 +738,15 @@ screen_queue_cmd(struct mpdclient *c, command_t cmd) switch(cmd) { case CMD_PLAY: - mpdclient_cmd_play(c, lw->selected); + song = screen_queue_selected_song(); + if (song == NULL) + return false; + + connection = mpdclient_get_connection(c); + if (connection != NULL && + !mpd_run_play_id(connection, mpd_song_get_id(song))) + mpdclient_handle_error(c); + return true; case CMD_DELETE: