From c9263b8396d3bd116144230df2715e8c33d10df6 Mon Sep 17 00:00:00 2001 From: unK Date: Sat, 6 Sep 2008 13:55:35 +0200 Subject: [PATCH] add playlist renaming support --- src/mpdpp.cpp | 9 +++++++++ src/mpdpp.h | 1 + src/ncmpcpp.cpp | 17 +++++++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/mpdpp.cpp b/src/mpdpp.cpp index 1cb65c3b..aee731d8 100644 --- a/src/mpdpp.cpp +++ b/src/mpdpp.cpp @@ -302,6 +302,15 @@ void MPDConnection::Move(const string &path, int from, int to) const } } +void MPDConnection::Rename(const string &from, const string &to) const +{ + if (isConnected) + { + mpd_sendRenameCommand(itsConnection, from.c_str(), to.c_str()); + mpd_finishCommand(itsConnection); + } +} + void MPDConnection::GetPlaylistChanges(long long id, SongList &v) const { if (isConnected) diff --git a/src/mpdpp.h b/src/mpdpp.h index 70dfb8c7..ed754e98 100644 --- a/src/mpdpp.h +++ b/src/mpdpp.h @@ -150,6 +150,7 @@ class MPDConnection void AddToPlaylist(const string &, const Song &) const; void AddToPlaylist(const string &, const string &) const; void Move(const string &, int, int) const; + void Rename(const string &, const string &) const; void StartSearch(bool) const; void StartFieldSearch(mpd_TagItems); diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 76a98837..694fc959 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -57,10 +57,10 @@ #ifdef HAVE_TAGLIB_H const string tag_screen = "Tag editor"; - const string tag_screen_keydesc = "Edit song's tags\n"; + const string tag_screen_keydesc = "Edit song's tags/playlist's name\n"; #else const string tag_screen = "Tag info"; - const string tag_screen_keydesc = "Show song's tags\n"; + const string tag_screen_keydesc = "Show song's tags/edit playlist's name\n"; #endif ncmpcpp_config Config; @@ -1977,6 +1977,19 @@ int main(int argc, char *argv[]) else ShowMessage("Cannot read file!"); } + else if (wCurrent == mPlaylistList) + { + LOCK_STATUSBAR; + wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]Playlist:[/b] ", 1); + string new_name = wFooter->GetString(mPlaylistList->GetOption()); + UNLOCK_STATUSBAR; + if (!new_name.empty() && new_name != mPlaylistList->GetOption()) + { + Mpd->Rename(mPlaylistList->GetOption(), new_name); + ShowMessage("Playlist '" + mPlaylistList->GetOption() + "' renamed to '" + new_name + "'"); + mPlaylistList->Clear(0); + } + } } else if (Keypressed(input, Key.GoToContainingDir)) {