move statusbar/progressbar related code to separate file
This commit is contained in:
@@ -38,6 +38,7 @@ ncmpcpp_SOURCES = \
|
||||
song.cpp \
|
||||
song_info.cpp \
|
||||
status.cpp \
|
||||
statusbar.cpp \
|
||||
tag_editor.cpp \
|
||||
tiny_tag_editor.cpp \
|
||||
visualizer.cpp \
|
||||
@@ -89,6 +90,8 @@ noinst_HEADERS = \
|
||||
settings.h \
|
||||
song.h \
|
||||
song_info.h \
|
||||
status.h \
|
||||
statusbar.h \
|
||||
tag_editor.h \
|
||||
tiny_tag_editor.h \
|
||||
visualizer.h \
|
||||
|
||||
297
src/actions.cpp
297
src/actions.cpp
@@ -31,6 +31,7 @@
|
||||
#include "global.h"
|
||||
#include "mpdpp.h"
|
||||
#include "helpers.h"
|
||||
#include "statusbar.h"
|
||||
#include "utility/comparators.h"
|
||||
|
||||
#include "bindings.h"
|
||||
@@ -191,7 +192,7 @@ void Action::ResizeScreen()
|
||||
RedrawStatusbar = true;
|
||||
NcmpcppStatusChanged(&Mpd, MPD::StatusChanges(), 0);
|
||||
DesignChanged = 0;
|
||||
ShowMessage("User interface: %s", Config.new_design ? "Alternative" : "Classic");
|
||||
Statusbar::msg("User interface: %s", Config.new_design ? "Alternative" : "Classic");
|
||||
}
|
||||
DrawHeader();
|
||||
wFooter->refresh();
|
||||
@@ -228,12 +229,12 @@ void Action::Seek()
|
||||
|
||||
if (!Mpd.GetTotalTime())
|
||||
{
|
||||
ShowMessage("Unknown item length");
|
||||
Statusbar::msg("Unknown item length");
|
||||
return;
|
||||
}
|
||||
|
||||
LockProgressbar();
|
||||
LockStatusbar();
|
||||
Progressbar::lock();
|
||||
Statusbar::lock();
|
||||
|
||||
int songpos = Mpd.GetElapsedTime();
|
||||
timeval t = Timer;
|
||||
@@ -307,7 +308,7 @@ void Action::Seek()
|
||||
*wFooter << NC::XY(wFooter->getWidth()-tracklength.length(), 1) << tracklength;
|
||||
}
|
||||
*wFooter << NC::fmtBoldEnd;
|
||||
DrawProgressbar(songpos, Mpd.GetTotalTime());
|
||||
Progressbar::draw(songpos, Mpd.GetTotalTime());
|
||||
wFooter->refresh();
|
||||
}
|
||||
SeekingInProgress = false;
|
||||
@@ -315,8 +316,8 @@ void Action::Seek()
|
||||
|
||||
wFooter->setTimeout(old_timeout);
|
||||
|
||||
UnlockProgressbar();
|
||||
UnlockStatusbar();
|
||||
Progressbar::unlock();
|
||||
Statusbar::unlock();
|
||||
}
|
||||
|
||||
void Action::FindItem(const FindDirection fd)
|
||||
@@ -327,13 +328,13 @@ void Action::FindItem(const FindDirection fd)
|
||||
assert(w);
|
||||
assert(w->allowsSearching());
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << "Find " << (fd == fdForward ? "forward" : "backward") << ": ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << "Find " << (fd == fdForward ? "forward" : "backward") << ": ";
|
||||
std::string findme = wFooter->getString();
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
|
||||
if (!findme.empty())
|
||||
ShowMessage("Searching...");
|
||||
Statusbar::msg("Searching...");
|
||||
|
||||
bool success = w->search(findme);
|
||||
|
||||
@@ -341,9 +342,9 @@ void Action::FindItem(const FindDirection fd)
|
||||
return;
|
||||
|
||||
if (success)
|
||||
ShowMessage("Searching finished");
|
||||
Statusbar::msg("Searching finished");
|
||||
else
|
||||
ShowMessage("Unable to find \"%s\"", findme.c_str());
|
||||
Statusbar::msg("Unable to find \"%s\"", findme.c_str());
|
||||
|
||||
if (fd == fdForward)
|
||||
w->nextFound(Config.wrapped_search);
|
||||
@@ -401,8 +402,8 @@ bool Action::AskYesNoQuestion(const std::string &question, void (*callback)())
|
||||
{
|
||||
using Global::wFooter;
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << question << " [" << NC::fmtBold << 'y' << NC::fmtBoldEnd << '/' << NC::fmtBold << 'n' << NC::fmtBoldEnd << "]";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << question << " [" << NC::fmtBold << 'y' << NC::fmtBoldEnd << '/' << NC::fmtBold << 'n' << NC::fmtBoldEnd << "]";
|
||||
wFooter->refresh();
|
||||
int answer = 0;
|
||||
do
|
||||
@@ -412,7 +413,7 @@ bool Action::AskYesNoQuestion(const std::string &question, void (*callback)())
|
||||
answer = wFooter->readKey();
|
||||
}
|
||||
while (answer != 'y' && answer != 'n');
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
return answer == 'y';
|
||||
}
|
||||
|
||||
@@ -420,7 +421,7 @@ bool Action::isMPDMusicDirSet()
|
||||
{
|
||||
if (Config.mpd_music_dir.empty())
|
||||
{
|
||||
ShowMessage("Proper mpd_music_dir variable has to be set in configuration file");
|
||||
Statusbar::msg("Proper mpd_music_dir variable has to be set in configuration file");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -632,8 +633,8 @@ void ToggleInterface::Run()
|
||||
Config.new_design = !Config.new_design;
|
||||
Config.statusbar_visibility = Config.new_design ? 0 : OriginalStatusbarVisibility;
|
||||
SetWindowsDimensions();
|
||||
UnlockProgressbar();
|
||||
UnlockStatusbar();
|
||||
Progressbar::unlock();
|
||||
Statusbar::unlock();
|
||||
DesignChanged = true;
|
||||
ResizeScreen();
|
||||
}
|
||||
@@ -779,10 +780,10 @@ void Delete::Run()
|
||||
{
|
||||
if (myScreen == myPlaylist && !myPlaylist->Items->empty())
|
||||
{
|
||||
ShowMessage("Deleting items...");
|
||||
Statusbar::msg("Deleting items...");
|
||||
auto delete_fun = std::bind(&MPD::Connection::Delete, _1, _2);
|
||||
if (deleteSelectedSongs(*myPlaylist->Items, delete_fun))
|
||||
ShowMessage("Item(s) deleted");
|
||||
Statusbar::msg("Item(s) deleted");
|
||||
}
|
||||
# ifndef WIN32
|
||||
else if (myScreen == myBrowser && !myBrowser->Main()->empty())
|
||||
@@ -815,12 +816,12 @@ void Delete::Run()
|
||||
if (myBrowser->deleteItem(i))
|
||||
{
|
||||
const char msg[] = "\"%ls\" deleted";
|
||||
ShowMessage(msg, wideShorten(ToWString(name), COLS-const_strlen(msg)).c_str());
|
||||
Statusbar::msg(msg, wideShorten(ToWString(name), COLS-const_strlen(msg)).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
const char msg[] = "Couldn't delete \"%ls\": %s";
|
||||
ShowMessage(msg, wideShorten(ToWString(name), COLS-const_strlen(msg)-25).c_str(), strerror(errno));
|
||||
Statusbar::msg(msg, wideShorten(ToWString(name), COLS-const_strlen(msg)-25).c_str(), strerror(errno));
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
@@ -832,7 +833,7 @@ void Delete::Run()
|
||||
}
|
||||
}
|
||||
else
|
||||
ShowMessage("Aborted");
|
||||
Statusbar::msg("Aborted");
|
||||
}
|
||||
# endif // !WIN32
|
||||
else if (myScreen == myPlaylistEditor && !myPlaylistEditor->Content->empty())
|
||||
@@ -856,18 +857,18 @@ void Delete::Run()
|
||||
for (auto it = list.begin(); it != list.end(); ++it)
|
||||
Mpd.DeletePlaylist((*it)->value());
|
||||
if (Mpd.CommitCommandsList())
|
||||
ShowMessage("Playlist%s deleted", list.size() == 1 ? "" : "s");
|
||||
Statusbar::msg("Playlist%s deleted", list.size() == 1 ? "" : "s");
|
||||
}
|
||||
else
|
||||
ShowMessage("Aborted");
|
||||
Statusbar::msg("Aborted");
|
||||
}
|
||||
else if (myScreen->ActiveWindow() == myPlaylistEditor->Content)
|
||||
{
|
||||
std::string playlist = myPlaylistEditor->Playlists->current().value();
|
||||
auto delete_fun = std::bind(&MPD::Connection::PlaylistDelete, _1, playlist, _2);
|
||||
ShowMessage("Deleting items...");
|
||||
Statusbar::msg("Deleting items...");
|
||||
if (deleteSelectedSongs(*myPlaylistEditor->Content, delete_fun))
|
||||
ShowMessage("Item(s) deleted");
|
||||
Statusbar::msg("Item(s) deleted");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -897,14 +898,14 @@ void SavePlaylist::Run()
|
||||
{
|
||||
using Global::wFooter;
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << "Save playlist as: ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << "Save playlist as: ";
|
||||
std::string playlist_name = wFooter->getString();
|
||||
std::string real_playlist_name = locale_to_utf_cpy(playlist_name);
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
if (playlist_name.find("/") != std::string::npos)
|
||||
{
|
||||
ShowMessage("Playlist name must not contain slashes");
|
||||
Statusbar::msg("Playlist name must not contain slashes");
|
||||
return;
|
||||
}
|
||||
if (!playlist_name.empty())
|
||||
@@ -916,14 +917,14 @@ void SavePlaylist::Run()
|
||||
Mpd.AddToPlaylist(real_playlist_name, (*myPlaylist->Items)[i].value());
|
||||
Mpd.CommitCommandsList();
|
||||
if (Mpd.GetErrorMessage().empty())
|
||||
ShowMessage("Filtered items added to playlist \"%s\"", playlist_name.c_str());
|
||||
Statusbar::msg("Filtered items added to playlist \"%s\"", playlist_name.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
int result = Mpd.SavePlaylist(real_playlist_name);
|
||||
if (result == MPD_ERROR_SUCCESS)
|
||||
{
|
||||
ShowMessage("Playlist saved as \"%s\"", playlist_name.c_str());
|
||||
Statusbar::msg("Playlist saved as \"%s\"", playlist_name.c_str());
|
||||
if (myPlaylistEditor->Main()) // check if initialized
|
||||
myPlaylistEditor->Playlists->clear(); // make playlist's list update itself
|
||||
}
|
||||
@@ -934,10 +935,10 @@ void SavePlaylist::Run()
|
||||
{
|
||||
Mpd.DeletePlaylist(real_playlist_name);
|
||||
if (Mpd.SavePlaylist(real_playlist_name) == MPD_ERROR_SUCCESS)
|
||||
ShowMessage("Playlist overwritten");
|
||||
Statusbar::msg("Playlist overwritten");
|
||||
}
|
||||
else
|
||||
ShowMessage("Aborted");
|
||||
Statusbar::msg("Aborted");
|
||||
if (myPlaylistEditor->Main()) // check if initialized
|
||||
myPlaylistEditor->Playlists->clear(); // make playlist's list update itself
|
||||
if (myScreen == myPlaylist)
|
||||
@@ -1058,14 +1059,14 @@ void Add::Run()
|
||||
{
|
||||
using Global::wFooter;
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << (myScreen == myPlaylistEditor ? "Add to playlist: " : "Add: ");
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << (myScreen == myPlaylistEditor ? "Add to playlist: " : "Add: ");
|
||||
std::string path = wFooter->getString();
|
||||
locale_to_utf(path);
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
if (!path.empty())
|
||||
{
|
||||
Statusbar() << "Adding...";
|
||||
Statusbar::put() << "Adding...";
|
||||
wFooter->refresh();
|
||||
if (myScreen == myPlaylistEditor)
|
||||
Mpd.AddToPlaylist(myPlaylistEditor->Playlists->current().value(), path);
|
||||
@@ -1118,7 +1119,7 @@ void ToggleDisplayMode::Run()
|
||||
if (myScreen == myPlaylist)
|
||||
{
|
||||
Config.columns_in_playlist = !Config.columns_in_playlist;
|
||||
ShowMessage("Playlist display mode: %s", Config.columns_in_playlist ? "Columns" : "Classic");
|
||||
Statusbar::msg("Playlist display mode: %s", Config.columns_in_playlist ? "Columns" : "Classic");
|
||||
|
||||
if (Config.columns_in_playlist)
|
||||
{
|
||||
@@ -1137,20 +1138,20 @@ void ToggleDisplayMode::Run()
|
||||
else if (myScreen == myBrowser)
|
||||
{
|
||||
Config.columns_in_browser = !Config.columns_in_browser;
|
||||
ShowMessage("Browser display mode: %s", Config.columns_in_browser ? "Columns" : "Classic");
|
||||
Statusbar::msg("Browser display mode: %s", Config.columns_in_browser ? "Columns" : "Classic");
|
||||
myBrowser->Main()->setTitle(Config.columns_in_browser && Config.titles_visibility ? Display::Columns(myBrowser->Main()->getWidth()) : "");
|
||||
}
|
||||
else if (myScreen == mySearcher)
|
||||
{
|
||||
Config.columns_in_search_engine = !Config.columns_in_search_engine;
|
||||
ShowMessage("Search engine display mode: %s", Config.columns_in_search_engine ? "Columns" : "Classic");
|
||||
Statusbar::msg("Search engine display mode: %s", Config.columns_in_search_engine ? "Columns" : "Classic");
|
||||
if (mySearcher->Main()->size() > SearchEngine::StaticOptions)
|
||||
mySearcher->Main()->setTitle(Config.columns_in_search_engine && Config.titles_visibility ? Display::Columns(mySearcher->Main()->getWidth()) : "");
|
||||
}
|
||||
else if (myScreen->ActiveWindow() == myPlaylistEditor->Content)
|
||||
{
|
||||
Config.columns_in_playlist_editor = !Config.columns_in_playlist_editor;
|
||||
ShowMessage("Playlist editor display mode: %s", Config.columns_in_playlist_editor ? "Columns" : "Classic");
|
||||
Statusbar::msg("Playlist editor display mode: %s", Config.columns_in_playlist_editor ? "Columns" : "Classic");
|
||||
if (Config.columns_in_playlist_editor)
|
||||
myPlaylistEditor->Content->setItemDisplayer(std::bind(Display::SongsInColumns, _1, myPlaylistEditor));
|
||||
else
|
||||
@@ -1166,7 +1167,7 @@ bool ToggleSeparatorsBetweenAlbums::canBeRun() const
|
||||
void ToggleSeparatorsBetweenAlbums::Run()
|
||||
{
|
||||
Config.playlist_separate_albums = !Config.playlist_separate_albums;
|
||||
ShowMessage("Separators between albums: %s", Config.playlist_separate_albums ? "On" : "Off");
|
||||
Statusbar::msg("Separators between albums: %s", Config.playlist_separate_albums ? "On" : "Off");
|
||||
}
|
||||
|
||||
#ifndef HAVE_CURL_CURL_H
|
||||
@@ -1194,14 +1195,14 @@ void ToggleFetchingLyricsInBackground::Run()
|
||||
{
|
||||
# ifdef HAVE_CURL_CURL_H
|
||||
Config.fetch_lyrics_in_background = !Config.fetch_lyrics_in_background;
|
||||
ShowMessage("Fetching lyrics for playing songs in background: %s", Config.fetch_lyrics_in_background ? "On" : "Off");
|
||||
Statusbar::msg("Fetching lyrics for playing songs in background: %s", Config.fetch_lyrics_in_background ? "On" : "Off");
|
||||
# endif // HAVE_CURL_CURL_H
|
||||
}
|
||||
|
||||
void TogglePlayingSongCentering::Run()
|
||||
{
|
||||
Config.autocenter_mode = !Config.autocenter_mode;
|
||||
ShowMessage("Centering playing song: %s", Config.autocenter_mode ? "On" : "Off");
|
||||
Statusbar::msg("Centering playing song: %s", Config.autocenter_mode ? "On" : "Off");
|
||||
if (Config.autocenter_mode && Mpd.isPlaying() && !myPlaylist->Items->isFiltered())
|
||||
myPlaylist->Items->highlight(Mpd.GetCurrentlyPlayingSongPos());
|
||||
}
|
||||
@@ -1315,10 +1316,10 @@ void SetCrossfade::Run()
|
||||
{
|
||||
using Global::wFooter;
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << "Set crossfade to: ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << "Set crossfade to: ";
|
||||
std::string crossfade = wFooter->getString(3);
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
int cf = stringToInt(crossfade);
|
||||
if (cf > 0)
|
||||
{
|
||||
@@ -1361,13 +1362,13 @@ void EditLibraryTag::Run()
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
using Global::wFooter;
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << NC::fmtBold << tagTypeToString(Config.media_lib_primary_tag) << NC::fmtBoldEnd << ": ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << NC::fmtBold << tagTypeToString(Config.media_lib_primary_tag) << NC::fmtBoldEnd << ": ";
|
||||
std::string new_tag = wFooter->getString(myLibrary->Tags->current().value());
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
if (!new_tag.empty() && new_tag != myLibrary->Tags->current().value())
|
||||
{
|
||||
ShowMessage("Updating tags...");
|
||||
Statusbar::msg("Updating tags...");
|
||||
Mpd.StartSearch(1);
|
||||
Mpd.AddSearch(Config.media_lib_primary_tag, locale_to_utf_cpy(myLibrary->Tags->current().value()));
|
||||
MPD::MutableSong::SetFunction set = tagTypeToSetFunction(Config.media_lib_primary_tag);
|
||||
@@ -1378,12 +1379,12 @@ void EditLibraryTag::Run()
|
||||
{
|
||||
MPD::MutableSong es = *s;
|
||||
es.setTags(set, new_tag);
|
||||
ShowMessage("Updating tags in \"%s\"...", es.getName().c_str());
|
||||
Statusbar::msg("Updating tags in \"%s\"...", es.getName().c_str());
|
||||
std::string path = Config.mpd_music_dir + es.getURI();
|
||||
if (!TagEditor::WriteTags(es))
|
||||
{
|
||||
const char msg[] = "Error while updating tags in \"%ls\"";
|
||||
ShowMessage(msg, wideShorten(ToWString(es.getURI()), COLS-const_strlen(msg)).c_str());
|
||||
Statusbar::msg(msg, wideShorten(ToWString(es.getURI()), COLS-const_strlen(msg)).c_str());
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
@@ -1391,7 +1392,7 @@ void EditLibraryTag::Run()
|
||||
if (success)
|
||||
{
|
||||
Mpd.UpdateDirectory(getSharedDirectory(songs.begin(), songs.end()));
|
||||
ShowMessage("Tags updated successfully");
|
||||
Statusbar::msg("Tags updated successfully");
|
||||
}
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
@@ -1413,23 +1414,23 @@ void EditLibraryAlbum::Run()
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
using Global::wFooter;
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << NC::fmtBold << "Album: " << NC::fmtBoldEnd;
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << NC::fmtBold << "Album: " << NC::fmtBoldEnd;
|
||||
std::string new_album = wFooter->getString(myLibrary->Albums->current().value().Album);
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
if (!new_album.empty() && new_album != myLibrary->Albums->current().value().Album)
|
||||
{
|
||||
bool success = 1;
|
||||
ShowMessage("Updating tags...");
|
||||
Statusbar::msg("Updating tags...");
|
||||
for (size_t i = 0; i < myLibrary->Songs->size(); ++i)
|
||||
{
|
||||
ShowMessage("Updating tags in \"%s\"...", (*myLibrary->Songs)[i].value().getName().c_str());
|
||||
Statusbar::msg("Updating tags in \"%s\"...", (*myLibrary->Songs)[i].value().getName().c_str());
|
||||
std::string path = Config.mpd_music_dir + (*myLibrary->Songs)[i].value().getURI();
|
||||
TagLib::FileRef f(path.c_str());
|
||||
if (f.isNull())
|
||||
{
|
||||
const char msg[] = "Error while opening file \"%ls\"";
|
||||
ShowMessage(msg, wideShorten(ToWString((*myLibrary->Songs)[i].value().getURI()), COLS-const_strlen(msg)).c_str());
|
||||
Statusbar::msg(msg, wideShorten(ToWString((*myLibrary->Songs)[i].value().getURI()), COLS-const_strlen(msg)).c_str());
|
||||
success = 0;
|
||||
break;
|
||||
}
|
||||
@@ -1437,7 +1438,7 @@ void EditLibraryAlbum::Run()
|
||||
if (!f.save())
|
||||
{
|
||||
const char msg[] = "Error while writing tags in \"%ls\"";
|
||||
ShowMessage(msg, wideShorten(ToWString((*myLibrary->Songs)[i].value().getURI()), COLS-const_strlen(msg)).c_str());
|
||||
Statusbar::msg(msg, wideShorten(ToWString((*myLibrary->Songs)[i].value().getURI()), COLS-const_strlen(msg)).c_str());
|
||||
success = 0;
|
||||
break;
|
||||
}
|
||||
@@ -1445,7 +1446,7 @@ void EditLibraryAlbum::Run()
|
||||
if (success)
|
||||
{
|
||||
Mpd.UpdateDirectory(getSharedDirectory(myLibrary->Songs->beginV(), myLibrary->Songs->endV()));
|
||||
ShowMessage("Tags updated successfully");
|
||||
Statusbar::msg("Tags updated successfully");
|
||||
}
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
@@ -1472,10 +1473,10 @@ void EditDirectoryName::Run()
|
||||
if (myScreen == myBrowser)
|
||||
{
|
||||
std::string old_dir = myBrowser->Main()->current().value().name;
|
||||
LockStatusbar();
|
||||
Statusbar() << NC::fmtBold << "Directory: " << NC::fmtBoldEnd;
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << NC::fmtBold << "Directory: " << NC::fmtBoldEnd;
|
||||
std::string new_dir = wFooter->getString(old_dir);
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
if (!new_dir.empty() && new_dir != old_dir)
|
||||
{
|
||||
std::string full_old_dir;
|
||||
@@ -1490,7 +1491,7 @@ void EditDirectoryName::Run()
|
||||
if (rename_result == 0)
|
||||
{
|
||||
const char msg[] = "Directory renamed to \"%ls\"";
|
||||
ShowMessage(msg, wideShorten(ToWString(new_dir), COLS-const_strlen(msg)).c_str());
|
||||
Statusbar::msg(msg, wideShorten(ToWString(new_dir), COLS-const_strlen(msg)).c_str());
|
||||
if (!myBrowser->isLocal())
|
||||
Mpd.UpdateDirectory(locale_to_utf_cpy(getSharedDirectory(old_dir, new_dir)));
|
||||
myBrowser->GetDirectory(myBrowser->CurrentDir());
|
||||
@@ -1498,7 +1499,7 @@ void EditDirectoryName::Run()
|
||||
else
|
||||
{
|
||||
const char msg[] = "Couldn't rename \"%ls\": %s";
|
||||
ShowMessage(msg, wideShorten(ToWString(old_dir), COLS-const_strlen(msg)-25).c_str(), strerror(errno));
|
||||
Statusbar::msg(msg, wideShorten(ToWString(old_dir), COLS-const_strlen(msg)-25).c_str(), strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1506,10 +1507,10 @@ void EditDirectoryName::Run()
|
||||
else if (myScreen->ActiveWindow() == myTagEditor->Dirs)
|
||||
{
|
||||
std::string old_dir = myTagEditor->Dirs->current().value().first;
|
||||
LockStatusbar();
|
||||
Statusbar() << NC::fmtBold << "Directory: " << NC::fmtBoldEnd;
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << NC::fmtBold << "Directory: " << NC::fmtBoldEnd;
|
||||
std::string new_dir = wFooter->getString(old_dir);
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
if (!new_dir.empty() && new_dir != old_dir)
|
||||
{
|
||||
std::string full_old_dir = Config.mpd_music_dir + myTagEditor->CurrentDir() + "/" + locale_to_utf_cpy(old_dir);
|
||||
@@ -1517,13 +1518,13 @@ void EditDirectoryName::Run()
|
||||
if (rename(full_old_dir.c_str(), full_new_dir.c_str()) == 0)
|
||||
{
|
||||
const char msg[] = "Directory renamed to \"%ls\"";
|
||||
ShowMessage(msg, wideShorten(ToWString(new_dir), COLS-const_strlen(msg)).c_str());
|
||||
Statusbar::msg(msg, wideShorten(ToWString(new_dir), COLS-const_strlen(msg)).c_str());
|
||||
Mpd.UpdateDirectory(myTagEditor->CurrentDir());
|
||||
}
|
||||
else
|
||||
{
|
||||
const char msg[] = "Couldn't rename \"%ls\": %s";
|
||||
ShowMessage(msg, wideShorten(ToWString(old_dir), COLS-const_strlen(msg)-25).c_str(), strerror(errno));
|
||||
Statusbar::msg(msg, wideShorten(ToWString(old_dir), COLS-const_strlen(msg)-25).c_str(), strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1548,16 +1549,16 @@ void EditPlaylistName::Run()
|
||||
old_name = myPlaylistEditor->Playlists->current().value();
|
||||
else
|
||||
old_name = myBrowser->Main()->current().value().name;
|
||||
LockStatusbar();
|
||||
Statusbar() << NC::fmtBold << "Playlist: " << NC::fmtBoldEnd;
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << NC::fmtBold << "Playlist: " << NC::fmtBoldEnd;
|
||||
std::string new_name = wFooter->getString(old_name);
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
if (!new_name.empty() && new_name != old_name)
|
||||
{
|
||||
if (Mpd.Rename(locale_to_utf_cpy(old_name), locale_to_utf_cpy(new_name)))
|
||||
{
|
||||
const char msg[] = "Playlist renamed to \"%ls\"";
|
||||
ShowMessage(msg, wideShorten(ToWString(new_name), COLS-const_strlen(msg)).c_str());
|
||||
Statusbar::msg(msg, wideShorten(ToWString(new_name), COLS-const_strlen(msg)).c_str());
|
||||
if (myBrowser->Main() && !myBrowser->isLocal())
|
||||
myBrowser->GetDirectory("/");
|
||||
if (myPlaylistEditor->Main())
|
||||
@@ -1619,31 +1620,31 @@ void ToggleScreenLock::Run()
|
||||
BasicScreen::Unlock();
|
||||
Action::SetResizeFlags();
|
||||
myScreen->Resize();
|
||||
ShowMessage("Screen unlocked");
|
||||
Statusbar::msg("Screen unlocked");
|
||||
}
|
||||
else
|
||||
{
|
||||
int part = Config.locked_screen_width_part*100;
|
||||
if (Config.ask_for_locked_screen_width_part)
|
||||
{
|
||||
LockStatusbar();
|
||||
Statusbar() << "% of the locked screen's width to be reserved (20-80): ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << "% of the locked screen's width to be reserved (20-80): ";
|
||||
std::string str_part = wFooter->getString(intTo<std::string>::apply(Config.locked_screen_width_part*100));
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
if (str_part.empty())
|
||||
return;
|
||||
part = stringToInt(str_part);
|
||||
}
|
||||
if (part < 20 || part > 80)
|
||||
{
|
||||
ShowMessage("Number is out of range");
|
||||
Statusbar::msg("Number is out of range");
|
||||
return;
|
||||
}
|
||||
Config.locked_screen_width_part = part/100.0;
|
||||
if (myScreen->Lock())
|
||||
ShowMessage("Screen locked (with %d%% width)", part);
|
||||
Statusbar::msg("Screen locked (with %d%% width)", part);
|
||||
else
|
||||
ShowMessage("Current screen can't be locked");
|
||||
Statusbar::msg("Current screen can't be locked");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1675,10 +1676,10 @@ void JumpToPositionInSong::Run()
|
||||
|
||||
const MPD::Song s = myPlaylist->nowPlayingSong();
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << "Position to go (in %/mm:ss/seconds(s)): ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << "Position to go (in %/mm:ss/seconds(s)): ";
|
||||
std::string position = wFooter->getString();
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
|
||||
if (position.empty())
|
||||
return;
|
||||
@@ -1690,7 +1691,7 @@ void JumpToPositionInSong::Run()
|
||||
if (newpos >= 0 && newpos <= Mpd.GetTotalTime())
|
||||
Mpd.Seek(newpos);
|
||||
else
|
||||
ShowMessage("Out of bounds, 0:00-%s possible for mm:ss, %s given", s.getLength().c_str(), MPD::Song::ShowTime(newpos).c_str());
|
||||
Statusbar::msg("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
|
||||
{
|
||||
@@ -1698,7 +1699,7 @@ void JumpToPositionInSong::Run()
|
||||
if (newpos >= 0 && newpos <= Mpd.GetTotalTime())
|
||||
Mpd.Seek(newpos);
|
||||
else
|
||||
ShowMessage("Out of bounds, 0-%d possible for seconds, %d given", s.getDuration(), newpos);
|
||||
Statusbar::msg("Out of bounds, 0-%d possible for seconds, %d given", s.getDuration(), newpos);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1706,7 +1707,7 @@ void JumpToPositionInSong::Run()
|
||||
if (newpos >= 0 && newpos <= 100)
|
||||
Mpd.Seek(Mpd.GetTotalTime()*newpos/100.0);
|
||||
else
|
||||
ShowMessage("Out of bounds, 0-100 possible for %%, %d given", newpos);
|
||||
Statusbar::msg("Out of bounds, 0-100 possible for %%, %d given", newpos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1720,7 +1721,7 @@ void ReverseSelection::Run()
|
||||
{
|
||||
auto w = hasSongs(myScreen);
|
||||
w->reverseSelection();
|
||||
ShowMessage("Selection reversed");
|
||||
Statusbar::msg("Selection reversed");
|
||||
}
|
||||
|
||||
bool RemoveSelection::canBeRun() const
|
||||
@@ -1733,7 +1734,7 @@ void RemoveSelection::Run()
|
||||
auto pl = proxySongList(myScreen);
|
||||
for (size_t i = 0; i < pl->size(); ++i)
|
||||
pl->setSelected(i, false);
|
||||
ShowMessage("Selection removed");
|
||||
Statusbar::msg("Selection removed");
|
||||
}
|
||||
|
||||
bool SelectAlbum::canBeRun() const
|
||||
@@ -1770,7 +1771,7 @@ void SelectAlbum::Run()
|
||||
else
|
||||
pl->setSelected(pos, true);
|
||||
}
|
||||
ShowMessage("Album around cursor position selected");
|
||||
Statusbar::msg("Album around cursor position selected");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1786,9 +1787,9 @@ void CropMainPlaylist::Run()
|
||||
yes = AskYesNoQuestion("Do you really want to crop main playlist?", TraceMpdStatus);
|
||||
if (yes)
|
||||
{
|
||||
ShowMessage("Cropping playlist...");
|
||||
Statusbar::msg("Cropping playlist...");
|
||||
if (cropPlaylist(*myPlaylist->Items, std::bind(&MPD::Connection::Delete, _1, _2)))
|
||||
ShowMessage("Cropping playlist...");
|
||||
Statusbar::msg("Cropping playlist...");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1807,9 +1808,9 @@ void CropPlaylist::Run()
|
||||
if (yes)
|
||||
{
|
||||
auto delete_fun = std::bind(&MPD::Connection::PlaylistDelete, _1, playlist, _2);
|
||||
ShowMessage("Cropping playlist \"%s\"...", playlist.c_str());
|
||||
Statusbar::msg("Cropping playlist \"%s\"...", playlist.c_str());
|
||||
if (cropPlaylist(*myPlaylistEditor->Content, delete_fun))
|
||||
ShowMessage("Playlist \"%s\" cropped", playlist.c_str());
|
||||
Statusbar::msg("Playlist \"%s\" cropped", playlist.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1822,9 +1823,9 @@ void ClearMainPlaylist::Run()
|
||||
{
|
||||
auto delete_fun = std::bind(&MPD::Connection::Delete, _1, _2);
|
||||
auto clear_fun = std::bind(&MPD::Connection::ClearMainPlaylist, _1);
|
||||
ShowMessage("Deleting items...");
|
||||
Statusbar::msg("Deleting items...");
|
||||
if (clearPlaylist(*myPlaylist->Items, delete_fun, clear_fun))
|
||||
ShowMessage("Items deleted");
|
||||
Statusbar::msg("Items deleted");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1844,9 +1845,9 @@ void ClearPlaylist::Run()
|
||||
{
|
||||
auto delete_fun = std::bind(&MPD::Connection::PlaylistDelete, _1, playlist, _2);
|
||||
auto clear_fun = std::bind(&MPD::Connection::ClearPlaylist, _1, playlist);
|
||||
ShowMessage("Deleting items from \"%s\"...", playlist.c_str());
|
||||
Statusbar::msg("Deleting items from \"%s\"...", playlist.c_str());
|
||||
if (clearPlaylist(*myPlaylistEditor->Content, delete_fun, clear_fun))
|
||||
ShowMessage("Items deleted from \"%s\"", playlist.c_str());
|
||||
Statusbar::msg("Items deleted from \"%s\"", playlist.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1883,21 +1884,21 @@ void ApplyFilter::Run()
|
||||
Filterable *f = dynamic_cast<Filterable *>(myScreen);
|
||||
std::string filter = f->currentFilter();
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << NC::fmtBold << "Apply filter: " << NC::fmtBoldEnd;
|
||||
wFooter->setGetStringHelper(StatusbarApplyFilterImmediately(f, ToWString(filter)));
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << NC::fmtBold << "Apply filter: " << NC::fmtBoldEnd;
|
||||
wFooter->setGetStringHelper(Statusbar::Helpers::ApplyFilterImmediately(f, ToWString(filter)));
|
||||
wFooter->getString(filter);
|
||||
wFooter->setGetStringHelper(StatusbargetStringHelper);
|
||||
UnlockStatusbar();
|
||||
wFooter->setGetStringHelper(Statusbar::Helpers::getString);
|
||||
Statusbar::unlock();
|
||||
|
||||
filter = f->currentFilter();
|
||||
if (filter.empty())
|
||||
{
|
||||
myPlaylist->Items->clearFilterResults();
|
||||
ShowMessage("Filtering disabled");
|
||||
Statusbar::msg("Filtering disabled");
|
||||
}
|
||||
else
|
||||
ShowMessage("Using filter \"%s\"", filter.c_str());
|
||||
Statusbar::msg("Using filter \"%s\"", filter.c_str());
|
||||
|
||||
if (myScreen == myPlaylist)
|
||||
{
|
||||
@@ -1922,15 +1923,15 @@ void Find::Run()
|
||||
{
|
||||
using Global::wFooter;
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << "Find: ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << "Find: ";
|
||||
std::string findme = wFooter->getString();
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
|
||||
ShowMessage("Searching...");
|
||||
Statusbar::msg("Searching...");
|
||||
Screen<NC::Scrollpad> *s = static_cast<Screen<NC::Scrollpad> *>(myScreen);
|
||||
s->Main()->removeFormatting();
|
||||
ShowMessage("%s", findme.empty() || s->Main()->setFormatting(NC::fmtReverse, ToWString(findme), NC::fmtReverseEnd, 0) ? "Done!" : "No matching patterns found");
|
||||
Statusbar::msg("%s", findme.empty() || s->Main()->setFormatting(NC::fmtReverse, ToWString(findme), NC::fmtReverseEnd, 0) ? "Done!" : "No matching patterns found");
|
||||
s->Main()->flush();
|
||||
}
|
||||
|
||||
@@ -1985,14 +1986,14 @@ void PreviousFoundItem::Run()
|
||||
void ToggleFindMode::Run()
|
||||
{
|
||||
Config.wrapped_search = !Config.wrapped_search;
|
||||
ShowMessage("Search mode: %s", Config.wrapped_search ? "Wrapped" : "Normal");
|
||||
Statusbar::msg("Search mode: %s", Config.wrapped_search ? "Wrapped" : "Normal");
|
||||
}
|
||||
|
||||
bool ToggleReplayGainMode::canBeRun() const
|
||||
{
|
||||
if (Mpd.Version() < 16)
|
||||
{
|
||||
ShowMessage("Replay gain mode control is supported in MPD >= 0.16.0");
|
||||
Statusbar::msg("Replay gain mode control is supported in MPD >= 0.16.0");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -2002,8 +2003,8 @@ void ToggleReplayGainMode::Run()
|
||||
{
|
||||
using Global::wFooter;
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << "Replay gain mode? [" << NC::fmtBold << 'o' << NC::fmtBoldEnd << "ff/" << NC::fmtBold << 't' << NC::fmtBoldEnd << "rack/" << NC::fmtBold << 'a' << NC::fmtBoldEnd << "lbum]";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << "Replay gain mode? [" << NC::fmtBold << 'o' << NC::fmtBoldEnd << "ff/" << NC::fmtBold << 't' << NC::fmtBoldEnd << "rack/" << NC::fmtBold << 'a' << NC::fmtBoldEnd << "lbum]";
|
||||
wFooter->refresh();
|
||||
int answer = 0;
|
||||
do
|
||||
@@ -2012,42 +2013,42 @@ void ToggleReplayGainMode::Run()
|
||||
answer = wFooter->readKey();
|
||||
}
|
||||
while (answer != 'o' && answer != 't' && answer != 'a');
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
Mpd.SetReplayGainMode(answer == 't' ? MPD::rgmTrack : (answer == 'a' ? MPD::rgmAlbum : MPD::rgmOff));
|
||||
ShowMessage("Replay gain mode: %s", Mpd.GetReplayGainMode().c_str());
|
||||
Statusbar::msg("Replay gain mode: %s", Mpd.GetReplayGainMode().c_str());
|
||||
}
|
||||
|
||||
void ToggleSpaceMode::Run()
|
||||
{
|
||||
Config.space_selects = !Config.space_selects;
|
||||
ShowMessage("Space mode: %s item", Config.space_selects ? "Select" : "Add");
|
||||
Statusbar::msg("Space mode: %s item", Config.space_selects ? "Select" : "Add");
|
||||
}
|
||||
|
||||
void ToggleAddMode::Run()
|
||||
{
|
||||
Config.ncmpc_like_songs_adding = !Config.ncmpc_like_songs_adding;
|
||||
ShowMessage("Add mode: %s", Config.ncmpc_like_songs_adding ? "Add item to playlist, remove if already added" : "Always add item to playlist");
|
||||
Statusbar::msg("Add mode: %s", Config.ncmpc_like_songs_adding ? "Add item to playlist, remove if already added" : "Always add item to playlist");
|
||||
}
|
||||
|
||||
void ToggleMouse::Run()
|
||||
{
|
||||
Config.mouse_support = !Config.mouse_support;
|
||||
mousemask(Config.mouse_support ? ALL_MOUSE_EVENTS : 0, 0);
|
||||
ShowMessage("Mouse support %s", Config.mouse_support ? "enabled" : "disabled");
|
||||
Statusbar::msg("Mouse support %s", Config.mouse_support ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
void ToggleBitrateVisibility::Run()
|
||||
{
|
||||
Config.display_bitrate = !Config.display_bitrate;
|
||||
ShowMessage("Bitrate visibility %s", Config.display_bitrate ? "enabled" : "disabled");
|
||||
Statusbar::msg("Bitrate visibility %s", Config.display_bitrate ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
void AddRandomItems::Run()
|
||||
{
|
||||
using Global::wFooter;
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << "Add random? [" << NC::fmtBold << 's' << NC::fmtBoldEnd << "ongs/" << NC::fmtBold << 'a' << NC::fmtBoldEnd << "rtists/al" << NC::fmtBold << 'b' << NC::fmtBoldEnd << "ums] ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << "Add random? [" << NC::fmtBold << 's' << NC::fmtBoldEnd << "ongs/" << NC::fmtBold << 'a' << NC::fmtBoldEnd << "rtists/al" << NC::fmtBold << 'b' << NC::fmtBoldEnd << "ums] ";
|
||||
wFooter->refresh();
|
||||
int answer = 0;
|
||||
do
|
||||
@@ -2056,7 +2057,7 @@ void AddRandomItems::Run()
|
||||
answer = wFooter->readKey();
|
||||
}
|
||||
while (answer != 's' && answer != 'a' && answer != 'b');
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
|
||||
mpd_tag_type tag_type = MPD_TAG_ARTIST;
|
||||
std::string tag_type_str ;
|
||||
@@ -2068,12 +2069,12 @@ void AddRandomItems::Run()
|
||||
else
|
||||
tag_type_str = "song";
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << "Number of random " << tag_type_str << "s: ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << "Number of random " << tag_type_str << "s: ";
|
||||
size_t number = stringToLongInt(wFooter->getString());
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
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");
|
||||
Statusbar::msg("%zu random %s%s added to playlist", number, tag_type_str.c_str(), number == 1 ? "" : "s");
|
||||
}
|
||||
|
||||
bool ToggleBrowserSortMode::canBeRun() const
|
||||
@@ -2089,17 +2090,17 @@ void ToggleBrowserSortMode::Run()
|
||||
if (!myBrowser->isLocal())
|
||||
{
|
||||
Config.browser_sort_mode = smMTime;
|
||||
ShowMessage("Sort songs by: Modification time");
|
||||
Statusbar::msg("Sort songs by: Modification time");
|
||||
break;
|
||||
}
|
||||
// local browser doesn't support sorting by mtime, so we just skip it.
|
||||
case smMTime:
|
||||
Config.browser_sort_mode = smCustomFormat;
|
||||
ShowMessage("Sort songs by: Custom format");
|
||||
Statusbar::msg("Sort songs by: Custom format");
|
||||
break;
|
||||
case smCustomFormat:
|
||||
Config.browser_sort_mode = smName;
|
||||
ShowMessage("Sort songs by: Name");
|
||||
Statusbar::msg("Sort songs by: Name");
|
||||
break;
|
||||
}
|
||||
std::sort(myBrowser->Main()->begin()+(myBrowser->CurrentDir() != "/"), myBrowser->Main()->end(),
|
||||
@@ -2116,8 +2117,8 @@ void ToggleLibraryTagType::Run()
|
||||
{
|
||||
using Global::wFooter;
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << "Tag type? [" << NC::fmtBold << 'a' << NC::fmtBoldEnd << "rtist/album" << NC::fmtBold << 'A' << NC::fmtBoldEnd << "rtist/" << NC::fmtBold << 'y' << NC::fmtBoldEnd << "ear/" << NC::fmtBold << 'g' << NC::fmtBoldEnd << "enre/" << NC::fmtBold << 'c' << NC::fmtBoldEnd << "omposer/" << NC::fmtBold << 'p' << NC::fmtBoldEnd << "erformer] ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << "Tag type? [" << NC::fmtBold << 'a' << NC::fmtBoldEnd << "rtist/album" << NC::fmtBold << 'A' << NC::fmtBoldEnd << "rtist/" << NC::fmtBold << 'y' << NC::fmtBoldEnd << "ear/" << NC::fmtBold << 'g' << NC::fmtBoldEnd << "enre/" << NC::fmtBold << 'c' << NC::fmtBoldEnd << "omposer/" << NC::fmtBold << 'p' << NC::fmtBoldEnd << "erformer] ";
|
||||
wFooter->refresh();
|
||||
int answer = 0;
|
||||
do
|
||||
@@ -2126,7 +2127,7 @@ void ToggleLibraryTagType::Run()
|
||||
answer = wFooter->readKey();
|
||||
}
|
||||
while (answer != 'a' && answer != 'A' && answer != 'y' && answer != 'g' && answer != 'c' && answer != 'p');
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
mpd_tag_type new_tagitem = charToTagType(answer);
|
||||
if (new_tagitem != Config.media_lib_primary_tag)
|
||||
{
|
||||
@@ -2148,7 +2149,7 @@ void ToggleLibraryTagType::Run()
|
||||
myLibrary->Tags->clear();
|
||||
myLibrary->Tags->display();
|
||||
}
|
||||
ShowMessage("Switched to list of %s tag", item_type.c_str());
|
||||
Statusbar::msg("Switched to list of %s tag", item_type.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2188,7 +2189,7 @@ bool SetSelectedItemsPriority::canBeRun() const
|
||||
{
|
||||
if (Mpd.Version() < 17)
|
||||
{
|
||||
ShowMessage("Priorities are supported in MPD >= 0.17.0");
|
||||
Statusbar::msg("Priorities are supported in MPD >= 0.17.0");
|
||||
return false;
|
||||
}
|
||||
return myScreen->ActiveWindow() == myPlaylist->Items && !myPlaylist->Items->empty();
|
||||
@@ -2198,16 +2199,16 @@ void SetSelectedItemsPriority::Run()
|
||||
{
|
||||
using Global::wFooter;
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << "Set priority [0-255]: ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << "Set priority [0-255]: ";
|
||||
std::string strprio = wFooter->getString();
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
if (!isInteger(strprio.c_str(), true))
|
||||
return;
|
||||
int prio = stringToInt(strprio);
|
||||
if (prio < 0 || prio > 255)
|
||||
{
|
||||
ShowMessage("Number is out of range");
|
||||
Statusbar::msg("Number is out of range");
|
||||
return;
|
||||
}
|
||||
myPlaylist->SetSelectedItemsPriority(prio);
|
||||
@@ -2222,10 +2223,10 @@ void FilterPlaylistOnPriorities::Run()
|
||||
{
|
||||
using Global::wFooter;
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << "Show songs with priority higher than: ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << "Show songs with priority higher than: ";
|
||||
std::string strprio = wFooter->getString();
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
if (!isInteger(strprio.c_str(), false))
|
||||
return;
|
||||
unsigned prio = stringToInt(strprio);
|
||||
@@ -2233,7 +2234,7 @@ void FilterPlaylistOnPriorities::Run()
|
||||
[prio](const NC::Menu<MPD::Song>::Item &s) {
|
||||
return s.value().getPrio() > prio;
|
||||
});
|
||||
ShowMessage("Playlist filtered (songs with priority higher than %u)", prio);
|
||||
Statusbar::msg("Playlist filtered (songs with priority higher than %u)", prio);
|
||||
}
|
||||
|
||||
void ShowSongInfo::Run()
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "regex_filter.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
#include "tag_editor.h"
|
||||
#include "utility/comparators.h"
|
||||
|
||||
@@ -158,7 +159,7 @@ void Browser::EnterPressed()
|
||||
{
|
||||
if (Mpd.LoadPlaylist(locale_to_utf_cpy(item.name)))
|
||||
{
|
||||
ShowMessage("Playlist \"%s\" loaded", item.name.c_str());
|
||||
Statusbar::msg("Playlist \"%s\" loaded", item.name.c_str());
|
||||
myPlaylist->PlayNewlyAddedSongs();
|
||||
}
|
||||
}
|
||||
@@ -194,7 +195,7 @@ void Browser::SpacePressed()
|
||||
{
|
||||
MPD::SongList list;
|
||||
MPD::ItemList items;
|
||||
ShowMessage("Scanning directory \"%s\"...", item.name.c_str());
|
||||
Statusbar::msg("Scanning directory \"%s\"...", item.name.c_str());
|
||||
myBrowser->GetLocalDirectory(items, item.name, 1);
|
||||
list.reserve(items.size());
|
||||
for (MPD::ItemList::const_iterator it = items.begin(); it != items.end(); ++it)
|
||||
@@ -205,7 +206,7 @@ void Browser::SpacePressed()
|
||||
# endif // !WIN32
|
||||
result = Mpd.Add(locale_to_utf_cpy(item.name));
|
||||
if (result)
|
||||
ShowMessage("Directory \"%s\" added", item.name.c_str());
|
||||
Statusbar::msg("Directory \"%s\" added", item.name.c_str());
|
||||
break;
|
||||
}
|
||||
case itSong:
|
||||
@@ -216,7 +217,7 @@ void Browser::SpacePressed()
|
||||
case itPlaylist:
|
||||
{
|
||||
if (Mpd.LoadPlaylist(locale_to_utf_cpy(item.name)))
|
||||
ShowMessage("Playlist \"%s\" loaded", item.name.c_str());
|
||||
Statusbar::msg("Playlist \"%s\" loaded", item.name.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -551,12 +552,12 @@ void Browser::ClearDirectory(const std::string &path) const
|
||||
if (remove(full_path.c_str()) == 0)
|
||||
{
|
||||
const char msg[] = "Deleting \"%ls\"...";
|
||||
ShowMessage(msg, wideShorten(ToWString(full_path), COLS-const_strlen(msg)).c_str());
|
||||
Statusbar::msg(msg, wideShorten(ToWString(full_path), COLS-const_strlen(msg)).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
const char msg[] = "Couldn't remove \"%ls\": %s";
|
||||
ShowMessage(msg, wideShorten(ToWString(full_path), COLS-const_strlen(msg)-25).c_str(), strerror(errno));
|
||||
Statusbar::msg(msg, wideShorten(ToWString(full_path), COLS-const_strlen(msg)-25).c_str(), strerror(errno));
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
@@ -566,12 +567,12 @@ void Browser::ChangeBrowseMode()
|
||||
{
|
||||
if (Mpd.GetHostname()[0] != '/')
|
||||
{
|
||||
ShowMessage("For browsing local filesystem connection to MPD via UNIX Socket is required");
|
||||
Statusbar::msg("For browsing local filesystem connection to MPD via UNIX Socket is required");
|
||||
return;
|
||||
}
|
||||
|
||||
itsBrowseLocally = !itsBrowseLocally;
|
||||
ShowMessage("Browse mode: %s", itsBrowseLocally ? "Local filesystem" : "MPD database");
|
||||
Statusbar::msg("Browse mode: %s", itsBrowseLocally ? "Local filesystem" : "MPD database");
|
||||
itsBrowsedDir = itsBrowseLocally ? Config.GetHomeDirectory() : "/";
|
||||
if (itsBrowseLocally && *itsBrowsedDir.rbegin() == '/')
|
||||
itsBrowsedDir.resize(itsBrowsedDir.length()-1);
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "playlist.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
@@ -90,7 +91,7 @@ void Clock::SwitchTo()
|
||||
GetWindowResizeParams(x_offset, width, false);
|
||||
if (Width > width || Height > MainHeight)
|
||||
{
|
||||
ShowMessage("Screen is too small to display clock");
|
||||
Statusbar::msg("Screen is too small to display clock");
|
||||
if (myLockedScreen)
|
||||
UpdateInactiveScreen(myLockedScreen);
|
||||
return;
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Global
|
||||
// height of main window
|
||||
extern size_t MainHeight;
|
||||
|
||||
// indicates whether messages from ShowMessage function should be shown
|
||||
// indicates whether messages from Statusbar::msg function should be shown
|
||||
extern bool ShowMessages;
|
||||
|
||||
// indicates whether seeking action in currently in progress
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "helpers.h"
|
||||
#include "charset.h"
|
||||
#include "global.h"
|
||||
#include "statusbar.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
@@ -211,7 +212,7 @@ void Lastfm::Refetch()
|
||||
if (remove(itsFilename.c_str()) && errno != ENOENT)
|
||||
{
|
||||
const char msg[] = "Couldn't remove \"%ls\": %s";
|
||||
ShowMessage(msg, wideShorten(ToWString(itsFilename), COLS-const_strlen(msg)-25).c_str(), strerror(errno));
|
||||
Statusbar::msg(msg, wideShorten(ToWString(itsFilename), COLS-const_strlen(msg)-25).c_str(), strerror(errno));
|
||||
return;
|
||||
}
|
||||
Load();
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "scrollpad.h"
|
||||
#include "settings.h"
|
||||
#include "song.h"
|
||||
#include "statusbar.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
@@ -112,7 +113,7 @@ void Lyrics::SwitchTo()
|
||||
|
||||
if (isDownloadInProgress || itsWorkersNumber > 0)
|
||||
{
|
||||
ShowMessage("Lyrics are being downloaded...");
|
||||
Statusbar::msg("Lyrics are being downloaded...");
|
||||
return;
|
||||
}
|
||||
# endif // HAVE_CURL_CURL_H
|
||||
@@ -133,7 +134,7 @@ void Lyrics::SwitchTo()
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Song must have both artist and title tag set");
|
||||
Statusbar::msg("Song must have both artist and title tag set");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -157,7 +158,7 @@ std::wstring Lyrics::Title()
|
||||
void Lyrics::SpacePressed()
|
||||
{
|
||||
Config.now_playing_lyrics = !Config.now_playing_lyrics;
|
||||
ShowMessage("Reload lyrics if song changes: %s", Config.now_playing_lyrics ? "On" : "Off");
|
||||
Statusbar::msg("Reload lyrics if song changes: %s", Config.now_playing_lyrics ? "On" : "Off");
|
||||
}
|
||||
|
||||
#ifdef HAVE_CURL_CURL_H
|
||||
@@ -173,7 +174,7 @@ void Lyrics::DownloadInBackground(const MPD::Song &s)
|
||||
f.close();
|
||||
return;
|
||||
}
|
||||
ShowMessage("Fetching lyrics for \"%s\"...", s.toString(Config.song_status_format_no_colors).c_str());
|
||||
Statusbar::msg("Fetching lyrics for \"%s\"...", s.toString(Config.song_status_format_no_colors).c_str());
|
||||
|
||||
MPD::Song *s_copy = new MPD::Song(s);
|
||||
pthread_mutex_lock(&itsDIBLock);
|
||||
@@ -370,11 +371,11 @@ void Lyrics::Edit()
|
||||
|
||||
if (Config.external_editor.empty())
|
||||
{
|
||||
ShowMessage("Proper external_editor variable has to be set in configuration file");
|
||||
Statusbar::msg("Proper external_editor variable has to be set in configuration file");
|
||||
return;
|
||||
}
|
||||
|
||||
ShowMessage("Opening lyrics in external editor...");
|
||||
Statusbar::msg("Opening lyrics in external editor...");
|
||||
|
||||
GNUC_UNUSED int res;
|
||||
if (Config.use_console_editor)
|
||||
@@ -406,7 +407,7 @@ void Lyrics::Refetch()
|
||||
if (remove(itsFilename.c_str()) && errno != ENOENT)
|
||||
{
|
||||
const char msg[] = "Couldn't remove \"%ls\": %s";
|
||||
ShowMessage(msg, wideShorten(ToWString(itsFilename), COLS-const_strlen(msg)-25).c_str(), strerror(errno));
|
||||
Statusbar::msg(msg, wideShorten(ToWString(itsFilename), COLS-const_strlen(msg)-25).c_str(), strerror(errno));
|
||||
return;
|
||||
}
|
||||
Load();
|
||||
@@ -419,9 +420,9 @@ void Lyrics::ToggleFetcher()
|
||||
else
|
||||
itsFetcher = &lyricsPlugins[0];
|
||||
if (*itsFetcher)
|
||||
ShowMessage("Using lyrics database: %s", (*itsFetcher)->name());
|
||||
Statusbar::msg("Using lyrics database: %s", (*itsFetcher)->name());
|
||||
else
|
||||
ShowMessage("Using all lyrics databases");
|
||||
Statusbar::msg("Using all lyrics databases");
|
||||
}
|
||||
|
||||
void Lyrics::Take()
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "playlist.h"
|
||||
#include "regex_filter.h"
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
#include "utility/comparators.h"
|
||||
#include "utility/type_conversions.h"
|
||||
|
||||
@@ -766,13 +767,13 @@ void MediaLibrary::LocateSong(const MPD::Song &s)
|
||||
if (primary_tag.empty())
|
||||
{
|
||||
std::string item_type = lowercase(tagTypeToString(Config.media_lib_primary_tag));
|
||||
ShowMessage("Can't use this function because the song has no %s tag set", item_type.c_str());
|
||||
Statusbar::msg("Can't use this function because the song has no %s tag set", item_type.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (myScreen != this)
|
||||
SwitchTo();
|
||||
Statusbar() << "Jumping to song...";
|
||||
Statusbar::put() << "Jumping to song...";
|
||||
Global::wFooter->refresh();
|
||||
|
||||
if (!hasTwoColumns)
|
||||
@@ -854,10 +855,10 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
|
||||
|| (w == Albums && Albums->current().value().Date == AllTracksMarker))
|
||||
{
|
||||
std::string tag_type = lowercase(tagTypeToString(Config.media_lib_primary_tag));
|
||||
ShowMessage("Songs with %s = \"%s\" added", tag_type.c_str(), Tags->current().value().c_str());
|
||||
Statusbar::msg("Songs with %s = \"%s\" added", tag_type.c_str(), Tags->current().value().c_str());
|
||||
}
|
||||
else if (w == Albums)
|
||||
ShowMessage("Songs from album \"%s\" added", Albums->current().value().Album.c_str());
|
||||
Statusbar::msg("Songs from album \"%s\" added", Albums->current().value().Album.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "playlist.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
#include "visualizer.h"
|
||||
|
||||
namespace
|
||||
@@ -52,7 +53,7 @@ namespace
|
||||
{
|
||||
if (signal == SIGPIPE)
|
||||
{
|
||||
ShowMessage("SIGPIPE (broken pipe signal) received");
|
||||
Statusbar::msg("SIGPIPE (broken pipe signal) received");
|
||||
}
|
||||
else if (signal == SIGWINCH)
|
||||
{
|
||||
@@ -157,9 +158,9 @@ int main(int argc, char **argv)
|
||||
|
||||
wFooter = new NC::Window(0, Action::FooterStartY, COLS, Action::FooterHeight, "", Config.statusbar_color, NC::brNone);
|
||||
wFooter->setTimeout(500);
|
||||
wFooter->setGetStringHelper(StatusbargetStringHelper);
|
||||
wFooter->setGetStringHelper(Statusbar::Helpers::getString);
|
||||
if (Mpd.SupportsIdle())
|
||||
wFooter->addFDCallback(Mpd.GetFD(), StatusbarMPDCallback);
|
||||
wFooter->addFDCallback(Mpd.GetFD(), Statusbar::Helpers::mpd);
|
||||
wFooter->createHistory();
|
||||
|
||||
// initialize screens to browser as default previous screen
|
||||
@@ -207,13 +208,13 @@ int main(int argc, char **argv)
|
||||
{
|
||||
if (!wFooter->FDCallbacksListEmpty())
|
||||
wFooter->clearFDCallbacksList();
|
||||
ShowMessage("Attempting to reconnect...");
|
||||
Statusbar::msg("Attempting to reconnect...");
|
||||
if (Mpd.Connect())
|
||||
{
|
||||
ShowMessage("Connected to %s", Mpd.GetHostname().c_str());
|
||||
Statusbar::msg("Connected to %s", Mpd.GetHostname().c_str());
|
||||
if (Mpd.SupportsIdle())
|
||||
{
|
||||
wFooter->addFDCallback(Mpd.GetFD(), StatusbarMPDCallback);
|
||||
wFooter->addFDCallback(Mpd.GetFD(), Statusbar::Helpers::mpd);
|
||||
Mpd.OrderDataFetching(); // we need info about new connection
|
||||
}
|
||||
ShowMessages = false;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "global.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
@@ -87,12 +88,12 @@ void Outputs::EnterPressed()
|
||||
if (w->current().value().isEnabled())
|
||||
{
|
||||
if (Mpd.DisableOutput(w->choice()))
|
||||
ShowMessage("Output \"%s\" disabled", w->current().value().name().c_str());
|
||||
Statusbar::msg("Output \"%s\" disabled", w->current().value().name().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Mpd.EnableOutput(w->choice()))
|
||||
ShowMessage("Output \"%s\" enabled", w->current().value().name().c_str());
|
||||
Statusbar::msg("Output \"%s\" enabled", w->current().value().name().c_str());
|
||||
}
|
||||
if (!Mpd.SupportsIdle())
|
||||
FetchList();
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "regex_filter.h"
|
||||
#include "song.h"
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
#include "utility/comparators.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
@@ -187,7 +188,7 @@ void Playlist::EnterPressed()
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Move tag types up and down to adjust sort order");
|
||||
Statusbar::msg("Move tag types up and down to adjust sort order");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -227,11 +228,11 @@ void Playlist::EnterPressed()
|
||||
}
|
||||
};
|
||||
|
||||
ShowMessage("Sorting...");
|
||||
Statusbar::msg("Sorting...");
|
||||
Mpd.StartCommandsList();
|
||||
quick_sort(playlist.begin(), playlist.end());
|
||||
if (Mpd.CommitCommandsList())
|
||||
ShowMessage("Playlist sorted");
|
||||
Statusbar::msg("Playlist sorted");
|
||||
w = Items;
|
||||
}
|
||||
}
|
||||
@@ -378,7 +379,7 @@ bool Playlist::isFiltered()
|
||||
{
|
||||
if (Items->isFiltered())
|
||||
{
|
||||
ShowMessage("Function currently unavailable due to filtered playlist");
|
||||
Statusbar::msg("Function currently unavailable due to filtered playlist");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -389,7 +390,7 @@ void Playlist::Sort()
|
||||
if (isFiltered())
|
||||
return;
|
||||
if (Items->getWidth() < SortDialogWidth || MainHeight < 5)
|
||||
ShowMessage("Screen is too small to display dialog window");
|
||||
Statusbar::msg("Screen is too small to display dialog window");
|
||||
else
|
||||
{
|
||||
SortDialog->reset();
|
||||
@@ -401,7 +402,7 @@ void Playlist::Reverse()
|
||||
{
|
||||
if (isFiltered())
|
||||
return;
|
||||
ShowMessage("Reversing playlist order...");
|
||||
Statusbar::msg("Reversing playlist order...");
|
||||
size_t beginning = -1, end = -1;
|
||||
for (size_t i = 0; i < Items->size(); ++i)
|
||||
{
|
||||
@@ -421,7 +422,7 @@ void Playlist::Reverse()
|
||||
for (size_t i = beginning, j = end-1; i < (beginning+end)/2; ++i, --j)
|
||||
Mpd.Swap(i, j);
|
||||
if (Mpd.CommitCommandsList())
|
||||
ShowMessage("Playlist reversed");
|
||||
Statusbar::msg("Playlist reversed");
|
||||
}
|
||||
|
||||
void Playlist::EnableHighlighting()
|
||||
@@ -516,7 +517,7 @@ bool Playlist::Add(const MPD::Song &s, bool play, int position)
|
||||
int id = Mpd.AddSong(s, position);
|
||||
if (id >= 0)
|
||||
{
|
||||
ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format_no_colors).c_str());
|
||||
Statusbar::msg("Added to playlist: %s", s.toString(Config.song_status_format_no_colors).c_str());
|
||||
if (play)
|
||||
Mpd.PlayID(id);
|
||||
return true;
|
||||
@@ -570,7 +571,7 @@ void Playlist::SetSelectedItemsPriority(int prio)
|
||||
for (auto it = list.begin(); it != list.end(); ++it)
|
||||
Mpd.SetPriority((*it)->value(), prio);
|
||||
if (Mpd.CommitCommandsList())
|
||||
ShowMessage("Priority set");
|
||||
Statusbar::msg("Priority set");
|
||||
}
|
||||
|
||||
bool Playlist::checkForSong(const MPD::Song &s)
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "mpdpp.h"
|
||||
#include "regex_filter.h"
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
#include "tag_editor.h"
|
||||
#include "utility/comparators.h"
|
||||
|
||||
@@ -211,7 +212,7 @@ bool PlaylistEditor::isContentFiltered()
|
||||
{
|
||||
if (Content->isFiltered())
|
||||
{
|
||||
ShowMessage("Function currently unavailable due to filtered playlist content");
|
||||
Statusbar::msg("Function currently unavailable due to filtered playlist content");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -278,7 +279,7 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play)
|
||||
{
|
||||
if (Mpd.LoadPlaylist(utf_to_locale_cpy(Playlists->current().value())))
|
||||
{
|
||||
ShowMessage("Playlist \"%s\" loaded", Playlists->current().value().c_str());
|
||||
Statusbar::msg("Playlist \"%s\" loaded", Playlists->current().value().c_str());
|
||||
if (add_n_play)
|
||||
myPlaylist->PlayNewlyAddedSongs();
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "search_engine.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
#include "utility/comparators.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
@@ -163,12 +164,12 @@ void SearchEngine::EnterPressed()
|
||||
if (option > ConstraintsNumber && option < SearchButton)
|
||||
w->current().value().buffer().clear();
|
||||
if (option < SearchButton)
|
||||
LockStatusbar();
|
||||
Statusbar::lock();
|
||||
|
||||
if (option < ConstraintsNumber)
|
||||
{
|
||||
std::string constraint = ConstraintsNames[option];
|
||||
Statusbar() << NC::fmtBold << constraint << NC::fmtBoldEnd << ": ";
|
||||
Statusbar::put() << NC::fmtBold << constraint << NC::fmtBoldEnd << ": ";
|
||||
itsConstraints[option] = Global::wFooter->getString(itsConstraints[option]);
|
||||
w->current().value().buffer().clear();
|
||||
constraint.resize(13, ' ');
|
||||
@@ -189,7 +190,7 @@ void SearchEngine::EnterPressed()
|
||||
else if (option == SearchButton)
|
||||
{
|
||||
w->showAll();
|
||||
ShowMessage("Searching...");
|
||||
Statusbar::msg("Searching...");
|
||||
if (w->size() > StaticOptions)
|
||||
Prepare();
|
||||
Search();
|
||||
@@ -204,7 +205,7 @@ void SearchEngine::EnterPressed()
|
||||
w->at(ResetButton+2).value().mkBuffer() << Config.color1 << "Search results: " << Config.color2 << "Found " << found << (found > 1 ? " songs" : " song") << NC::clDefault;
|
||||
w->insertSeparator(ResetButton+3);
|
||||
markSongsInPlaylist(getProxySongList());
|
||||
ShowMessage("Searching finished");
|
||||
Statusbar::msg("Searching finished");
|
||||
if (Config.block_search_constraints_change)
|
||||
for (size_t i = 0; i < StaticOptions-4; ++i)
|
||||
w->at(i).setInactive(true);
|
||||
@@ -212,7 +213,7 @@ void SearchEngine::EnterPressed()
|
||||
w->scroll(NC::wDown);
|
||||
}
|
||||
else
|
||||
ShowMessage("No results found");
|
||||
Statusbar::msg("No results found");
|
||||
}
|
||||
else if (option == ResetButton)
|
||||
{
|
||||
@@ -222,7 +223,7 @@ void SearchEngine::EnterPressed()
|
||||
myPlaylist->Add(w->current().value().song(), 1);
|
||||
|
||||
if (option < SearchButton)
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
}
|
||||
|
||||
void SearchEngine::SpacePressed()
|
||||
@@ -387,7 +388,7 @@ void SearchEngine::reset()
|
||||
itsConstraints[i].clear();
|
||||
w->reset();
|
||||
Prepare();
|
||||
ShowMessage("Search state reset");
|
||||
Statusbar::msg("Search state reset");
|
||||
}
|
||||
|
||||
void SearchEngine::Search()
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "sel_items_adder.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
#include "utility/comparators.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
@@ -77,7 +78,7 @@ void SelectedItemsAdder::SwitchTo()
|
||||
|
||||
if (MainHeight < 5)
|
||||
{
|
||||
ShowMessage("Screen is too small to display this window");
|
||||
Statusbar::msg("Screen is too small to display this window");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -95,7 +96,7 @@ void SelectedItemsAdder::SwitchTo()
|
||||
|
||||
bool playlists_not_active = myScreen == myBrowser && myBrowser->isLocal();
|
||||
if (playlists_not_active)
|
||||
ShowMessage("Local items can't be added to stored playlists");
|
||||
Statusbar::msg("Local items can't be added to stored playlists");
|
||||
|
||||
w->clear();
|
||||
w->reset();
|
||||
@@ -172,10 +173,10 @@ void SelectedItemsAdder::EnterPressed()
|
||||
}
|
||||
else if (pos == 1) // create new playlist
|
||||
{
|
||||
LockStatusbar();
|
||||
Statusbar() << "Save playlist as: ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << "Save playlist as: ";
|
||||
std::string playlist = Global::wFooter->getString();
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
if (!playlist.empty())
|
||||
{
|
||||
std::string utf_playlist = locale_to_utf_cpy(playlist);
|
||||
@@ -183,7 +184,7 @@ void SelectedItemsAdder::EnterPressed()
|
||||
for (auto it = list.begin(); it != list.end(); ++it)
|
||||
Mpd.AddToPlaylist(utf_playlist, *it);
|
||||
if (Mpd.CommitCommandsList())
|
||||
ShowMessage("Selected item(s) added to playlist \"%s\"", playlist.c_str());
|
||||
Statusbar::msg("Selected item(s) added to playlist \"%s\"", playlist.c_str());
|
||||
}
|
||||
}
|
||||
else if (pos > 1 && pos < w->size()-1) // add items to existing playlist
|
||||
@@ -193,7 +194,7 @@ void SelectedItemsAdder::EnterPressed()
|
||||
for (auto it = list.begin(); it != list.end(); ++it)
|
||||
Mpd.AddToPlaylist(playlist, *it);
|
||||
if (Mpd.CommitCommandsList())
|
||||
ShowMessage("Selected item(s) added to playlist \"%s\"", w->current().value().c_str());
|
||||
Statusbar::msg("Selected item(s) added to playlist \"%s\"", w->current().value().c_str());
|
||||
}
|
||||
if (pos != w->size()-1)
|
||||
{
|
||||
@@ -209,7 +210,7 @@ void SelectedItemsAdder::EnterPressed()
|
||||
// disable adding after current track/album when stopped
|
||||
if (pos > 1 && pos < 4 && !Mpd.isPlaying())
|
||||
{
|
||||
ShowMessage("Player is stopped");
|
||||
Statusbar::msg("Player is stopped");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -246,7 +247,7 @@ void SelectedItemsAdder::EnterPressed()
|
||||
}
|
||||
|
||||
if (successful_operation)
|
||||
ShowMessage("Selected item(s) added");
|
||||
Statusbar::msg("Selected item(s) added");
|
||||
}
|
||||
SwitchTo();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "server_info.h"
|
||||
#include "statusbar.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
@@ -53,7 +54,7 @@ void ServerInfo::SwitchTo()
|
||||
}
|
||||
if (MainHeight < 5)
|
||||
{
|
||||
ShowMessage("Screen is too small to display this window");
|
||||
Statusbar::msg("Screen is too small to display this window");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
202
src/status.cpp
202
src/status.cpp
@@ -37,6 +37,7 @@
|
||||
#include "sel_items_adder.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
#include "tag_editor.h"
|
||||
#include "visualizer.h"
|
||||
|
||||
@@ -50,16 +51,6 @@ using Global::wHeader;
|
||||
using Global::Timer;
|
||||
using Global::VolumeState;
|
||||
|
||||
namespace
|
||||
{
|
||||
timeval time_of_statusbar_lock;
|
||||
int lock_statusbar_delay = -1;
|
||||
|
||||
bool block_statusbar_update = 0;
|
||||
bool block_progressbar_update = 0;
|
||||
bool allow_statusbar_unlock = 1;
|
||||
}
|
||||
|
||||
#ifndef USE_PDCURSES
|
||||
void WindowTitle(const std::string &status)
|
||||
{
|
||||
@@ -76,100 +67,6 @@ void DrawNowPlayingTitle(MPD::Song &np)
|
||||
WindowTitle(np.toString(Config.song_window_title_format));
|
||||
}
|
||||
|
||||
void StatusbarMPDCallback()
|
||||
{
|
||||
Mpd.OrderDataFetching();
|
||||
}
|
||||
|
||||
void StatusbargetStringHelper(const std::wstring &)
|
||||
{
|
||||
TraceMpdStatus();
|
||||
}
|
||||
|
||||
void StatusbarApplyFilterImmediately::operator()(const std::wstring &ws)
|
||||
{
|
||||
// if input queue is not empty, we don't want to update filter since next
|
||||
// character will be taken from queue immediately, trigering this function
|
||||
// again and thus making it inefficient, so let's apply filter only if
|
||||
// "real" user input arrived. however, we want to apply filter if ENTER
|
||||
// is next in queue, so its effects will be seen.
|
||||
if (wFooter->inputQueue().empty() || wFooter->inputQueue().front() == KEY_ENTER)
|
||||
{
|
||||
if (m_ws != ws)
|
||||
{
|
||||
m_ws = ws;
|
||||
m_f->applyFilter(ToString(m_ws));
|
||||
myScreen->RefreshWindow();
|
||||
}
|
||||
TraceMpdStatus();
|
||||
}
|
||||
}
|
||||
|
||||
void LockProgressbar()
|
||||
{
|
||||
block_progressbar_update = 1;
|
||||
}
|
||||
|
||||
void UnlockProgressbar()
|
||||
{
|
||||
block_progressbar_update = 0;
|
||||
}
|
||||
|
||||
void LockStatusbar()
|
||||
{
|
||||
if (Config.statusbar_visibility)
|
||||
block_statusbar_update = 1;
|
||||
else
|
||||
block_progressbar_update = 1;
|
||||
allow_statusbar_unlock = 0;
|
||||
}
|
||||
|
||||
void UnlockStatusbar()
|
||||
{
|
||||
allow_statusbar_unlock = 1;
|
||||
if (lock_statusbar_delay < 0)
|
||||
{
|
||||
if (Config.statusbar_visibility)
|
||||
block_statusbar_update = 0;
|
||||
else
|
||||
block_progressbar_update = 0;
|
||||
}
|
||||
if (!Mpd.isPlaying())
|
||||
{
|
||||
if (Config.new_design)
|
||||
DrawProgressbar(Mpd.GetElapsedTime(), Mpd.GetTotalTime());
|
||||
else
|
||||
Statusbar() << wclrtoeol;
|
||||
wFooter->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void TryToClearStatusbarMessage()
|
||||
{
|
||||
using Global::Timer;
|
||||
if (lock_statusbar_delay > 0)
|
||||
{
|
||||
if (Timer.tv_sec >= time_of_statusbar_lock.tv_sec+lock_statusbar_delay)
|
||||
{
|
||||
lock_statusbar_delay = -1;
|
||||
|
||||
if (Config.statusbar_visibility)
|
||||
block_statusbar_update = !allow_statusbar_unlock;
|
||||
else
|
||||
block_progressbar_update = !allow_statusbar_unlock;
|
||||
|
||||
if (Mpd.GetState() != MPD::psPlay && !block_statusbar_update && !block_progressbar_update)
|
||||
{
|
||||
if (Config.new_design)
|
||||
DrawProgressbar(Mpd.GetElapsedTime(), Mpd.GetTotalTime());
|
||||
else
|
||||
Statusbar() << wclrtoeol;
|
||||
wFooter->refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TraceMpdStatus()
|
||||
{
|
||||
static timeval past = { 0, 0 };
|
||||
@@ -203,7 +100,7 @@ void TraceMpdStatus()
|
||||
myPlaylist->Items->refresh();
|
||||
}
|
||||
|
||||
TryToClearStatusbarMessage();
|
||||
Statusbar::tryRedraw();
|
||||
}
|
||||
|
||||
void NcmpcppErrorCallback(MPD::Connection *, int errorid, const char *msg, void *)
|
||||
@@ -214,11 +111,11 @@ void NcmpcppErrorCallback(MPD::Connection *, int errorid, const char *msg, void
|
||||
if ((errorid >> 8) == MPD_SERVER_ERROR_PERMISSION)
|
||||
{
|
||||
wFooter->setGetStringHelper(0);
|
||||
Statusbar() << "Password: ";
|
||||
Statusbar::put() << "Password: ";
|
||||
Mpd.SetPassword(wFooter->getString(-1, 0, 1));
|
||||
if (Mpd.SendPassword())
|
||||
ShowMessage("Password accepted");
|
||||
wFooter->setGetStringHelper(StatusbargetStringHelper);
|
||||
Statusbar::msg("Password accepted");
|
||||
wFooter->setGetStringHelper(Statusbar::Helpers::getString);
|
||||
}
|
||||
else if ((errorid >> 8) == MPD_SERVER_ERROR_NO_EXIST && myScreen == myBrowser)
|
||||
{
|
||||
@@ -226,7 +123,7 @@ void NcmpcppErrorCallback(MPD::Connection *, int errorid, const char *msg, void
|
||||
myBrowser->Refresh();
|
||||
}
|
||||
else
|
||||
ShowMessage("MPD: %s", msg);
|
||||
Statusbar::msg("MPD: %s", msg);
|
||||
}
|
||||
|
||||
void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
|
||||
@@ -351,8 +248,8 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
|
||||
case MPD::psStop:
|
||||
{
|
||||
WindowTitle("ncmpcpp " VERSION);
|
||||
if (!block_progressbar_update)
|
||||
DrawProgressbar(0, 0);
|
||||
if (Progressbar::isUnlocked())
|
||||
Progressbar::draw(0, 0);
|
||||
Playlist::ReloadRemaining = true;
|
||||
if (Config.new_design)
|
||||
{
|
||||
@@ -379,7 +276,7 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
|
||||
*wHeader << NC::XY(0, 1) << NC::fmtBold << player_state << NC::fmtBoldEnd;
|
||||
wHeader->refresh();
|
||||
}
|
||||
else if (!block_statusbar_update && Config.statusbar_visibility)
|
||||
else if (Statusbar::isUnlocked() && Config.statusbar_visibility)
|
||||
{
|
||||
*wFooter << NC::XY(0, 1);
|
||||
if (player_state.empty())
|
||||
@@ -468,7 +365,7 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
|
||||
|
||||
changed.StatusFlags = 1;
|
||||
}
|
||||
else if (!block_statusbar_update && Config.statusbar_visibility)
|
||||
else if (Statusbar::isUnlocked() && Config.statusbar_visibility)
|
||||
{
|
||||
if (Config.display_bitrate && Mpd.GetBitrate())
|
||||
{
|
||||
@@ -501,13 +398,13 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
|
||||
np_song.write(*wFooter, playing_song_scroll_begin, wFooter->getWidth()-player_state.length()-tracklength.length(), L" ** ");
|
||||
*wFooter << NC::fmtBold << NC::XY(wFooter->getWidth()-tracklength.length(), 1) << tracklength << NC::fmtBoldEnd;
|
||||
}
|
||||
if (!block_progressbar_update)
|
||||
DrawProgressbar(Mpd.GetElapsedTime(), Mpd.GetTotalTime());
|
||||
if (Progressbar::isUnlocked())
|
||||
Progressbar::draw(Mpd.GetElapsedTime(), Mpd.GetTotalTime());
|
||||
Global::RedrawStatusbar = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!block_statusbar_update && Config.statusbar_visibility)
|
||||
if (Statusbar::isUnlocked() && Config.statusbar_visibility)
|
||||
*wFooter << NC::XY(0, 1) << wclrtoeol;
|
||||
}
|
||||
}
|
||||
@@ -522,28 +419,28 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
|
||||
if (changed.Repeat)
|
||||
{
|
||||
mpd_repeat = Mpd.GetRepeat() ? 'r' : 0;
|
||||
ShowMessage("Repeat mode is %s", !mpd_repeat ? "off" : "on");
|
||||
Statusbar::msg("Repeat mode is %s", !mpd_repeat ? "off" : "on");
|
||||
}
|
||||
if (changed.Random)
|
||||
{
|
||||
mpd_random = Mpd.GetRandom() ? 'z' : 0;
|
||||
ShowMessage("Random mode is %s", !mpd_random ? "off" : "on");
|
||||
Statusbar::msg("Random mode is %s", !mpd_random ? "off" : "on");
|
||||
}
|
||||
if (changed.Single)
|
||||
{
|
||||
mpd_single = Mpd.GetSingle() ? 's' : 0;
|
||||
ShowMessage("Single mode is %s", !mpd_single ? "off" : "on");
|
||||
Statusbar::msg("Single mode is %s", !mpd_single ? "off" : "on");
|
||||
}
|
||||
if (changed.Consume)
|
||||
{
|
||||
mpd_consume = Mpd.GetConsume() ? 'c' : 0;
|
||||
ShowMessage("Consume mode is %s", !mpd_consume ? "off" : "on");
|
||||
Statusbar::msg("Consume mode is %s", !mpd_consume ? "off" : "on");
|
||||
}
|
||||
if (changed.Crossfade)
|
||||
{
|
||||
int crossfade = Mpd.GetCrossfade();
|
||||
mpd_crossfade = crossfade ? 'x' : 0;
|
||||
ShowMessage("Crossfade set to %d seconds", crossfade);
|
||||
Statusbar::msg("Crossfade set to %d seconds", crossfade);
|
||||
}
|
||||
if (changed.DBUpdating)
|
||||
{
|
||||
@@ -551,11 +448,11 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
|
||||
// finished and nothing changed, so we need to switch it off for them.
|
||||
if (!Mpd.SupportsIdle() || Mpd.Version() > 15)
|
||||
mpd_db_updating = Mpd.GetDBIsUpdating() ? 'U' : 0;
|
||||
ShowMessage(Mpd.GetDBIsUpdating() ? "Database update started!" : "Database update finished!");
|
||||
Statusbar::msg(Mpd.GetDBIsUpdating() ? "Database update started!" : "Database update finished!");
|
||||
if (changed.Database && myScreen == mySelectedItemsAdder)
|
||||
{
|
||||
myScreen->SwitchTo(); // switch to previous screen
|
||||
ShowMessage("Database has changed, you need to select your item(s) once again");
|
||||
Statusbar::msg("Database has changed, you need to select your item(s) once again");
|
||||
}
|
||||
}
|
||||
if (changed.StatusFlags && (Config.header_visibility || Config.new_design))
|
||||
@@ -667,62 +564,3 @@ void DrawHeader()
|
||||
}
|
||||
wHeader->refresh();
|
||||
}
|
||||
|
||||
NC::Window &Statusbar()
|
||||
{
|
||||
*wFooter << NC::XY(0, Config.statusbar_visibility) << wclrtoeol;
|
||||
return *wFooter;
|
||||
}
|
||||
|
||||
void DrawProgressbar(unsigned elapsed, unsigned time)
|
||||
{
|
||||
unsigned pb_width = wFooter->getWidth();
|
||||
unsigned howlong = time ? pb_width*elapsed/time : 0;
|
||||
if (Config.progressbar_boldness)
|
||||
*wFooter << NC::fmtBold;
|
||||
*wFooter << Config.progressbar_color;
|
||||
if (Config.progressbar[2] != '\0')
|
||||
{
|
||||
wFooter->goToXY(0, 0);
|
||||
for (unsigned i = 0; i < pb_width; ++i)
|
||||
*wFooter << Config.progressbar[2];
|
||||
wFooter->goToXY(0, 0);
|
||||
}
|
||||
else
|
||||
mvwhline(wFooter->raw(), 0, 0, 0, pb_width);
|
||||
if (time)
|
||||
{
|
||||
*wFooter << Config.progressbar_elapsed_color;
|
||||
pb_width = std::min(size_t(howlong), wFooter->getWidth());
|
||||
for (unsigned i = 0; i < pb_width; ++i)
|
||||
*wFooter << Config.progressbar[0];
|
||||
if (howlong < wFooter->getWidth())
|
||||
*wFooter << Config.progressbar[1];
|
||||
*wFooter << NC::clEnd;
|
||||
}
|
||||
*wFooter << NC::clEnd;
|
||||
if (Config.progressbar_boldness)
|
||||
*wFooter << NC::fmtBoldEnd;
|
||||
}
|
||||
|
||||
void ShowMessage(const char *format, ...)
|
||||
{
|
||||
if (Global::ShowMessages && allow_statusbar_unlock)
|
||||
{
|
||||
time_of_statusbar_lock = Global::Timer;
|
||||
lock_statusbar_delay = Config.message_delay_time;
|
||||
if (Config.statusbar_visibility)
|
||||
block_statusbar_update = 1;
|
||||
else
|
||||
block_progressbar_update = 1;
|
||||
wFooter->goToXY(0, Config.statusbar_visibility);
|
||||
*wFooter << NC::fmtBoldEnd;
|
||||
va_list list;
|
||||
va_start(list, format);
|
||||
wmove(wFooter->raw(), Config.statusbar_visibility, 0);
|
||||
vw_printw(wFooter->raw(), format, list);
|
||||
wclrtoeol(wFooter->raw());
|
||||
va_end(list);
|
||||
wFooter->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
26
src/status.h
26
src/status.h
@@ -32,36 +32,10 @@
|
||||
|
||||
void DrawNowPlayingTitle();
|
||||
|
||||
void LockProgressbar();
|
||||
void UnlockProgressbar();
|
||||
|
||||
void LockStatusbar();
|
||||
void UnlockStatusbar();
|
||||
|
||||
void TraceMpdStatus();
|
||||
void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges, void *);
|
||||
void NcmpcppErrorCallback(MPD::Connection *, int, const char *, void *);
|
||||
|
||||
void DrawHeader();
|
||||
|
||||
NC::Window &Statusbar();
|
||||
void DrawProgressbar(unsigned elapsed, unsigned time);
|
||||
void ShowMessage(const char *, ...) GNUC_PRINTF(1, 2);
|
||||
|
||||
void StatusbarMPDCallback();
|
||||
void StatusbargetStringHelper(const std::wstring &);
|
||||
|
||||
struct StatusbarApplyFilterImmediately
|
||||
{
|
||||
StatusbarApplyFilterImmediately(Filterable *f, const std::wstring &filter)
|
||||
: m_f(f), m_ws(filter) { }
|
||||
|
||||
void operator()(const std::wstring &ws);
|
||||
|
||||
private:
|
||||
Filterable *m_f;
|
||||
std::wstring m_ws;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
199
src/statusbar.cpp
Normal file
199
src/statusbar.cpp
Normal file
@@ -0,0 +1,199 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008-2012 by Andrzej Rybczak *
|
||||
* electricityispower@gmail.com *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "global.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
|
||||
using Global::wFooter;
|
||||
|
||||
namespace {//
|
||||
|
||||
timeval statusbarLockTime;
|
||||
int statusbarLockDelay = -1;
|
||||
|
||||
bool statusbarBlockUpdate = false;
|
||||
bool progressbarBlockUpdate = false;
|
||||
bool statusbarAllowUnlock = true;
|
||||
|
||||
}
|
||||
|
||||
void Progressbar::lock()
|
||||
{
|
||||
progressbarBlockUpdate = true;
|
||||
}
|
||||
|
||||
void Progressbar::unlock()
|
||||
{
|
||||
progressbarBlockUpdate = false;
|
||||
}
|
||||
|
||||
bool Progressbar::isUnlocked()
|
||||
{
|
||||
return !progressbarBlockUpdate;
|
||||
}
|
||||
|
||||
void Progressbar::draw(unsigned int elapsed, unsigned int time)
|
||||
{
|
||||
unsigned pb_width = wFooter->getWidth();
|
||||
unsigned howlong = time ? pb_width*elapsed/time : 0;
|
||||
if (Config.progressbar_boldness)
|
||||
*wFooter << NC::fmtBold;
|
||||
*wFooter << Config.progressbar_color;
|
||||
if (Config.progressbar[2] != '\0')
|
||||
{
|
||||
wFooter->goToXY(0, 0);
|
||||
for (unsigned i = 0; i < pb_width; ++i)
|
||||
*wFooter << Config.progressbar[2];
|
||||
wFooter->goToXY(0, 0);
|
||||
}
|
||||
else
|
||||
mvwhline(wFooter->raw(), 0, 0, 0, pb_width);
|
||||
if (time)
|
||||
{
|
||||
*wFooter << Config.progressbar_elapsed_color;
|
||||
pb_width = std::min(size_t(howlong), wFooter->getWidth());
|
||||
for (unsigned i = 0; i < pb_width; ++i)
|
||||
*wFooter << Config.progressbar[0];
|
||||
if (howlong < wFooter->getWidth())
|
||||
*wFooter << Config.progressbar[1];
|
||||
*wFooter << NC::clEnd;
|
||||
}
|
||||
*wFooter << NC::clEnd;
|
||||
if (Config.progressbar_boldness)
|
||||
*wFooter << NC::fmtBoldEnd;
|
||||
}
|
||||
|
||||
void Statusbar::lock()
|
||||
{
|
||||
if (Config.statusbar_visibility)
|
||||
statusbarBlockUpdate = true;
|
||||
else
|
||||
progressbarBlockUpdate = true;
|
||||
statusbarAllowUnlock = false;
|
||||
}
|
||||
|
||||
void Statusbar::unlock()
|
||||
{
|
||||
statusbarAllowUnlock = true;
|
||||
if (statusbarLockDelay < 0)
|
||||
{
|
||||
if (Config.statusbar_visibility)
|
||||
statusbarBlockUpdate = false;
|
||||
else
|
||||
progressbarBlockUpdate = false;
|
||||
}
|
||||
if (!Mpd.isPlaying())
|
||||
{
|
||||
if (Config.new_design)
|
||||
Progressbar::draw(Mpd.GetElapsedTime(), Mpd.GetTotalTime());
|
||||
else
|
||||
put() << wclrtoeol;
|
||||
wFooter->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
bool Statusbar::isUnlocked()
|
||||
{
|
||||
return !statusbarBlockUpdate;
|
||||
}
|
||||
|
||||
void Statusbar::tryRedraw()
|
||||
{
|
||||
using Global::Timer;
|
||||
if (statusbarLockDelay > 0
|
||||
&& Timer.tv_sec >= statusbarLockTime.tv_sec+statusbarLockDelay)
|
||||
{
|
||||
statusbarLockDelay = -1;
|
||||
|
||||
if (Config.statusbar_visibility)
|
||||
statusbarBlockUpdate = !statusbarAllowUnlock;
|
||||
else
|
||||
progressbarBlockUpdate = !statusbarAllowUnlock;
|
||||
|
||||
if (Mpd.GetState() != MPD::psPlay && !statusbarBlockUpdate && !progressbarBlockUpdate)
|
||||
{
|
||||
if (Config.new_design)
|
||||
Progressbar::draw(Mpd.GetElapsedTime(), Mpd.GetTotalTime());
|
||||
else
|
||||
put() << wclrtoeol;
|
||||
wFooter->refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NC::Window &Statusbar::put()
|
||||
{
|
||||
*wFooter << NC::XY(0, Config.statusbar_visibility ? 1 : 0) << wclrtoeol;
|
||||
return *wFooter;
|
||||
}
|
||||
|
||||
void Statusbar::msg(const char *format, ...)
|
||||
{
|
||||
if (Global::ShowMessages && statusbarAllowUnlock)
|
||||
{
|
||||
statusbarLockTime = Global::Timer;
|
||||
statusbarLockDelay = Config.message_delay_time;
|
||||
if (Config.statusbar_visibility)
|
||||
statusbarBlockUpdate = 1;
|
||||
else
|
||||
progressbarBlockUpdate = 1;
|
||||
wFooter->goToXY(0, Config.statusbar_visibility);
|
||||
*wFooter << NC::fmtBoldEnd;
|
||||
va_list list;
|
||||
va_start(list, format);
|
||||
wmove(wFooter->raw(), Config.statusbar_visibility, 0);
|
||||
vw_printw(wFooter->raw(), format, list);
|
||||
wclrtoeol(wFooter->raw());
|
||||
va_end(list);
|
||||
wFooter->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void Statusbar::Helpers::mpd()
|
||||
{
|
||||
Mpd.OrderDataFetching();
|
||||
}
|
||||
|
||||
void Statusbar::Helpers::getString(const std::wstring &)
|
||||
{
|
||||
TraceMpdStatus();
|
||||
}
|
||||
|
||||
void Statusbar::Helpers::ApplyFilterImmediately::operator()(const std::wstring &ws)
|
||||
{
|
||||
using Global::myScreen;
|
||||
// if input queue is not empty, we don't want to update filter since next
|
||||
// character will be taken from queue immediately, trigering this function
|
||||
// again and thus making it inefficient, so let's apply filter only if
|
||||
// "real" user input arrived. however, we want to apply filter if ENTER
|
||||
// is next in queue, so its effects will be seen.
|
||||
if (wFooter->inputQueue().empty() || wFooter->inputQueue().front() == KEY_ENTER)
|
||||
{
|
||||
if (m_ws != ws)
|
||||
{
|
||||
m_ws = ws;
|
||||
m_f->applyFilter(ToString(m_ws));
|
||||
myScreen->RefreshWindow();
|
||||
}
|
||||
TraceMpdStatus();
|
||||
}
|
||||
}
|
||||
90
src/statusbar.h
Normal file
90
src/statusbar.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008-2012 by Andrzej Rybczak *
|
||||
* electricityispower@gmail.com *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _STATUSBAR_H
|
||||
#define _STATUSBAR_H
|
||||
|
||||
#include "gcc.h"
|
||||
#include "interfaces.h"
|
||||
#include "window.h"
|
||||
|
||||
namespace Progressbar {//
|
||||
|
||||
/// locks progressbar (usually used for seeking)
|
||||
void lock();
|
||||
|
||||
/// unlocks progressbar (usually right after seeking is done)
|
||||
void unlock();
|
||||
|
||||
/// @return true if progressbar is unlocked
|
||||
bool isUnlocked();
|
||||
|
||||
/// draws progressbar
|
||||
void draw(unsigned elapsed, unsigned time);
|
||||
|
||||
}
|
||||
|
||||
namespace Statusbar{//
|
||||
|
||||
/// locks statusbar (usually for prompting the user)
|
||||
void lock();
|
||||
|
||||
/// unlocks statusbar (usually after prompting the user)
|
||||
void unlock();
|
||||
|
||||
/// @return true if statusbar is unlocked
|
||||
bool isUnlocked();
|
||||
|
||||
/// tries to clear current message put there using Statusbar::msg if there is any
|
||||
void tryRedraw();
|
||||
|
||||
/// clears statusbar and move cursor to beginning of line
|
||||
/// @return window object that represents statusbar
|
||||
NC::Window &put();
|
||||
|
||||
/// displays message in statusbar for period of time set in configuration file
|
||||
void msg(const char *format, ...) GNUC_PRINTF(1, 2);
|
||||
|
||||
namespace Helpers {//
|
||||
|
||||
/// called when statusbar window detects incoming idle notification
|
||||
void mpd();
|
||||
|
||||
/// called each time user types another character while inside Window::getString
|
||||
void getString(const std::wstring &);
|
||||
|
||||
/// called each time user changes current filter (while being inside Window::getString)
|
||||
struct ApplyFilterImmediately
|
||||
{
|
||||
ApplyFilterImmediately(Filterable *f, const std::wstring &filter)
|
||||
: m_f(f), m_ws(filter) { }
|
||||
|
||||
void operator()(const std::wstring &ws);
|
||||
|
||||
private:
|
||||
Filterable *m_f;
|
||||
std::wstring m_ws;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // _STATUSBAR_H
|
||||
@@ -41,8 +41,9 @@
|
||||
#include "display.h"
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "song_info.h"
|
||||
#include "playlist.h"
|
||||
#include "song_info.h"
|
||||
#include "statusbar.h"
|
||||
#include "utility/comparators.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
@@ -317,7 +318,7 @@ void TagEditor::EnterPressed()
|
||||
Dirs->reset();
|
||||
}
|
||||
else
|
||||
ShowMessage("No subdirectories found");
|
||||
Statusbar::msg("No subdirectories found");
|
||||
}
|
||||
else if (w == FParserDialog)
|
||||
{
|
||||
@@ -384,10 +385,10 @@ void TagEditor::EnterPressed()
|
||||
|
||||
if (pos == 0) // change pattern
|
||||
{
|
||||
LockStatusbar();
|
||||
Statusbar() << "Pattern: ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << "Pattern: ";
|
||||
std::string new_pattern = wFooter->getString(Config.pattern);
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
if (!new_pattern.empty())
|
||||
{
|
||||
Config.pattern = new_pattern;
|
||||
@@ -398,7 +399,7 @@ void TagEditor::EnterPressed()
|
||||
else if (pos == 1 || pos == 4) // preview or proceed
|
||||
{
|
||||
bool success = 1;
|
||||
ShowMessage("Parsing...");
|
||||
Statusbar::msg("Parsing...");
|
||||
FParserPreview->clear();
|
||||
for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
|
||||
{
|
||||
@@ -421,7 +422,7 @@ void TagEditor::EnterPressed()
|
||||
std::string new_file = GenerateFilename(s, "{" + Config.pattern + "}");
|
||||
if (new_file.empty() && !FParserUsePreview)
|
||||
{
|
||||
ShowMessage("File \"%s\" would have an empty name", s.getName().c_str());
|
||||
Statusbar::msg("File \"%s\" would have an empty name", s.getName().c_str());
|
||||
FParserUsePreview = 1;
|
||||
success = 0;
|
||||
}
|
||||
@@ -450,7 +451,7 @@ void TagEditor::EnterPressed()
|
||||
quit = 1;
|
||||
}
|
||||
if (pos != 4 || success)
|
||||
ShowMessage("Operation finished");
|
||||
Statusbar::msg("Operation finished");
|
||||
}
|
||||
else if (pos == 2) // show legend
|
||||
{
|
||||
@@ -507,10 +508,10 @@ void TagEditor::EnterPressed()
|
||||
else
|
||||
(*it)->setTrack(unsignedIntTo<std::string>::apply(i));
|
||||
}
|
||||
ShowMessage("Tracks numbered");
|
||||
Statusbar::msg("Tracks numbered");
|
||||
}
|
||||
else
|
||||
ShowMessage("Aborted");
|
||||
Statusbar::msg("Aborted");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -520,19 +521,19 @@ void TagEditor::EnterPressed()
|
||||
MPD::MutableSong::SetFunction set = SongInfo::Tags[id].Set;
|
||||
if (id > 0 && w == TagTypes)
|
||||
{
|
||||
LockStatusbar();
|
||||
Statusbar() << NC::fmtBold << TagTypes->current().value() << NC::fmtBoldEnd << ": ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << NC::fmtBold << TagTypes->current().value() << NC::fmtBoldEnd << ": ";
|
||||
std::string new_tag = wFooter->getString(Tags->current().value().getTags(get));
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
|
||||
(*it)->setTags(set, new_tag);
|
||||
}
|
||||
else if (w == Tags)
|
||||
{
|
||||
LockStatusbar();
|
||||
Statusbar() << NC::fmtBold << TagTypes->current().value() << NC::fmtBoldEnd << ": ";
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << NC::fmtBold << TagTypes->current().value() << NC::fmtBoldEnd << ": ";
|
||||
std::string new_tag = wFooter->getString(Tags->current().value().getTags(get));
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
if (new_tag != Tags->current().value().getTags(get))
|
||||
Tags->current().value().setTags(set, new_tag);
|
||||
Tags->scroll(NC::wDown);
|
||||
@@ -546,7 +547,7 @@ void TagEditor::EnterPressed()
|
||||
{
|
||||
if (size_t(COLS) < FParserDialogWidth || MainHeight < FParserDialogHeight)
|
||||
{
|
||||
ShowMessage("Screen is too small to display additional windows");
|
||||
Statusbar::msg("Screen is too small to display additional windows");
|
||||
return;
|
||||
}
|
||||
FParserDialog->reset();
|
||||
@@ -559,10 +560,10 @@ void TagEditor::EnterPressed()
|
||||
size_t last_dot = old_name.rfind(".");
|
||||
std::string extension = old_name.substr(last_dot);
|
||||
old_name = old_name.substr(0, last_dot);
|
||||
LockStatusbar();
|
||||
Statusbar() << NC::fmtBold << "New filename: " << NC::fmtBoldEnd;
|
||||
Statusbar::lock();
|
||||
Statusbar::put() << NC::fmtBold << "New filename: " << NC::fmtBoldEnd;
|
||||
std::string new_name = wFooter->getString(old_name);
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
if (!new_name.empty() && new_name != old_name)
|
||||
s.setNewURI(new_name + extension);
|
||||
Tags->scroll(NC::wDown);
|
||||
@@ -570,41 +571,41 @@ void TagEditor::EnterPressed()
|
||||
}
|
||||
else if (id == 16) // capitalize first letters
|
||||
{
|
||||
ShowMessage("Processing...");
|
||||
Statusbar::msg("Processing...");
|
||||
for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
|
||||
CapitalizeFirstLetters(**it);
|
||||
ShowMessage("Done");
|
||||
Statusbar::msg("Done");
|
||||
}
|
||||
else if (id == 17) // lower all letters
|
||||
{
|
||||
ShowMessage("Processing...");
|
||||
Statusbar::msg("Processing...");
|
||||
for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
|
||||
LowerAllLetters(**it);
|
||||
ShowMessage("Done");
|
||||
Statusbar::msg("Done");
|
||||
}
|
||||
else if (id == 19) // reset
|
||||
{
|
||||
Tags->clear();
|
||||
ShowMessage("Changes reset");
|
||||
Statusbar::msg("Changes reset");
|
||||
}
|
||||
else if (id == 20) // save
|
||||
{
|
||||
bool success = 1;
|
||||
ShowMessage("Writing changes...");
|
||||
Statusbar::msg("Writing changes...");
|
||||
for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
|
||||
{
|
||||
ShowMessage("Writing tags in \"%s\"...", (*it)->getName().c_str());
|
||||
Statusbar::msg("Writing tags in \"%s\"...", (*it)->getName().c_str());
|
||||
if (!WriteTags(**it))
|
||||
{
|
||||
const char msg[] = "Error while writing tags in \"%ls\"";
|
||||
ShowMessage(msg, wideShorten(ToWString((*it)->getURI()), COLS-const_strlen(msg)).c_str());
|
||||
Statusbar::msg(msg, wideShorten(ToWString((*it)->getURI()), COLS-const_strlen(msg)).c_str());
|
||||
success = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
ShowMessage("Tags updated");
|
||||
Statusbar::msg("Tags updated");
|
||||
TagTypes->setHighlightColor(Config.main_highlight_color);
|
||||
TagTypes->reset();
|
||||
w->refresh();
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "song_info.h"
|
||||
#include "playlist.h"
|
||||
#include "search_engine.h"
|
||||
#include "statusbar.h"
|
||||
#include "tag_editor.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
@@ -70,7 +71,7 @@ void TinyTagEditor::SwitchTo()
|
||||
|
||||
if (itsEdited.isStream())
|
||||
{
|
||||
ShowMessage("Streams can't be edited");
|
||||
Statusbar::msg("Streams can't be edited");
|
||||
}
|
||||
else if (getTags())
|
||||
{
|
||||
@@ -92,7 +93,7 @@ void TinyTagEditor::SwitchTo()
|
||||
full_path += itsEdited.getURI();
|
||||
|
||||
const char msg[] = "Couldn't read file \"%ls\"";
|
||||
ShowMessage(msg, wideShorten(ToWString(full_path), COLS-const_strlen(msg)).c_str());
|
||||
Statusbar::msg(msg, wideShorten(ToWString(full_path), COLS-const_strlen(msg)).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,11 +105,11 @@ std::wstring TinyTagEditor::Title()
|
||||
void TinyTagEditor::EnterPressed()
|
||||
{
|
||||
size_t option = w->choice();
|
||||
LockStatusbar();
|
||||
Statusbar::lock();
|
||||
if (option < 19) // separator after comment
|
||||
{
|
||||
size_t pos = option-8;
|
||||
Statusbar() << NC::fmtBold << SongInfo::Tags[pos].Name << ": " << NC::fmtBoldEnd;
|
||||
Statusbar::put() << NC::fmtBold << SongInfo::Tags[pos].Name << ": " << NC::fmtBoldEnd;
|
||||
itsEdited.setTags(SongInfo::Tags[pos].Set, Global::wFooter->getString(itsEdited.getTags(SongInfo::Tags[pos].Get)));
|
||||
w->at(option).value().clear();
|
||||
w->at(option).value() << NC::fmtBold << SongInfo::Tags[pos].Name << ':' << NC::fmtBoldEnd << ' ';
|
||||
@@ -116,7 +117,7 @@ void TinyTagEditor::EnterPressed()
|
||||
}
|
||||
else if (option == 20)
|
||||
{
|
||||
Statusbar() << NC::fmtBold << "Filename: " << NC::fmtBoldEnd;
|
||||
Statusbar::put() << NC::fmtBold << "Filename: " << NC::fmtBoldEnd;
|
||||
std::string filename = itsEdited.getNewURI().empty() ? itsEdited.getName() : itsEdited.getNewURI();
|
||||
size_t dot = filename.rfind(".");
|
||||
std::string extension = filename.substr(dot);
|
||||
@@ -126,14 +127,14 @@ void TinyTagEditor::EnterPressed()
|
||||
w->at(option).value().clear();
|
||||
w->at(option).value() << NC::fmtBold << "Filename:" << NC::fmtBoldEnd << ' ' << (itsEdited.getNewURI().empty() ? itsEdited.getName() : itsEdited.getNewURI());
|
||||
}
|
||||
UnlockStatusbar();
|
||||
Statusbar::unlock();
|
||||
|
||||
if (option == 22)
|
||||
{
|
||||
ShowMessage("Updating tags...");
|
||||
Statusbar::msg("Updating tags...");
|
||||
if (TagEditor::WriteTags(itsEdited))
|
||||
{
|
||||
ShowMessage("Tags updated");
|
||||
Statusbar::msg("Tags updated");
|
||||
if (itsEdited.isFromDatabase())
|
||||
Mpd.UpdateDirectory(itsEdited.getDirectory());
|
||||
else
|
||||
@@ -145,7 +146,7 @@ void TinyTagEditor::EnterPressed()
|
||||
}
|
||||
}
|
||||
else
|
||||
ShowMessage("Error while writing tags");
|
||||
Statusbar::msg("Error while writing tags");
|
||||
}
|
||||
if (option > 21)
|
||||
myOldScreen->SwitchTo();
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "global.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
|
||||
using Global::MainStartY;
|
||||
using Global::MainHeight;
|
||||
@@ -157,7 +158,7 @@ void Visualizer::SpacePressed()
|
||||
{
|
||||
# ifdef HAVE_FFTW3_H
|
||||
Config.visualizer_use_wave = !Config.visualizer_use_wave;
|
||||
ShowMessage("Visualization type: %s", Config.visualizer_use_wave ? "Sound wave" : "Frequency spectrum");
|
||||
Statusbar::msg("Visualization type: %s", Config.visualizer_use_wave ? "Sound wave" : "Frequency spectrum");
|
||||
# endif // HAVE_FFTW3_H
|
||||
}
|
||||
|
||||
@@ -225,7 +226,7 @@ void Visualizer::DrawFrequencySpectrum(int16_t *buf, ssize_t samples, size_t y_o
|
||||
void Visualizer::SetFD()
|
||||
{
|
||||
if (itsFifo < 0 && (itsFifo = open(Config.visualizer_fifo_path.c_str(), O_RDONLY | O_NONBLOCK)) < 0)
|
||||
ShowMessage("Couldn't open \"%s\" for reading PCM data: %s", Config.visualizer_fifo_path.c_str(), strerror(errno));
|
||||
Statusbar::msg("Couldn't open \"%s\" for reading PCM data: %s", Config.visualizer_fifo_path.c_str(), strerror(errno));
|
||||
}
|
||||
|
||||
void Visualizer::ResetFD()
|
||||
@@ -244,7 +245,7 @@ void Visualizer::FindOutputID()
|
||||
if (o->name() == Config.visualizer_output_name)
|
||||
itsOutputID = i;
|
||||
if (itsOutputID == -1)
|
||||
ShowMessage("There is no output named \"%s\"", Config.visualizer_output_name.c_str());
|
||||
Statusbar::msg("There is no output named \"%s\"", Config.visualizer_output_name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user