make displayed messages more consistent

This commit is contained in:
Andrzej Rybczak
2012-08-14 18:17:30 +02:00
parent dad2bba13e
commit 77a3c73d9c
18 changed files with 95 additions and 113 deletions

View File

@@ -208,7 +208,7 @@ void Action::Seek()
if (!Mpd.GetTotalTime()) if (!Mpd.GetTotalTime())
{ {
ShowMessage("Unknown item length!"); ShowMessage("Unknown item length");
return; return;
} }
@@ -323,7 +323,7 @@ void Action::FindItem(const FindDirection fd)
return; return;
if (success) if (success)
ShowMessage("Searching finished!"); ShowMessage("Searching finished");
else else
ShowMessage("Unable to find \"%s\"", findme.c_str()); ShowMessage("Unable to find \"%s\"", findme.c_str());
@@ -390,7 +390,7 @@ bool Action::isMPDMusicDirSet()
{ {
if (Config.mpd_music_dir.empty()) if (Config.mpd_music_dir.empty())
{ {
ShowMessage("mpd_music_dir is not set!"); ShowMessage("Proper mpd_music_dir variable has to be set in configuration file");
return false; return false;
} }
return true; return true;
@@ -722,8 +722,7 @@ void Delete::Run()
{ {
for (size_t i = 0; i < myPlaylist->Items->Size(); ++i) for (size_t i = 0; i < myPlaylist->Items->Size(); ++i)
myPlaylist->Items->Select(i, 0); myPlaylist->Items->Select(i, 0);
myPlaylist->FixPositions(list.front()); ShowMessage("Selected items deleted");
ShowMessage("Selected items deleted!");
} }
} }
else else
@@ -744,14 +743,14 @@ void Delete::Run()
{ {
if (Mpd.DeletePlaylist(locale_to_utf_cpy(name))) if (Mpd.DeletePlaylist(locale_to_utf_cpy(name)))
{ {
const char msg[] = "Playlist \"%s\" deleted!"; const char msg[] = "Playlist \"%s\" deleted";
ShowMessage(msg, Shorten(TO_WSTRING(name), COLS-static_strlen(msg)).c_str()); ShowMessage(msg, Shorten(TO_WSTRING(name), COLS-static_strlen(msg)).c_str());
if (myBrowser->Main() && !myBrowser->isLocal() && myBrowser->CurrentDir() == "/") if (myBrowser->Main() && !myBrowser->isLocal() && myBrowser->CurrentDir() == "/")
myBrowser->GetDirectory("/"); myBrowser->GetDirectory("/");
} }
} }
else else
ShowMessage("Aborted!"); ShowMessage("Aborted");
if (myPlaylistEditor->Main()) // check if initialized if (myPlaylistEditor->Main()) // check if initialized
myPlaylistEditor->Playlists->Clear(); // make playlists list update itself myPlaylistEditor->Playlists->Clear(); // make playlists list update itself
} }
@@ -802,12 +801,12 @@ void Delete::Run()
name = it.type == itSong ? it.song->GetName() : it.name; name = it.type == itSong ? it.song->GetName() : it.name;
if (myBrowser->DeleteItem(it)) if (myBrowser->DeleteItem(it))
{ {
const char msg[] = "\"%s\" deleted!"; const char msg[] = "\"%s\" deleted";
ShowMessage(msg, Shorten(TO_WSTRING(name), COLS-static_strlen(msg)).c_str()); ShowMessage(msg, Shorten(TO_WSTRING(name), COLS-static_strlen(msg)).c_str());
} }
else else
{ {
const char msg[] = "Couldn't remove \"%s\": %s"; const char msg[] = "Couldn't delete \"%s\": %s";
ShowMessage(msg, Shorten(TO_WSTRING(name), COLS-static_strlen(msg)-25).c_str(), strerror(errno)); ShowMessage(msg, Shorten(TO_WSTRING(name), COLS-static_strlen(msg)-25).c_str(), strerror(errno));
success = 0; success = 0;
break; break;
@@ -822,7 +821,7 @@ void Delete::Run()
} }
} }
else else
ShowMessage("Aborted!"); ShowMessage("Aborted");
} }
# endif // !WIN32 # endif // !WIN32
@@ -841,7 +840,7 @@ void Delete::Run()
myPlaylistEditor->Content->DeleteOption(*it); myPlaylistEditor->Content->DeleteOption(*it);
} }
Mpd.CommitCommandsList(); Mpd.CommitCommandsList();
ShowMessage("Selected items deleted from playlist \"%s\"!", myPlaylistEditor->Playlists->Current().c_str()); ShowMessage("Selected items deleted from playlist \"%s\"", myPlaylistEditor->Playlists->Current().c_str());
} }
else else
{ {
@@ -883,7 +882,7 @@ void SavePlaylist::Run()
UnlockStatusbar(); UnlockStatusbar();
if (playlist_name.find("/") != std::string::npos) if (playlist_name.find("/") != std::string::npos)
{ {
ShowMessage("Playlist name cannot contain slashes!"); ShowMessage("Playlist name must not contain slashes");
return; return;
} }
if (!playlist_name.empty()) if (!playlist_name.empty())
@@ -902,7 +901,7 @@ void SavePlaylist::Run()
int result = Mpd.SavePlaylist(real_playlist_name); int result = Mpd.SavePlaylist(real_playlist_name);
if (result == MPD_ERROR_SUCCESS) if (result == MPD_ERROR_SUCCESS)
{ {
ShowMessage("Playlist saved as: %s", playlist_name.c_str()); ShowMessage("Playlist saved as \"%s\"", playlist_name.c_str());
if (myPlaylistEditor->Main()) // check if initialized if (myPlaylistEditor->Main()) // check if initialized
myPlaylistEditor->Playlists->Clear(); // make playlist's list update itself myPlaylistEditor->Playlists->Clear(); // make playlist's list update itself
} }
@@ -913,10 +912,10 @@ void SavePlaylist::Run()
{ {
Mpd.DeletePlaylist(real_playlist_name); Mpd.DeletePlaylist(real_playlist_name);
if (Mpd.SavePlaylist(real_playlist_name) == MPD_ERROR_SUCCESS) if (Mpd.SavePlaylist(real_playlist_name) == MPD_ERROR_SUCCESS)
ShowMessage("Playlist overwritten!"); ShowMessage("Playlist overwritten");
} }
else else
ShowMessage("Aborted!"); ShowMessage("Aborted");
if (myPlaylistEditor->Main()) // check if initialized if (myPlaylistEditor->Main()) // check if initialized
myPlaylistEditor->Playlists->Clear(); // make playlist's list update itself myPlaylistEditor->Playlists->Clear(); // make playlist's list update itself
if (myScreen == myPlaylist) if (myScreen == myPlaylist)
@@ -992,7 +991,7 @@ void MoveSelectedItemsTo::Run()
return; return;
if (!myPlaylist->Items->hasSelected()) if (!myPlaylist->Items->hasSelected())
{ {
ShowMessage("No selected items to move!"); ShowMessage("No selected items to move");
return; return;
} }
// remove search results as we may move them to different positions, but // remove search results as we may move them to different positions, but
@@ -1195,7 +1194,7 @@ void ToggleFetchingLyricsInBackground::Run()
{ {
# ifdef HAVE_CURL_CURL_H # ifdef HAVE_CURL_CURL_H
Config.fetch_lyrics_in_background = !Config.fetch_lyrics_in_background; Config.fetch_lyrics_in_background = !Config.fetch_lyrics_in_background;
ShowMessage("Fetching lyrics for currently playing song in background: %s", Config.fetch_lyrics_in_background ? "On" : "Off"); ShowMessage("Fetching lyrics for playing songs in background: %s", Config.fetch_lyrics_in_background ? "On" : "Off");
# endif // HAVE_CURL_CURL_H # endif // HAVE_CURL_CURL_H
} }
@@ -1399,7 +1398,7 @@ void EditLibraryTag::Run()
std::string path = Config.mpd_music_dir + (*it)->GetFile(); std::string path = Config.mpd_music_dir + (*it)->GetFile();
if (!TagEditor::WriteTags(**it)) if (!TagEditor::WriteTags(**it))
{ {
const char msg[] = "Error while updating tags in \"%s\"!"; const char msg[] = "Error while updating tags in \"%s\"";
ShowMessage(msg, Shorten(TO_WSTRING((*it)->GetFile()), COLS-static_strlen(msg)).c_str()); ShowMessage(msg, Shorten(TO_WSTRING((*it)->GetFile()), COLS-static_strlen(msg)).c_str());
success = 0; success = 0;
break; break;
@@ -1408,7 +1407,7 @@ void EditLibraryTag::Run()
if (success) if (success)
{ {
Mpd.UpdateDirectory(locale_to_utf_cpy(FindSharedDir(list))); Mpd.UpdateDirectory(locale_to_utf_cpy(FindSharedDir(list)));
ShowMessage("Tags updated successfully!"); ShowMessage("Tags updated successfully");
} }
FreeSongList(list); FreeSongList(list);
} }
@@ -1448,7 +1447,7 @@ void EditLibraryAlbum::Run()
TagLib::FileRef f(locale_to_utf_cpy(path).c_str()); TagLib::FileRef f(locale_to_utf_cpy(path).c_str());
if (f.isNull()) if (f.isNull())
{ {
const char msg[] = "Error while opening file \"%s\"!"; const char msg[] = "Error while opening file \"%s\"";
ShowMessage(msg, Shorten(TO_WSTRING((*myLibrary->Songs)[i].GetFile()), COLS-static_strlen(msg)).c_str()); ShowMessage(msg, Shorten(TO_WSTRING((*myLibrary->Songs)[i].GetFile()), COLS-static_strlen(msg)).c_str());
success = 0; success = 0;
break; break;
@@ -1456,7 +1455,7 @@ void EditLibraryAlbum::Run()
f.tag()->setAlbum(ToWString(new_album)); f.tag()->setAlbum(ToWString(new_album));
if (!f.save()) if (!f.save())
{ {
const char msg[] = "Error while writing tags in \"%s\"!"; const char msg[] = "Error while writing tags in \"%s\"";
ShowMessage(msg, Shorten(TO_WSTRING((*myLibrary->Songs)[i].GetFile()), COLS-static_strlen(msg)).c_str()); ShowMessage(msg, Shorten(TO_WSTRING((*myLibrary->Songs)[i].GetFile()), COLS-static_strlen(msg)).c_str());
success = 0; success = 0;
break; break;
@@ -1465,7 +1464,7 @@ void EditLibraryAlbum::Run()
if (success) if (success)
{ {
Mpd.UpdateDirectory(locale_to_utf_cpy(FindSharedDir(myLibrary->Songs))); Mpd.UpdateDirectory(locale_to_utf_cpy(FindSharedDir(myLibrary->Songs)));
ShowMessage("Tags updated successfully!"); ShowMessage("Tags updated successfully");
} }
} }
# endif // HAVE_TAGLIB_H # endif // HAVE_TAGLIB_H
@@ -1658,14 +1657,14 @@ void ToggleScreenLock::Run()
} }
if (part < 20 || part > 80) if (part < 20 || part > 80)
{ {
ShowMessage("Invalid number (%d)!", part); ShowMessage("Number is out of range");
return; return;
} }
Config.locked_screen_width_part = part/100.0; Config.locked_screen_width_part = part/100.0;
if (myScreen->Lock()) if (myScreen->Lock())
ShowMessage("Screen locked (with %d%% width)", part); ShowMessage("Screen locked (with %d%% width)", part);
else else
ShowMessage("Screen cannot be locked"); ShowMessage("Current screen can't be locked");
} }
} }
@@ -1700,7 +1699,7 @@ void JumpToPositionInSong::Run()
if (!Mpd.GetTotalTime()) if (!Mpd.GetTotalTime())
{ {
ShowMessage("Unknown item length!"); ShowMessage("Unknown item length");
return; return;
} }
@@ -1722,7 +1721,7 @@ void JumpToPositionInSong::Run()
if (newpos >= 0 && newpos <= Mpd.GetTotalTime()) if (newpos >= 0 && newpos <= Mpd.GetTotalTime())
Mpd.Seek(newpos); Mpd.Seek(newpos);
else else
ShowMessage("Out of bounds, 0:00-%s possible for mm:ss, %s given.", s->GetLength().c_str(), MPD::Song::ShowTime(newpos).c_str()); ShowMessage("Out of bounds, 0:00-%s possible for mm:ss, %s given", s->GetLength().c_str(), MPD::Song::ShowTime(newpos).c_str());
} }
else if (position.find('s') != std::string::npos) // probably position in seconds else if (position.find('s') != std::string::npos) // probably position in seconds
{ {
@@ -1730,7 +1729,7 @@ void JumpToPositionInSong::Run()
if (newpos >= 0 && newpos <= Mpd.GetTotalTime()) if (newpos >= 0 && newpos <= Mpd.GetTotalTime())
Mpd.Seek(newpos); Mpd.Seek(newpos);
else else
ShowMessage("Out of bounds, 0-%d possible for seconds, %d given.", s->GetTotalLength(), newpos); ShowMessage("Out of bounds, 0-%d possible for seconds, %d given", s->GetTotalLength(), newpos);
} }
else else
{ {
@@ -1738,7 +1737,7 @@ void JumpToPositionInSong::Run()
if (newpos >= 0 && newpos <= 100) if (newpos >= 0 && newpos <= 100)
Mpd.Seek(Mpd.GetTotalTime()*newpos/100.0); Mpd.Seek(Mpd.GetTotalTime()*newpos/100.0);
else else
ShowMessage("Out of bounds, 0-100 possible for %%, %d given.", newpos); ShowMessage("Out of bounds, 0-100 possible for %%, %d given", newpos);
} }
} }
@@ -1750,7 +1749,7 @@ bool ReverseSelection::canBeRun() const
void ReverseSelection::Run() void ReverseSelection::Run()
{ {
myScreen->ReverseSelection(); myScreen->ReverseSelection();
ShowMessage("Selection reversed!"); ShowMessage("Selection reversed");
} }
bool DeselectItems::canBeRun() const bool DeselectItems::canBeRun() const
@@ -1765,7 +1764,7 @@ void DeselectItems::Run()
return; return;
for (size_t i = 0; i < mList->Size(); ++i) for (size_t i = 0; i < mList->Size(); ++i)
mList->Select(i, 0); mList->Select(i, 0);
ShowMessage("Items deselected!"); ShowMessage("Items deselected");
} }
bool SelectAlbum::canBeRun() const bool SelectAlbum::canBeRun() const
@@ -1804,7 +1803,7 @@ void SelectAlbum::Run()
else else
mList->Select(pos, 1); mList->Select(pos, 1);
} }
ShowMessage("Album around cursor position selected."); ShowMessage("Album around cursor position selected");
} }
} }
@@ -1836,9 +1835,9 @@ void CropMainPlaylist::Run()
|| (!delete_all_but_current && !myPlaylist->Items->isSelected(myPlaylist->NowPlaying)); || (!delete_all_but_current && !myPlaylist->Items->isSelected(myPlaylist->NowPlaying));
if (myPlaylist->isPlaying() && delete_np) if (myPlaylist->isPlaying() && delete_np)
Mpd.DeleteID(myPlaylist->NowPlayingSong()->GetID()); Mpd.DeleteID(myPlaylist->NowPlayingSong()->GetID());
ShowMessage("Deleting all items but selected..."); ShowMessage("Cropping playlist...");
if (Mpd.CommitCommandsList()) if (Mpd.CommitCommandsList())
ShowMessage("Items deleted!"); ShowMessage("Playlist cropped");
} }
} }
@@ -1868,10 +1867,10 @@ void CropPlaylist::Run()
if (delete_i) if (delete_i)
Mpd.Delete(playlist, i); Mpd.Delete(playlist, i);
} }
ShowMessage("Deleting all items but selected..."); ShowMessage("Cropping playlist \"%s\"...", myPlaylistEditor->Playlists->Current().c_str());
if (Mpd.CommitCommandsList()) if (Mpd.CommitCommandsList())
{ {
ShowMessage("Items deleted!"); ShowMessage("Playlist \"%s\" cropped", myPlaylistEditor->Playlists->Current().c_str());
// enforce content update // enforce content update
myPlaylistEditor->Content->Clear(); myPlaylistEditor->Content->Clear();
} }
@@ -1892,12 +1891,13 @@ void ClearMainPlaylist::Run()
for (int i = myPlaylist->Items->Size()-1; i >= 0; --i) for (int i = myPlaylist->Items->Size()-1; i >= 0; --i)
Mpd.Delete((*myPlaylist->Items)[i].GetPosition()); Mpd.Delete((*myPlaylist->Items)[i].GetPosition());
if (Mpd.CommitCommandsList()) if (Mpd.CommitCommandsList())
ShowMessage("Filtered items deleted!"); ShowMessage("Filtered items deleted");
} }
else else
{ {
ShowMessage("Clearing playlist..."); ShowMessage("Clearing playlist...");
Mpd.ClearPlaylist(); if (Mpd.ClearPlaylist())
ShowMessage("Playlist cleared");
} }
} }
} }
@@ -1911,20 +1911,21 @@ void ClearPlaylist::Run()
{ {
if (myPlaylistEditor->Playlists->Empty()) if (myPlaylistEditor->Playlists->Empty())
return; return;
// OMGPLZ
bool yes = true; bool yes = true;
if (Config.ask_before_clearing_main_playlist) if (Config.ask_before_clearing_main_playlist)
yes = AskYesNoQuestion("Do you really want to clear playlist \"" + myPlaylistEditor->Playlists->Current() + "\"?", TraceMpdStatus); yes = AskYesNoQuestion("Do you really want to clear playlist \"" + myPlaylistEditor->Playlists->Current() + "\"?", TraceMpdStatus);
if (yes) if (yes)
{ {
if (myPlaylist->Items->isFiltered()) if (myPlaylistEditor->Content->isFiltered())
{ {
ShowMessage("Deleting filtered items..."); std::string playlist = locale_to_utf_cpy(myPlaylistEditor->Playlists->Current());
ShowMessage("Deleting filtered items from playlist \"%s\"...", myPlaylistEditor->Playlists->Current().c_str());
Mpd.StartCommandsList(); Mpd.StartCommandsList();
for (int i = myPlaylistEditor->Content->Size()-1; i >= 0; --i) for (int i = myPlaylistEditor->Content->Size()-1; i >= 0; --i)
Mpd.Delete((*myPlaylistEditor->Content)[i].GetPosition()); Mpd.Delete(playlist, (*myPlaylistEditor->Content)[i].GetPosition());
if (Mpd.CommitCommandsList()) if (Mpd.CommitCommandsList())
ShowMessage("Filtered items deleted!"); ShowMessage("Filtered items deleted from playlist \"%s\"", myPlaylistEditor->Playlists->Current().c_str());
} }
else else
{ {
@@ -2095,7 +2096,7 @@ void ToggleReplayGainMode::Run()
void ToggleSpaceMode::Run() void ToggleSpaceMode::Run()
{ {
Config.space_selects = !Config.space_selects; Config.space_selects = !Config.space_selects;
ShowMessage("Space mode: %s item", Config.space_selects ? "Select/deselect" : "Add"); ShowMessage("Space mode: %s item", Config.space_selects ? "Select" : "Add");
} }
void ToggleAddMode::Run() void ToggleAddMode::Run()
@@ -2142,7 +2143,7 @@ void AddRandomItems::Run()
size_t number = StrToLong(wFooter->GetString()); size_t number = StrToLong(wFooter->GetString());
UnlockStatusbar(); UnlockStatusbar();
if (number && (answer == 's' ? Mpd.AddRandomSongs(number) : Mpd.AddRandomTag(tag_type, number))) if (number && (answer == 's' ? Mpd.AddRandomSongs(number) : Mpd.AddRandomTag(tag_type, number)))
ShowMessage("%zu random %s%s added to playlist!", number, tag_type_str.c_str(), number == 1 ? "" : "s"); ShowMessage("%zu random %s%s added to playlist", number, tag_type_str.c_str(), number == 1 ? "" : "s");
} }
bool ToggleBrowserSortMode::canBeRun() const bool ToggleBrowserSortMode::canBeRun() const
@@ -2278,7 +2279,7 @@ void SetSelectedItemsPriority::Run()
int prio = atoi(strprio.c_str()); int prio = atoi(strprio.c_str());
if (prio < 0 || prio > 255) if (prio < 0 || prio > 255)
{ {
ShowMessage("Entered number is out of range"); ShowMessage("Number is out of range");
return; return;
} }
myPlaylist->SetSelectedItemsPriority(prio); myPlaylist->SetSelectedItemsPriority(prio);

View File

@@ -140,11 +140,11 @@ void Browser::EnterPressed()
} }
case itPlaylist: case itPlaylist:
{ {
ShowMessage("Loading and playing playlist \"%s\"...", item.name.c_str());
if (Mpd.LoadPlaylist(locale_to_utf_cpy(item.name))) if (Mpd.LoadPlaylist(locale_to_utf_cpy(item.name)))
{
ShowMessage("Playlist \"%s\" loaded", item.name.c_str()); ShowMessage("Playlist \"%s\" loaded", item.name.c_str());
else
myPlaylist->PlayNewlyAddedSongs(); myPlaylist->PlayNewlyAddedSongs();
}
} }
} }
} }
@@ -178,7 +178,7 @@ void Browser::SpacePressed()
{ {
MPD::SongList list; MPD::SongList list;
MPD::ItemList items; MPD::ItemList items;
ShowMessage("Scanning \"%s\"...", item.name.c_str()); ShowMessage("Scanning directory \"%s\"...", item.name.c_str());
myBrowser->GetLocalDirectory(items, item.name, 1); myBrowser->GetLocalDirectory(items, item.name, 1);
list.reserve(items.size()); list.reserve(items.size());
for (MPD::ItemList::const_iterator it = items.begin(); it != items.end(); ++it) for (MPD::ItemList::const_iterator it = items.begin(); it != items.end(); ++it)
@@ -190,7 +190,7 @@ void Browser::SpacePressed()
# endif // !WIN32 # endif // !WIN32
result = Mpd.Add(locale_to_utf_cpy(item.name)); result = Mpd.Add(locale_to_utf_cpy(item.name));
if (result) if (result)
ShowMessage("Added folder: %s", item.name.c_str()); ShowMessage("Directory \"%s\" added", item.name.c_str());
break; break;
} }
case itSong: case itSong:
@@ -201,7 +201,6 @@ void Browser::SpacePressed()
} }
case itPlaylist: case itPlaylist:
{ {
ShowMessage("Loading playlist \"%s\"...", item.name.c_str());
if (Mpd.LoadPlaylist(locale_to_utf_cpy(item.name))) if (Mpd.LoadPlaylist(locale_to_utf_cpy(item.name)))
ShowMessage("Playlist \"%s\" loaded", item.name.c_str()); ShowMessage("Playlist \"%s\" loaded", item.name.c_str());
break; break;
@@ -519,7 +518,7 @@ void Browser::ChangeBrowseMode()
return; return;
itsBrowseLocally = !itsBrowseLocally; itsBrowseLocally = !itsBrowseLocally;
ShowMessage("Browse mode: %s", itsBrowseLocally ? "Local filesystem" : "MPD music dir"); ShowMessage("Browse mode: %s", itsBrowseLocally ? "Local filesystem" : "MPD database");
itsBrowsedDir = itsBrowseLocally ? Config.GetHomeDirectory() : "/"; itsBrowsedDir = itsBrowseLocally ? Config.GetHomeDirectory() : "/";
if (itsBrowseLocally && *itsBrowsedDir.rbegin() == '/') if (itsBrowseLocally && *itsBrowsedDir.rbegin() == '/')
itsBrowsedDir.resize(itsBrowsedDir.length()-1); itsBrowsedDir.resize(itsBrowsedDir.length()-1);

View File

@@ -90,7 +90,7 @@ void Clock::SwitchTo()
GetWindowResizeParams(x_offset, width, false); GetWindowResizeParams(x_offset, width, false);
if (Width > width || Height > MainHeight) if (Width > width || Height > MainHeight)
{ {
ShowMessage("Screen is too small to display clock!"); ShowMessage("Screen is too small to display clock");
if (myLockedScreen) if (myLockedScreen)
UpdateInactiveScreen(myLockedScreen); UpdateInactiveScreen(myLockedScreen);
return; return;

View File

@@ -129,7 +129,7 @@ void Lyrics::SwitchTo()
} }
else else
{ {
ShowMessage("Song must have both artist and title tag set!"); ShowMessage("Song must have both artist and title tag set");
return; return;
} }
} }
@@ -171,7 +171,7 @@ void Lyrics::DownloadInBackground(const MPD::Song *s)
f.close(); f.close();
return; return;
} }
ShowMessage("Fetching lyrics for %s...", s->toString(Config.song_status_format_no_colors).c_str()); ShowMessage("Fetching lyrics for \"%s\"...", s->toString(Config.song_status_format_no_colors).c_str());
MPD::Song *s_copy = new MPD::Song(*s); MPD::Song *s_copy = new MPD::Song(*s);
pthread_mutex_lock(&itsDIBLock); pthread_mutex_lock(&itsDIBLock);
@@ -369,7 +369,7 @@ void Lyrics::Edit()
if (Config.external_editor.empty()) if (Config.external_editor.empty())
{ {
ShowMessage("External editor is not set!"); ShowMessage("Proper external_editor variable has to be set in configuration file");
return; return;
} }

