new feature: customizable startup screen

This commit is contained in:
Andrzej Rybczak
2010-02-13 11:55:59 +01:00
parent b01801ea22
commit ad74cfea2e
5 changed files with 22 additions and 1 deletions

View File

@@ -292,6 +292,12 @@
## ##
#screen_switcher_mode = "sequence: 2 -> 3" #screen_switcher_mode = "sequence: 2 -> 3"
# #
##
## Note: You can define startup screen for ncmpcpp
## by choosing screen number from the list above.
##
#startup_screen = "2"
#
#jump_to_now_playing_song_at_start = "yes" #jump_to_now_playing_song_at_start = "yes"
# #
#ask_before_clearing_main_playlist = "no" #ask_before_clearing_main_playlist = "no"

View File

@@ -225,6 +225,9 @@ If enabled, screens' names and their keybindings will be shown in header window
.B screen_switcher_previous = SWITCHER_MODE .B screen_switcher_previous = SWITCHER_MODE
If set to "previous", key_screen_switcher will switch between current and last used screen. If set to "sequence: user_defined_sequence", it will switch between given sequence of screens. Syntax clarification can be found in example config file. If set to "previous", key_screen_switcher will switch between current and last used screen. If set to "sequence: user_defined_sequence", it will switch between given sequence of screens. Syntax clarification can be found in example config file.
.TP .TP
.B startup_screen = SCREEN_NUMBER
Screen that has to be displayed at start (playlist by default).
.TP
.B jump_to_now_playing_song_at_start = yes/no .B jump_to_now_playing_song_at_start = yes/no
If enabled, ncmpcpp will jump at start to now playing song if mpd is playing or paused. If enabled, ncmpcpp will jump at start to now playing song if mpd is playing or paused.
.TP .TP

View File

@@ -287,6 +287,10 @@ int main(int argc, char *argv[])
myPlaylist->SwitchTo(); myPlaylist->SwitchTo();
myPlaylist->UpdateTimer(); myPlaylist->UpdateTimer();
// go to startup screen
if (Config.startup_screen != myScreen)
Config.startup_screen->SwitchTo();
Mpd.SetStatusUpdater(NcmpcppStatusChanged, 0); Mpd.SetStatusUpdater(NcmpcppStatusChanged, 0);
Mpd.SetErrorHandler(NcmpcppErrorCallback, 0); Mpd.SetErrorHandler(NcmpcppErrorCallback, 0);
@@ -311,6 +315,7 @@ int main(int argc, char *argv[])
if (Config.mouse_support) if (Config.mouse_support)
mousemask(ALL_MOUSE_EVENTS, 0); mousemask(ALL_MOUSE_EVENTS, 0);
Mpd.OrderDataFetching();
if (Config.jump_to_now_playing_song_at_start) if (Config.jump_to_now_playing_song_at_start)
{ {
TraceMpdStatus(); TraceMpdStatus();

View File

@@ -393,7 +393,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
if (conf.system_encoding == "UTF-8") // mpd uses utf-8 by default so no need to convert if (conf.system_encoding == "UTF-8") // mpd uses utf-8 by default so no need to convert
conf.system_encoding.clear(); conf.system_encoding.clear();
# endif // HAVE_LANGINFO_H # endif // HAVE_LANGINFO_H
conf.startup_screen = myPlaylist;
// default screens sequence // default screens sequence
conf.screens_seq.push_back(myPlaylist); conf.screens_seq.push_back(myPlaylist);
conf.screens_seq.push_back(myBrowser); conf.screens_seq.push_back(myBrowser);
@@ -848,6 +848,12 @@ void ReadConfiguration(ncmpcpp_config &conf)
conf.screens_seq.unique(); conf.screens_seq.unique();
} }
} }
else if (cl.find("startup_screen") != std::string::npos)
{
conf.startup_screen = IntoScreen(atoi(v.c_str()));
if (!conf.startup_screen)
conf.startup_screen = myPlaylist;
}
else if (cl.find("autocenter_mode") != std::string::npos) else if (cl.find("autocenter_mode") != std::string::npos)
{ {
conf.autocenter_mode = v == "yes"; conf.autocenter_mode = v == "yes";

View File

@@ -238,6 +238,7 @@ struct ncmpcpp_config
size_t selected_item_suffix_length; size_t selected_item_suffix_length;
size_t now_playing_suffix_length; size_t now_playing_suffix_length;
BasicScreen *startup_screen;
std::list<BasicScreen *> screens_seq; std::list<BasicScreen *> screens_seq;
}; };