From 8ab805abd561124ef46ae4d7aab8d37416a5b7d5 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Wed, 10 Jun 2009 18:43:26 +0200 Subject: [PATCH] ask before clearing playlist in playlist editor --- src/ncmpcpp.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 77f69849..e746bcd9 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -1650,17 +1650,36 @@ int main(int argc, char *argv[]) { if (myScreen == myPlaylistEditor && myPlaylistEditor->Playlists->Empty()) continue; - ShowMessage("Clearing playlist..."); + int in = 0; if (myScreen == myPlaylistEditor) { - Mpd->ClearPlaylist(locale_to_utf_cpy(myPlaylistEditor->Playlists->Current())); - myPlaylistEditor->Content->Clear(0); + LockStatusbar(); + Statusbar() << "Do you really want to clear playlist \"" << myPlaylistEditor->Playlists->Current() << "\" ? [y/n] "; + curs_set(1); + do + { + TraceMpdStatus(); + wFooter->ReadKey(in); + } + while (in != 'y' && in != 'n'); + curs_set(0); + UnlockStatusbar(); + + if (in == 'y') + { + Mpd->ClearPlaylist(locale_to_utf_cpy(myPlaylistEditor->Playlists->Current())); + myPlaylistEditor->Content->Clear(0); + } + else + ShowMessage("Aborted!"); } else { + ShowMessage("Clearing playlist..."); Mpd->ClearPlaylist(); } - ShowMessage("Cleared playlist!"); + if (myScreen != myPlaylistEditor || in == 'y') + ShowMessage("Playlist cleared!"); } // if playlist is cleared, items list have to be updated, but this // can be blocked if new song was added to playlist less than one