View File

@@ -629,7 +629,7 @@ void MediaLibrary::LocateSong(const MPD::Song &s)
// <mpd-0.14.* has no ability to search for empty tags, which sometimes // <mpd-0.14.* has no ability to search for empty tags, which sometimes
// leaves albums column empty. since this function relies on this column // leaves albums column empty. since this function relies on this column
// being non-empty, it has to be disabled for these versions. // being non-empty, it has to be disabled for these versions.
ShowMessage("Your MPD version is too old to handle this function properly, please upgrade."); ShowMessage("This function is supported in MPD >= 0.14.0");
return; return;
} }
std::string primary_tag; std::string primary_tag;
@@ -650,15 +650,15 @@ void MediaLibrary::LocateSong(const MPD::Song &s)
case MPD_TAG_PERFORMER: case MPD_TAG_PERFORMER:
primary_tag = s.GetPerformer(); primary_tag = s.GetPerformer();
break; break;
default: default: // shouldn't happen
ShowMessage("Invalid tag type in left column of the media library"); assert(false);
return; return;
} }
if (primary_tag.empty()) if (primary_tag.empty())
{ {
std::string item_type = IntoStr(Config.media_lib_primary_tag); std::string item_type = IntoStr(Config.media_lib_primary_tag);
ToLower(item_type); ToLower(item_type);
ShowMessage("Can't jump to media library because the song has no %s tag set.", item_type.c_str()); ShowMessage("Can't use this function because the song has no %s tag set", item_type.c_str());
return; return;
} }
@@ -749,10 +749,10 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
{ {
std::string tag_type = IntoStr(Config.media_lib_primary_tag); std::string tag_type = IntoStr(Config.media_lib_primary_tag);
ToLower(tag_type); ToLower(tag_type);
ShowMessage("Adding songs of %s \"%s\"", tag_type.c_str(), Artists->Current().c_str()); ShowMessage("Songs with %s = \"%s\" added", tag_type.c_str(), Artists->Current().c_str());
} }
else if (w == Albums) else if (w == Albums)
ShowMessage("Adding songs from album \"%s\"", Albums->Current().Album.c_str()); ShowMessage("Songs from album \"%s\" added", Albums->Current().Album.c_str());
} }
} }

