From ad74cfea2ef073f78a933e110b31fa55e374f9af Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sat, 13 Feb 2010 11:55:59 +0100 Subject: [PATCH] new feature: customizable startup screen --- doc/config | 6 ++++++ doc/ncmpcpp.1 | 3 +++ src/ncmpcpp.cpp | 5 +++++ src/settings.cpp | 8 +++++++- src/settings.h | 1 + 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/doc/config b/doc/config index fd617d6b..28a1c45b 100644 --- a/doc/config +++ b/doc/config @@ -292,6 +292,12 @@ ## #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" # #ask_before_clearing_main_playlist = "no" diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1 index 3420b1a8..ec966134 100644 --- a/doc/ncmpcpp.1 +++ b/doc/ncmpcpp.1 @@ -225,6 +225,9 @@ If enabled, screens' names and their keybindings will be shown in header window .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. .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 If enabled, ncmpcpp will jump at start to now playing song if mpd is playing or paused. .TP diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index deca3a1a..741908cb 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -287,6 +287,10 @@ int main(int argc, char *argv[]) myPlaylist->SwitchTo(); myPlaylist->UpdateTimer(); + // go to startup screen + if (Config.startup_screen != myScreen) + Config.startup_screen->SwitchTo(); + Mpd.SetStatusUpdater(NcmpcppStatusChanged, 0); Mpd.SetErrorHandler(NcmpcppErrorCallback, 0); @@ -311,6 +315,7 @@ int main(int argc, char *argv[]) if (Config.mouse_support) mousemask(ALL_MOUSE_EVENTS, 0); + Mpd.OrderDataFetching(); if (Config.jump_to_now_playing_song_at_start) { TraceMpdStatus(); diff --git a/src/settings.cpp b/src/settings.cpp index d1d5008b..ca9a53c4 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -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 conf.system_encoding.clear(); # endif // HAVE_LANGINFO_H - + conf.startup_screen = myPlaylist; // default screens sequence conf.screens_seq.push_back(myPlaylist); conf.screens_seq.push_back(myBrowser); @@ -848,6 +848,12 @@ void ReadConfiguration(ncmpcpp_config &conf) 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) { conf.autocenter_mode = v == "yes"; diff --git a/src/settings.h b/src/settings.h index 8a3964b7..6a42d5b5 100644 --- a/src/settings.h +++ b/src/settings.h @@ -238,6 +238,7 @@ struct ncmpcpp_config size_t selected_item_suffix_length; size_t now_playing_suffix_length; + BasicScreen *startup_screen; std::list screens_seq; };