summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 36acd5f)
raw | patch | inline | side by side (parent: 36acd5f)
author | Yannick LM <yannicklm1337@gmail.com> | |
Sun, 21 Sep 2008 11:50:26 +0000 (13:50 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Sun, 21 Sep 2008 11:50:26 +0000 (13:50 +0200) |
The "crop" command deletes all songs from the playlist, except the one
currently being played.
currently being played.
src/command.c | patch | blob | history | |
src/command.h | patch | blob | history | |
src/mpdclient.c | patch | blob | history | |
src/mpdclient.h | patch | blob | history | |
src/screen.c | patch | blob | history | |
src/screen_help.c | patch | blob | history |
diff --git a/src/command.c b/src/command.c
index afb7e42e41ea3a1a092859e0378a1b642c2cf73e..0ae90338194157da3b30e2c1f1f1eebf97cfff6f 100644 (file)
--- a/src/command.c
+++ b/src/command.c
N_("Pause") },
{ { 's', BS, 0 }, 0, CMD_STOP, "stop",
N_("Stop") },
+ { { 'o', 0, 0 }, 0, CMD_CROP, "crop",
+ N_("Crop") },
{ { '>', 0, 0 }, 0, CMD_TRACK_NEXT, "next",
N_("Next track") },
{ { '<', 0, 0 }, 0, CMD_TRACK_PREVIOUS, "prev",
diff --git a/src/command.h b/src/command.h
index dab6c99cef93746921f2eaf643d2d26241da42d8..f4b6859e84cf93757cee869b4d8a8758ddef4d2e 100644 (file)
--- a/src/command.h
+++ b/src/command.h
CMD_SELECT_ALL,
CMD_PAUSE,
CMD_STOP,
+ CMD_CROP,
CMD_TRACK_NEXT,
CMD_TRACK_PREVIOUS,
CMD_SEEK_FORWARD,
diff --git a/src/mpdclient.c b/src/mpdclient.c
index 2c46d8e9069b09201069a9a32221d10605cd18a4..6d9d72b9c206789e6694400783397f8b13553ba1 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
return mpdclient_finish_command(c);
}
+gint
+mpdclient_cmd_crop(mpdclient_t *c)
+{
+ mpd_Status *status;
+ int length;
+
+ mpd_sendStatusCommand(c->connection);
+ status = mpd_getStatus(c->connection);
+ length = status->playlistLength - 1;
+
+ if (length <= 0) {
+ mpd_freeStatus(status);
+ screen_status_message("You have to have a playlist longer than 1 song in length to crop");
+ } else if (status->state == 3 || status->state == 2) {
+ /* If playing or paused */
+
+ mpd_sendCommandListBegin( c->connection );
+
+ while (length >= 0) {
+ if (length != status->song)
+ mpd_sendDeleteCommand(c->connection, length);
+
+ length--;
+ }
+
+ mpd_sendCommandListEnd(c->connection);
+ mpd_freeStatus(status);
+ } else {
+ mpd_freeStatus(status);
+ screen_status_message("You need to be playing to crop the playlist\n");
+ }
+
+ return mpdclient_finish_command(c);
+}
+
gint
mpdclient_cmd_stop(mpdclient_t *c)
{
diff --git a/src/mpdclient.h b/src/mpdclient.h
index c55e15453c5f8ae5e6668ae7f8267ec20fca39f5..2735f04ffa067d5cf9c12ff888704143281ab90a 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
/*** MPD Commands **********************************************************/
gint mpdclient_cmd_play(mpdclient_t *c, gint index);
gint mpdclient_cmd_pause(mpdclient_t *c, gint value);
+gint
+mpdclient_cmd_crop(mpdclient_t *c);
gint mpdclient_cmd_stop(mpdclient_t *c);
gint mpdclient_cmd_next(mpdclient_t *c);
gint mpdclient_cmd_prev(mpdclient_t *c);
diff --git a/src/screen.c b/src/screen.c
index e510b168265ed7f3a3a3ea781890723a51507c7b..2a5d6416f4d04adca020188dffb2488afc377545 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
case CMD_STOP:
mpdclient_cmd_stop(c);
break;
+ case CMD_CROP:
+ mpdclient_cmd_crop(c);
+ break;
case CMD_SEEK_FORWARD:
if (!IS_STOPPED(c->status->state)) {
if (c->song && seek_id != c->song->id) {
diff --git a/src/screen_help.c b/src/screen_help.c
index 7416e6e404f6a6dfcaaf5d35d646fe2ecbbf032d..79b8fa722ef146a9e638be46515285f42644da07 100644 (file)
--- a/src/screen_help.c
+++ b/src/screen_help.c
{ 2, CMD_NONE, NULL },
{ 0, CMD_STOP, NULL },
{ 0, CMD_PAUSE, NULL },
+ { 0, CMD_CROP, NULL },
{ 0, CMD_TRACK_NEXT, NULL },
{ 0, CMD_TRACK_PREVIOUS, NULL },
{ 0, CMD_SEEK_FORWARD, NULL },