View File

@@ -535,19 +535,19 @@ void MPD::Connection::Shuffle()
} }
} }
void MPD::Connection::ClearPlaylist() bool MPD::Connection::ClearPlaylist()
{ {
if (!itsConnection) if (!itsConnection)
return; return false;
if (!isCommandsListEnabled) if (!isCommandsListEnabled)
{ {
GoBusy(); GoBusy();
mpd_run_clear(itsConnection); return mpd_run_clear(itsConnection);
} }
else else
{ {
assert(!isIdle); assert(!isIdle);
mpd_send_clear(itsConnection); return mpd_send_clear(itsConnection);
} }
} }

View File

@@ -124,7 +124,7 @@ namespace MPD
void Swap(unsigned, unsigned); void Swap(unsigned, unsigned);
void Seek(unsigned); void Seek(unsigned);
void Shuffle(); void Shuffle();
void ClearPlaylist(); bool ClearPlaylist();
bool isPlaying() const { return GetState() > psStop; } bool isPlaying() const { return GetState() > psStop; }

View File

@@ -70,7 +70,7 @@ namespace
{ {
if (signal == SIGPIPE) if (signal == SIGPIPE)
{ {
ShowMessage("Broken pipe signal caught!"); ShowMessage("SIGPIPE (broken pipe signal) received");
} }
else if (signal == SIGWINCH) else if (signal == SIGWINCH)
{ {
@@ -206,7 +206,7 @@ int main(int argc, char **argv)
ShowMessage("Attempting to reconnect..."); ShowMessage("Attempting to reconnect...");
if (Mpd.Connect()) if (Mpd.Connect())
{ {
ShowMessage("Connected to %s!", Mpd.GetHostname().c_str()); ShowMessage("Connected to %s", Mpd.GetHostname().c_str());
if (Mpd.SupportsIdle()) if (Mpd.SupportsIdle())
{ {
wFooter->AddFDCallback(Mpd.GetFD(), StatusbarMPDCallback); wFooter->AddFDCallback(Mpd.GetFD(), StatusbarMPDCallback);

View File

@@ -216,7 +216,7 @@ void Playlist::EnterPressed()
} }
while (playlist != cmp); while (playlist != cmp);
if (Mpd.CommitCommandsList()) if (Mpd.CommitCommandsList())
ShowMessage("Playlist sorted!"); ShowMessage("Playlist sorted");
w = Items; w = Items;
} }
} }
@@ -377,7 +377,7 @@ void Playlist::Sort()
if (isFiltered()) if (isFiltered())
return; return;
if (Items->GetWidth() < SortDialogWidth || MainHeight < 5) if (Items->GetWidth() < SortDialogWidth || MainHeight < 5)
ShowMessage("Screen is too small to display dialog window!"); ShowMessage("Screen is too small to display dialog window");
else else
{ {
SortDialog->Reset(); SortDialog->Reset();
@@ -409,7 +409,7 @@ void Playlist::Reverse()
for (size_t i = beginning, j = end-1; i < (beginning+end)/2; ++i, --j) for (size_t i = beginning, j = end-1; i < (beginning+end)/2; ++i, --j)
Mpd.Swap(i, j); Mpd.Swap(i, j);
if (Mpd.CommitCommandsList()) if (Mpd.CommitCommandsList())
ShowMessage("Playlist reversed!"); ShowMessage("Playlist reversed");
} }
void Playlist::AdjustSortOrder(Movement where) void Playlist::AdjustSortOrder(Movement where)
@@ -439,16 +439,6 @@ void Playlist::AdjustSortOrder(Movement where)
} }
} }
void Playlist::FixPositions(size_t beginning)
{
bool was_filtered = Items->isFiltered();
Items->ShowAll();
for (size_t i = beginning; i < Items->Size(); ++i)
(*Items)[i].SetPosition(i);
if (was_filtered)
Items->ShowFiltered();
}
void Playlist::EnableHighlighting() void Playlist::EnableHighlighting()
{ {
Items->Highlighting(1); Items->Highlighting(1);

View File

@@ -69,7 +69,6 @@ class Playlist : public Screen<Window>
void Reverse(); void Reverse();
void AdjustSortOrder(Movement where); void AdjustSortOrder(Movement where);
bool SortingInProgress() { return w == SortDialog; } bool SortingInProgress() { return w == SortDialog; }
void FixPositions(size_t = 0);
void EnableHighlighting(); void EnableHighlighting();
void UpdateTimer() { time(&itsTimer); } void UpdateTimer() { time(&itsTimer); }

View File

@@ -325,12 +325,6 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play)
if (w == Playlists && !Playlists->Empty()) if (w == Playlists && !Playlists->Empty())
{ {
const char *msg;
if (add_n_play)
msg = "Loading and playing playlist \"%s\"...";
else
msg = "Loading playlist \"%s\"...";
ShowMessage(msg, Playlists->Current().c_str());
if (Mpd.LoadPlaylist(utf_to_locale_cpy(Playlists->Current()))) if (Mpd.LoadPlaylist(utf_to_locale_cpy(Playlists->Current())))
{ {
ShowMessage("Playlist \"%s\" loaded", Playlists->Current().c_str()); ShowMessage("Playlist \"%s\" loaded", Playlists->Current().c_str());

View File

@@ -172,7 +172,7 @@ void SearchEngine::EnterPressed()
*w->at(ResetButton+2).first << Config.color1 << "Search results: " << Config.color2 << "Found " << found << (found > 1 ? " songs" : " song") << clDefault; *w->at(ResetButton+2).first << Config.color1 << "Search results: " << Config.color2 << "Found " << found << (found > 1 ? " songs" : " song") << clDefault;
w->InsertSeparator(ResetButton+3); w->InsertSeparator(ResetButton+3);
UpdateFoundList(); UpdateFoundList();
ShowMessage("Searching finished!"); ShowMessage("Searching finished");
if (Config.block_search_constraints_change) if (Config.block_search_constraints_change)
for (size_t i = 0; i < StaticOptions-4; ++i) for (size_t i = 0; i < StaticOptions-4; ++i)
w->Static(i, 1); w->Static(i, 1);

View File

@@ -72,7 +72,7 @@ void SelectedItemsAdder::SwitchTo()
if (MainHeight < 5) if (MainHeight < 5)
{ {
ShowMessage("Screen is too small to display this window!"); ShowMessage("Screen is too small to display this window");
return; return;
} }
@@ -90,7 +90,7 @@ void SelectedItemsAdder::SwitchTo()
bool playlists_not_active = myScreen == myBrowser && myBrowser->isLocal(); bool playlists_not_active = myScreen == myBrowser && myBrowser->isLocal();
if (playlists_not_active) if (playlists_not_active)
ShowMessage("Local items cannot be added to m3u playlist!"); ShowMessage("Local items can't be added to stored playlists");
w->Clear(); w->Clear();
w->Reset(); w->Reset();
@@ -182,7 +182,7 @@ void SelectedItemsAdder::EnterPressed()
for (MPD::SongList::const_iterator it = list.begin(); it != list.end(); ++it) for (MPD::SongList::const_iterator it = list.begin(); it != list.end(); ++it)
Mpd.AddToPlaylist(utf_playlist, **it); Mpd.AddToPlaylist(utf_playlist, **it);
if (Mpd.CommitCommandsList()) if (Mpd.CommitCommandsList())
ShowMessage("Selected item(s) added to playlist \"%s\"!", playlist.c_str()); ShowMessage("Selected item(s) added to playlist \"%s\"", playlist.c_str());
} }
} }
else if (pos > 1 && pos < w->Size()-1) // add items to existing playlist else if (pos > 1 && pos < w->Size()-1) // add items to existing playlist
@@ -192,7 +192,7 @@ void SelectedItemsAdder::EnterPressed()
for (MPD::SongList::const_iterator it = list.begin(); it != list.end(); ++it) for (MPD::SongList::const_iterator it = list.begin(); it != list.end(); ++it)
Mpd.AddToPlaylist(playlist, **it); Mpd.AddToPlaylist(playlist, **it);
if (Mpd.CommitCommandsList()) if (Mpd.CommitCommandsList())
ShowMessage("Selected item(s) added to playlist \"%s\"!", w->Current().c_str()); ShowMessage("Selected item(s) added to playlist \"%s\"", w->Current().c_str());
} }
if (pos != w->Size()-1) if (pos != w->Size()-1)
{ {
@@ -208,7 +208,7 @@ void SelectedItemsAdder::EnterPressed()
// disable adding after current track/album when stopped // disable adding after current track/album when stopped
if (pos > 1 && pos < 4 && !Mpd.isPlaying()) if (pos > 1 && pos < 4 && !Mpd.isPlaying())
{ {
ShowMessage("Player is stopped!"); ShowMessage("Player is stopped");
return; return;
} }
@@ -245,7 +245,7 @@ void SelectedItemsAdder::EnterPressed()
} }
if (successful_operation) if (successful_operation)
ShowMessage("Selected item(s) added!"); ShowMessage("Selected item(s) added");
} }
MPD::FreeSongList(list); MPD::FreeSongList(list);
SwitchTo(); SwitchTo();

