move local_browser variable from settings to Browser class
This commit is contained in:
@@ -148,7 +148,7 @@ void Browser::SpacePressed()
|
||||
|
||||
SongList list;
|
||||
# ifndef WIN32
|
||||
if (Config.local_browser)
|
||||
if (isLocal())
|
||||
{
|
||||
ItemList items;
|
||||
ShowMessage("Scanning \"%s\"...", item.name.c_str());
|
||||
@@ -289,7 +289,7 @@ void Browser::LocateSong(const MPD::Song &s)
|
||||
if (s.GetDirectory().empty())
|
||||
return;
|
||||
|
||||
Config.local_browser = !s.isFromDB();
|
||||
itsBrowseLocally = !s.isFromDB();
|
||||
|
||||
SwitchTo();
|
||||
|
||||
@@ -339,7 +339,7 @@ void Browser::GetDirectory(std::string dir, std::string subdir)
|
||||
|
||||
ItemList list;
|
||||
# ifndef WIN32
|
||||
Config.local_browser ? GetLocalDirectory(list) : Mpd.GetDirectory(dir, list);
|
||||
isLocal() ? GetLocalDirectory(list) : Mpd.GetDirectory(dir, list);
|
||||
# else
|
||||
Mpd.GetDirectory(dir, list);
|
||||
# endif // !WIN32
|
||||
@@ -487,9 +487,9 @@ void Browser::ChangeBrowseMode()
|
||||
if (Mpd.GetHostname()[0] != '/')
|
||||
return;
|
||||
|
||||
Config.local_browser = !Config.local_browser;
|
||||
ShowMessage("Browse mode: %s", Config.local_browser ? "Local filesystem" : "MPD music dir");
|
||||
itsBrowsedDir = Config.local_browser ? home_path : "/";
|
||||
itsBrowseLocally = !itsBrowseLocally;
|
||||
ShowMessage("Browse mode: %s", itsBrowseLocally ? "Local filesystem" : "MPD music dir");
|
||||
itsBrowsedDir = itsBrowseLocally ? home_path : "/";
|
||||
w->Reset();
|
||||
GetDirectory(itsBrowsedDir);
|
||||
RedrawHeader = 1;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
class Browser : public Screen< Menu<MPD::Item> >
|
||||
{
|
||||
public:
|
||||
Browser() : itsScrollBeginning(0), itsBrowsedDir("/") { }
|
||||
Browser() : itsBrowseLocally(0), itsScrollBeginning(0), itsBrowsedDir("/") { }
|
||||
|
||||
virtual void Resize();
|
||||
virtual void SwitchTo();
|
||||
@@ -50,6 +50,7 @@ class Browser : public Screen< Menu<MPD::Item> >
|
||||
|
||||
const std::string &CurrentDir() { return itsBrowsedDir; }
|
||||
|
||||
bool isLocal() { return itsBrowseLocally; }
|
||||
void LocateSong(const MPD::Song &);
|
||||
void GetDirectory(std::string, std::string = "/");
|
||||
# ifndef WIN32
|
||||
@@ -68,6 +69,7 @@ class Browser : public Screen< Menu<MPD::Item> >
|
||||
|
||||
static const char *SupportedExtensions[];
|
||||
|
||||
bool itsBrowseLocally;
|
||||
size_t itsScrollBeginning;
|
||||
std::string itsBrowsedDir;
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@ void SelectedItemsAdder::SwitchTo()
|
||||
if (hasToBeResized)
|
||||
Resize();
|
||||
|
||||
bool playlists_not_active = myScreen == myBrowser && Config.local_browser;
|
||||
bool playlists_not_active = myScreen == myBrowser && myBrowser->isLocal();
|
||||
if (playlists_not_active)
|
||||
ShowMessage("Local items cannot be added to m3u playlist!");
|
||||
|
||||
@@ -159,7 +159,7 @@ void SelectedItemsAdder::EnterPressed()
|
||||
if (pos != w->Size()-1)
|
||||
{
|
||||
// refresh playlist's lists
|
||||
if (!Config.local_browser && myBrowser->Main() && myBrowser->CurrentDir() == "/")
|
||||
if (myBrowser->Main() && !myBrowser->isLocal() && myBrowser->CurrentDir() == "/")
|
||||
myBrowser->GetDirectory("/");
|
||||
if (myPlaylistEditor->Main())
|
||||
myPlaylistEditor->Playlists->Clear(0); // make playlist editor update itself
|
||||
|
||||
@@ -608,7 +608,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Mpd.DeletePlaylist(locale_to_utf_cpy(name));
|
||||
ShowMessage("Playlist \"%s\" deleted!", name.c_str());
|
||||
if (!Config.local_browser && myBrowser->Main())
|
||||
if (myBrowser->Main() && !myBrowser->isLocal() && myBrowser->CurrentDir() == "/")
|
||||
myBrowser->GetDirectory("/");
|
||||
}
|
||||
else
|
||||
@@ -619,7 +619,7 @@ int main(int argc, char *argv[])
|
||||
# ifndef WIN32
|
||||
else if (myScreen == myBrowser && !myBrowser->Main()->Empty() && myBrowser->Main()->Current().type != itPlaylist)
|
||||
{
|
||||
if (!Config.local_browser)
|
||||
if (!myBrowser->isLocal())
|
||||
CHECK_MPD_MUSIC_DIR;
|
||||
|
||||
MPD::Item &item = myBrowser->Main()->Current();
|
||||
@@ -652,7 +652,7 @@ int main(int argc, char *argv[])
|
||||
if (input == 'y')
|
||||
{
|
||||
std::string path;
|
||||
if (!Config.local_browser)
|
||||
if (!myBrowser->isLocal())
|
||||
path = Config.mpd_music_dir;
|
||||
path += item.type == itSong ? item.song->GetFile() : item.name;
|
||||
|
||||
@@ -662,7 +662,7 @@ int main(int argc, char *argv[])
|
||||
if (remove(path.c_str()) == 0)
|
||||
{
|
||||
ShowMessage("\"%s\" has been successfuly deleted!", name.c_str());
|
||||
if (!Config.local_browser)
|
||||
if (!myBrowser->isLocal())
|
||||
Mpd.UpdateDirectory(myBrowser->CurrentDir());
|
||||
else
|
||||
myBrowser->GetDirectory(myBrowser->CurrentDir());
|
||||
@@ -781,8 +781,8 @@ int main(int argc, char *argv[])
|
||||
myPlaylist->EnableHighlighting();
|
||||
}
|
||||
}
|
||||
if (!Config.local_browser
|
||||
&& myBrowser->Main()
|
||||
if (myBrowser->Main()
|
||||
&& !myBrowser->isLocal()
|
||||
&& myBrowser->CurrentDir() == "/"
|
||||
&& !myBrowser->Main()->Empty())
|
||||
myBrowser->GetDirectory(myBrowser->CurrentDir());
|
||||
@@ -1341,7 +1341,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.EditTags))
|
||||
{
|
||||
if (myScreen != myBrowser || !Config.local_browser)
|
||||
if (myScreen != myBrowser || !myBrowser->isLocal())
|
||||
CHECK_MPD_MUSIC_DIR;
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
if (myTinyTagEditor->SetEdited(myScreen->CurrentSong()))
|
||||
@@ -1460,18 +1460,18 @@ int main(int argc, char *argv[])
|
||||
if (!new_dir.empty() && new_dir != old_dir)
|
||||
{
|
||||
std::string full_old_dir;
|
||||
if (!Config.local_browser)
|
||||
if (!myBrowser->isLocal())
|
||||
full_old_dir += Config.mpd_music_dir;
|
||||
full_old_dir += locale_to_utf_cpy(old_dir);
|
||||
std::string full_new_dir;
|
||||
if (!Config.local_browser)
|
||||
if (!myBrowser->isLocal())
|
||||
full_new_dir += Config.mpd_music_dir;
|
||||
full_new_dir += locale_to_utf_cpy(new_dir);
|
||||
int rename_result = rename(full_old_dir.c_str(), full_new_dir.c_str());
|
||||
if (rename_result == 0)
|
||||
{
|
||||
ShowMessage("\"%s\" renamed to \"%s\"", old_dir.c_str(), new_dir.c_str());
|
||||
if (!Config.local_browser)
|
||||
if (!myBrowser->isLocal())
|
||||
Mpd.UpdateDirectory(locale_to_utf_cpy(FindSharedDir(old_dir, new_dir)));
|
||||
myBrowser->GetDirectory(myBrowser->CurrentDir());
|
||||
}
|
||||
@@ -1490,7 +1490,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Mpd.Rename(locale_to_utf_cpy(old_name), locale_to_utf_cpy(new_name));
|
||||
ShowMessage("Playlist \"%s\" renamed to \"%s\"", old_name.c_str(), new_name.c_str());
|
||||
if (!Config.local_browser && myBrowser->Main())
|
||||
if (myBrowser->Main() && !myBrowser->isLocal())
|
||||
myBrowser->GetDirectory("/");
|
||||
if (myPlaylistEditor->Main())
|
||||
myPlaylistEditor->Playlists->Clear(0);
|
||||
|
||||
@@ -296,7 +296,6 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
conf.albums_in_tag_editor = false;
|
||||
conf.incremental_seeking = true;
|
||||
conf.now_playing_lyrics = false;
|
||||
conf.local_browser = false;
|
||||
conf.local_browser_show_hidden_files = false;
|
||||
conf.search_in_db = true;
|
||||
conf.display_screens_numbers_on_start = true;
|
||||
|
||||
@@ -189,7 +189,6 @@ struct ncmpcpp_config
|
||||
bool albums_in_tag_editor;
|
||||
bool incremental_seeking;
|
||||
bool now_playing_lyrics;
|
||||
bool local_browser;
|
||||
bool local_browser_show_hidden_files;
|
||||
bool search_in_db;
|
||||
bool display_screens_numbers_on_start;
|
||||
|
||||
Reference in New Issue
Block a user