settings: add startup_slave_screen option
This commit is contained in:
@@ -106,12 +106,7 @@ void Browser::resize()
|
||||
void Browser::switchTo()
|
||||
{
|
||||
SwitchTo::execute(this);
|
||||
|
||||
if (w.empty())
|
||||
getDirectory(m_current_directory);
|
||||
else
|
||||
markSongsInPlaylist(proxySongList());
|
||||
|
||||
markSongsInPlaylist(proxySongList());
|
||||
drawHeader();
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ bool configure(int argc, char **argv)
|
||||
("config,c", po::value<std::string>(&config_path)->default_value("~/.ncmpcpp/config"), "specify configuration file")
|
||||
("bindings,b", po::value<std::string>(&bindings_path)->default_value("~/.ncmpcpp/bindings"), "specify bindings file")
|
||||
("screen,s", po::value<std::string>(), "specify initial screen")
|
||||
("slave-screen,S", po::value<std::string>(), "specify initial slave screen")
|
||||
("help,?", "show help message")
|
||||
("version,v", "display version information")
|
||||
;
|
||||
@@ -176,6 +177,18 @@ bool configure(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// custom startup slave screen
|
||||
if (vm.count("slave-screen"))
|
||||
{
|
||||
auto screen = vm["slave-screen"].as<std::string>();
|
||||
Config.startup_slave_screen_type = stringtoStartupScreenType(screen);
|
||||
if (Config.startup_slave_screen_type == ScreenType::Unknown)
|
||||
{
|
||||
std::cerr << "Unknown slave screen: " << screen << "\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
|
||||
@@ -130,6 +130,15 @@ int main(int argc, char **argv)
|
||||
|
||||
// initialize playlist
|
||||
myPlaylist->switchTo();
|
||||
|
||||
// go to startup screen
|
||||
if (Config.startup_screen_type != myScreen->type())
|
||||
toScreen(Config.startup_screen_type)->switchTo();
|
||||
|
||||
// lock current screen and go to the slave one
|
||||
if (Config.startup_slave_screen_type != myScreen->type())
|
||||
if (myScreen->lock())
|
||||
toScreen(Config.startup_slave_screen_type)->switchTo();
|
||||
|
||||
// local variables
|
||||
bool key_pressed = false;
|
||||
|
||||
@@ -517,6 +517,12 @@ bool Configuration::read(const std::string &config_path)
|
||||
throw std::runtime_error("unknown screen: " + v);
|
||||
}, defaults_to(startup_screen_type, ScreenType::Playlist)
|
||||
));
|
||||
p.add("startup_slave_screen", option_parser::worker([this](std::string v) {
|
||||
startup_slave_screen_type = stringtoStartupScreenType(v);
|
||||
if (startup_slave_screen_type == ScreenType::Unknown)
|
||||
throw std::runtime_error("unknown slave screen: " + v);
|
||||
}, defaults_to(startup_slave_screen_type, ScreenType::Playlist)
|
||||
));
|
||||
p.add("locked_screen_width_part", assign_default<double>(
|
||||
locked_screen_width_part, 50.0, [](double v) {
|
||||
return v / 100;
|
||||
|
||||
@@ -187,6 +187,7 @@ struct Configuration
|
||||
size_t now_playing_suffix_length;
|
||||
|
||||
ScreenType startup_screen_type;
|
||||
ScreenType startup_slave_screen_type;
|
||||
std::list<ScreenType> screen_sequence;
|
||||
|
||||
SortMode browser_sort_mode;
|
||||
|
||||
@@ -121,7 +121,11 @@ void initialize_status()
|
||||
{
|
||||
int curr_pos = Status::State::currentSongPosition();
|
||||
if (curr_pos >= 0)
|
||||
{
|
||||
myPlaylist->main().highlight(curr_pos);
|
||||
if (isVisible(myPlaylist))
|
||||
myPlaylist->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
// Set TCP_NODELAY on the tcp socket as we are using write-write-read pattern
|
||||
@@ -130,11 +134,6 @@ void initialize_status()
|
||||
int flag = 1;
|
||||
setsockopt(Mpd.GetFD(), IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag));
|
||||
|
||||
// go to startup screen
|
||||
if (Config.startup_screen_type != myScreen->type())
|
||||
toScreen(Config.startup_screen_type)->switchTo();
|
||||
myScreen->refresh();
|
||||
|
||||
myBrowser->fetchSupportedExtensions();
|
||||
# ifdef ENABLE_OUTPUTS
|
||||
myOutputs->FetchList();
|
||||
|
||||
Reference in New Issue
Block a user