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