settings: add startup_slave_screen option

This commit is contained in:
brezerk
2014-11-06 20:13:46 +01:00
committed by Andrzej Rybczak
parent a4e9523f63
commit cc747c0f99
10 changed files with 49 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
Alexander Lopatin <sbar.geek@gmail.com>
Alexey Malakhov <brezerk@gmail.com>
Alexey Semenko <igogo.dev@gmail.com>
Andrzej Rybczak <electricityispower@gmail.com>
Arnaud Guignard <aguignard@gmail.com>

1
NEWS
View File

@@ -5,6 +5,7 @@ ncmpcpp-0.7 (????-??-??)
* It is now possible to abort the current action using Ctrl-C or Ctrl-G in prompt mode. As a result, empty value is no longer a special value that aborts most of the actions.
* Directories and playlists in browser can now be sorted by modification time.
* ~ is now expanded to home directory in mpd_host configuration variable.
* It is now possible to define startup slave screen using -S/--slave-screen command line option or startup_slave_screen configuration variable.
ncmpcpp-0.6.1 (2014-11-06)

View File

@@ -400,12 +400,18 @@
#screen_switcher_mode = playlist, browser
#
##
## Note: You can define startup screen for ncmpcpp
## Note: You can define startup screen
## by choosing screen from the list above.
##
#startup_screen = playlist
#
##
## Note: You can define startup slave screen
## by choosing screen from the list above.
##
#startup_slave_screen = playlist
#
##
## Default width of locked screen (in %).
## Acceptable values are from 20 to 80.
##

View File

@@ -21,6 +21,9 @@ Use alternative configuration file
.B \-s, \-\-screen <name>
Specify the startup screen (<name> may be: help, playlist, browser, search_engine, media_library, playlist_editor, tag_editor, outputs, visualizer, clock)
.TP
.B \-S, \-\-slave-screen <name>
Specify the startup slave screen (<name> may be: help, playlist, browser, search_engine, media_library, playlist_editor, tag_editor, outputs, visualizer, clock)
.TP
.B \-?, \-\-help
Display help.
.TP
@@ -268,6 +271,9 @@ If set to "previous", key_screen_switcher will switch between current and last u
.B startup_screen = SCREEN_NAME
Screen that has to be displayed at start (playlist by default).
.TP
.B startup_slave_screen = SCREEN_NAME
Slave screen that has to be displayed at start (playlist by default).
.TP
.B locked_screen_width_part = 20-80
If you want to lock a screen, ncmpcpp asks for % of locked screen's width to be reserved before that and provides a default value, which is the one you can set here.
.TP

View File

@@ -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();
}

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();