View File

@@ -52,7 +52,7 @@ void ServerInfo::SwitchTo()
} }
if (MainHeight < 5) if (MainHeight < 5)
{ {
ShowMessage("Screen is too small to display this window!"); ShowMessage("Screen is too small to display this window");
return; return;
} }

View File

@@ -198,7 +198,7 @@ void NcmpcppErrorCallback(MPD::Connection *, int errorid, const char *msg, void
Statusbar() << "Password: "; Statusbar() << "Password: ";
Mpd.SetPassword(wFooter->GetString(-1, 0, 1)); Mpd.SetPassword(wFooter->GetString(-1, 0, 1));
if (Mpd.SendPassword()) if (Mpd.SendPassword())
ShowMessage("Password accepted!"); ShowMessage("Password accepted");
wFooter->SetGetStringHelper(StatusbarGetStringHelper); wFooter->SetGetStringHelper(StatusbarGetStringHelper);
} }
else if ((errorid >> 8) == MPD_SERVER_ERROR_NO_EXIST && myScreen == myBrowser) else if ((errorid >> 8) == MPD_SERVER_ERROR_NO_EXIST && myScreen == myBrowser)
@@ -207,7 +207,7 @@ void NcmpcppErrorCallback(MPD::Connection *, int errorid, const char *msg, void
myBrowser->Refresh(); myBrowser->Refresh();
} }
else else
ShowMessage("%s", msg); ShowMessage("MPD: %s", msg);
} }
void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *) void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
@@ -269,7 +269,6 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
{ {
myPlaylist->Items->Reset(); myPlaylist->Items->Reset();
myPlaylist->Items->Window::Clear(); myPlaylist->Items->Window::Clear();
ShowMessage("Cleared playlist!");
} }
if (isVisible(myBrowser)) if (isVisible(myBrowser))
@@ -550,7 +549,7 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
if (changed.Database && myScreen == mySelectedItemsAdder) if (changed.Database && myScreen == mySelectedItemsAdder)
{ {
myScreen->SwitchTo(); // switch to previous screen myScreen->SwitchTo(); // switch to previous screen
ShowMessage("Database has changed, you need to select your item(s) once again!"); ShowMessage("Database has changed, you need to select your item(s) once again");
} }
} }
if (changed.StatusFlags && (Config.header_visibility || Config.new_design)) if (changed.StatusFlags && (Config.header_visibility || Config.new_design))

View File

@@ -456,7 +456,7 @@ void TagEditor::EnterPressed()
std::string new_file = GenerateFilename(s, "{" + Config.pattern + "}"); std::string new_file = GenerateFilename(s, "{" + Config.pattern + "}");
if (new_file.empty() && !FParserUsePreview) if (new_file.empty() && !FParserUsePreview)
{ {
ShowMessage("File \"%s\" would have an empty name!", s.GetName().c_str()); ShowMessage("File \"%s\" would have an empty name", s.GetName().c_str());
FParserUsePreview = 1; FParserUsePreview = 1;
success = 0; success = 0;
} }
@@ -485,7 +485,7 @@ void TagEditor::EnterPressed()
quit = 1; quit = 1;
} }
if (pos != 3 || success) if (pos != 3 || success)
ShowMessage("Operation finished!"); ShowMessage("Operation finished");
} }
else if (pos == 2) // show legend else if (pos == 2) // show legend
{ {
@@ -541,10 +541,10 @@ void TagEditor::EnterPressed()
else else
(*it)->SetTrack(i); (*it)->SetTrack(i);
} }
ShowMessage("Tracks numbered!"); ShowMessage("Tracks numbered");
} }
else else
ShowMessage("Aborted!"); ShowMessage("Aborted");
return; return;
} }
@@ -580,7 +580,7 @@ void TagEditor::EnterPressed()
{ {
if (size_t(COLS) < FParserDialogWidth || MainHeight < FParserDialogHeight) if (size_t(COLS) < FParserDialogWidth || MainHeight < FParserDialogHeight)
{ {
ShowMessage("Screen is too small to display additional windows!"); ShowMessage("Screen is too small to display additional windows");
return; return;
} }
FParserDialog->Reset(); FParserDialog->Reset();
@@ -607,14 +607,14 @@ void TagEditor::EnterPressed()
ShowMessage("Processing..."); ShowMessage("Processing...");
for (MPD::SongList::iterator it = EditedSongs.begin(); it != EditedSongs.end(); ++it) for (MPD::SongList::iterator it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
CapitalizeFirstLetters(**it); CapitalizeFirstLetters(**it);
ShowMessage("Done!"); ShowMessage("Done");
} }
else if (id == 13) // lower all letters else if (id == 13) // lower all letters
{ {
ShowMessage("Processing..."); ShowMessage("Processing...");
for (MPD::SongList::iterator it = EditedSongs.begin(); it != EditedSongs.end(); ++it) for (MPD::SongList::iterator it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
LowerAllLetters(**it); LowerAllLetters(**it);
ShowMessage("Done!"); ShowMessage("Done");
} }
else if (id == 14) // reset else if (id == 14) // reset
{ {
@@ -630,7 +630,7 @@ void TagEditor::EnterPressed()
ShowMessage("Writing tags in \"%s\"...", (*it)->GetName().c_str()); ShowMessage("Writing tags in \"%s\"...", (*it)->GetName().c_str());
if (!WriteTags(**it)) if (!WriteTags(**it))
{ {
const char msg[] = "Error while writing tags in \"%s\"!"; const char msg[] = "Error while writing tags in \"%s\"";
ShowMessage(msg, Shorten(TO_WSTRING((*it)->GetFile()), COLS-static_strlen(msg)).c_str()); ShowMessage(msg, Shorten(TO_WSTRING((*it)->GetFile()), COLS-static_strlen(msg)).c_str());
success = 0; success = 0;
break; break;
@@ -638,7 +638,7 @@ void TagEditor::EnterPressed()
} }
if (success) if (success)
{ {
ShowMessage("Tags updated!"); ShowMessage("Tags updated");
TagTypes->HighlightColor(Config.main_highlight_color); TagTypes->HighlightColor(Config.main_highlight_color);
TagTypes->Reset(); TagTypes->Reset();
w->Refresh(); w->Refresh();

View File

@@ -68,7 +68,7 @@ void TinyTagEditor::SwitchTo()
if (itsEdited.isStream()) if (itsEdited.isStream())
{ {
ShowMessage("Streams cannot be edited!"); ShowMessage("Streams can't be edited");
} }
else if (GetTags()) else if (GetTags())
{ {
@@ -135,7 +135,7 @@ void TinyTagEditor::EnterPressed()
ShowMessage("Updating tags..."); ShowMessage("Updating tags...");
if (TagEditor::WriteTags(s)) if (TagEditor::WriteTags(s))
{ {
ShowMessage("Tags updated!"); ShowMessage("Tags updated");
if (s.isFromDB()) if (s.isFromDB())
{ {
Mpd.UpdateDirectory(locale_to_utf_cpy(s.GetDirectory())); Mpd.UpdateDirectory(locale_to_utf_cpy(s.GetDirectory()));
@@ -151,7 +151,7 @@ void TinyTagEditor::EnterPressed()
} }
} }
else else
ShowMessage("Error while writing tags!"); ShowMessage("Error while writing tags");
} }
if (option > 21) if (option > 21)
myOldScreen->SwitchTo(); myOldScreen->SwitchTo();

View File

@@ -242,7 +242,7 @@ void Visualizer::FindOutputID()
if (outputs[i].first == Config.visualizer_output_name) if (outputs[i].first == Config.visualizer_output_name)
itsOutputID = i; itsOutputID = i;
if (itsOutputID == -1) if (itsOutputID == -1)
ShowMessage("There is no output named \"%s\"!", Config.visualizer_output_name.c_str()); ShowMessage("There is no output named \"%s\"", Config.visualizer_output_name.c_str());
} }
} }