diff options
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | src/browser.cpp | 4 | ||||
-rw-r--r-- | src/browser.h | 6 | ||||
-rw-r--r-- | src/clock.cpp | 4 | ||||
-rw-r--r-- | src/clock.h | 4 | ||||
-rw-r--r-- | src/help.cpp | 4 | ||||
-rw-r--r-- | src/help.h | 4 | ||||
-rw-r--r-- | src/info.cpp | 7 | ||||
-rw-r--r-- | src/info.h | 4 | ||||
-rw-r--r-- | src/lyrics.cpp | 4 | ||||
-rw-r--r-- | src/lyrics.h | 4 | ||||
-rw-r--r-- | src/media_library.cpp | 4 | ||||
-rw-r--r-- | src/media_library.h | 4 | ||||
-rw-r--r-- | src/mpdpp.cpp | 2 | ||||
-rw-r--r-- | src/ncmpcpp.cpp | 24 | ||||
-rw-r--r-- | src/outputs.cpp | 4 | ||||
-rw-r--r-- | src/outputs.h | 4 | ||||
-rw-r--r-- | src/playlist.cpp | 5 | ||||
-rw-r--r-- | src/playlist.h | 4 | ||||
-rw-r--r-- | src/playlist_editor.cpp | 4 | ||||
-rw-r--r-- | src/playlist_editor.h | 6 | ||||
-rw-r--r-- | src/screen.h | 8 | ||||
-rw-r--r-- | src/search_engine.cpp | 4 | ||||
-rw-r--r-- | src/search_engine.h | 4 | ||||
-rw-r--r-- | src/tag_editor.cpp | 8 | ||||
-rw-r--r-- | src/tag_editor.h | 8 |
26 files changed, 99 insertions, 41 deletions
diff --git a/configure.in b/configure.in index ca4ddc8a..9807a1b0 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,7 @@ AC_INIT(configure.in) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(ncmpcpp, 0.3.5) +AM_INIT_AUTOMAKE(ncmpcpp, 0.3.6_pre) AC_PREREQ(2.59) diff --git a/src/browser.cpp b/src/browser.cpp index 49565e7d..34d8e0a0 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -60,6 +60,7 @@ void Browser::Init() w->SetSelectSuffix(&Config.selected_item_suffix); w->SetItemDisplayer(Display::Items); w->SetGetStringFunction(ItemToString); + isInitialized = 1; } void Browser::Resize() @@ -73,6 +74,9 @@ void Browser::SwitchTo() if (myScreen == this) return; + if (!isInitialized) + Init(); + if (hasToBeResized) Resize(); diff --git a/src/browser.h b/src/browser.h index 1f938770..06f8b853 100644 --- a/src/browser.h +++ b/src/browser.h @@ -29,7 +29,6 @@ class Browser : public Screen< Menu<MPD::Item> > public: Browser() : itsScrollBeginning(0), itsBrowsedDir("/") { } - virtual void Init(); virtual void Resize(); virtual void SwitchTo(); @@ -57,7 +56,10 @@ class Browser : public Screen< Menu<MPD::Item> > void ClearDirectory(const std::string &) const; void ChangeBrowseMode(); void UpdateItemList(); - + + protected: + virtual void Init(); + private: static bool hasSupportedExtension(const std::string &); static std::string ItemToString(const MPD::Item &, void *); diff --git a/src/clock.cpp b/src/clock.cpp index b7913a04..ed68685a 100644 --- a/src/clock.cpp +++ b/src/clock.cpp @@ -53,6 +53,7 @@ void Clock::Init() w = new Window((COLS-Width)/2, (LINES-Height)/2, Width, Height-1, "", Config.main_color, Border(Config.main_color)); w->SetTimeout(ncmpcpp_window_timeout); + isInitialized = 1; } void Clock::Resize() @@ -80,6 +81,9 @@ void Clock::SwitchTo() if (myScreen == this) return; + if (!isInitialized) + Init(); + if (hasToBeResized) Resize(); diff --git a/src/clock.h b/src/clock.h index 30305961..85cd6a7d 100644 --- a/src/clock.h +++ b/src/clock.h @@ -33,7 +33,6 @@ class Clock : public Screen<Window> { public: - virtual void Init(); virtual void Resize(); virtual void SwitchTo(); @@ -50,6 +49,9 @@ class Clock : public Screen<Window> virtual List *GetList() { return 0; } + protected: + virtual void Init(); + private: static void Prepare(); static void Set(int, int); diff --git a/src/help.cpp b/src/help.cpp index 9d02374c..ee292d5a 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -35,6 +35,7 @@ void Help::Init() w->SetTimeout(ncmpcpp_window_timeout); GetKeybindings(); w->Flush(); + isInitialized = 1; } void Help::Resize() @@ -48,6 +49,9 @@ void Help::SwitchTo() if (myScreen == this) return; + if (!isInitialized) + Init(); + if (hasToBeResized) Resize(); @@ -27,7 +27,6 @@ class Help : public Screen<Scrollpad> { public: - virtual void Init(); virtual void Resize(); virtual void SwitchTo(); @@ -40,6 +39,9 @@ class Help : public Screen<Scrollpad> virtual List *GetList() { return 0; } + protected: + virtual void Init(); + private: std::string DisplayKeys(int *, int = 2); void GetKeybindings(); diff --git a/src/info.cpp b/src/info.cpp index ee14c9d7..05e5250a 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -61,6 +61,7 @@ void Info::Init() { w = new Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone); w->SetTimeout(ncmpcpp_window_timeout); + isInitialized = 1; } void Info::Resize() @@ -96,6 +97,9 @@ void Info::GetSong() } else { + if (!isInitialized) + Init(); + MPD::Song *s = myScreen->CurrentSong(); if (!s) @@ -125,6 +129,9 @@ void Info::GetArtist() } else { + if (!isInitialized) + Init(); + # ifdef HAVE_PTHREAD_H if (Downloader && !ArtistReady) { @@ -28,7 +28,6 @@ class Info : public Screen<Scrollpad> { public: - virtual void Init(); virtual void SwitchTo() { } virtual void Resize(); @@ -50,6 +49,9 @@ class Info : public Screen<Scrollpad> void GetArtist(); # endif // HAVE_CURL_CURL_H + protected: + virtual void Init(); + private: std::string itsArtist; std::string itsTitle; diff --git a/src/lyrics.cpp b/src/lyrics.cpp index 54cd67b6..fcf128ca 100644 --- a/src/lyrics.cpp +++ b/src/lyrics.cpp @@ -71,6 +71,7 @@ void Lyrics::Init() { w = new Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone); w->SetTimeout(ncmpcpp_window_timeout); + isInitialized = 1; } void Lyrics::Resize() @@ -104,6 +105,9 @@ void Lyrics::SwitchTo() } else { + if (!isInitialized) + Init(); + # if defined(HAVE_CURL_CURL_H) && defined(HAVE_PTHREAD_H) if (Downloader && !Ready) { diff --git a/src/lyrics.h b/src/lyrics.h index 58cba3b0..781432a7 100644 --- a/src/lyrics.h +++ b/src/lyrics.h @@ -43,7 +43,6 @@ class Lyrics : public Screen<Scrollpad> Lyrics() : itsScrollBegin(0) { } ~Lyrics() { } - virtual void Init(); virtual void Resize(); virtual void SwitchTo(); @@ -66,6 +65,9 @@ class Lyrics : public Screen<Scrollpad> static const char *GetPluginName(int offset); # endif // HAVE_CURL_CURL_H + protected: + virtual void Init(); + private: std::string itsFilenamePath; diff --git a/src/media_library.cpp b/src/media_library.cpp index 87542bd0..b5a0e876 100644 --- a/src/media_library.cpp +++ b/src/media_library.cpp @@ -75,6 +75,7 @@ void MediaLibrary::Init() Songs->SetGetStringFunction(SongToString); w = Artists; + isInitialized = 1; } void MediaLibrary::Resize() @@ -141,6 +142,9 @@ void MediaLibrary::SwitchTo() Albums->SetTitle("Albums"); } + if (!isInitialized) + Init(); + if (hasToBeResized) Resize(); diff --git a/src/media_library.h b/src/media_library.h index 7546e753..75f1d961 100644 --- a/src/media_library.h +++ b/src/media_library.h @@ -37,7 +37,6 @@ class MediaLibrary : public Screen<Window> }; public: - virtual void Init(); virtual void SwitchTo(); virtual void Resize(); @@ -68,6 +67,9 @@ class MediaLibrary : public Screen<Window> Menu< std::pair<std::string, SearchConstraints> > *Albums; Menu<MPD::Song> *Songs; + protected: + virtual void Init(); + private: void AddToPlaylist(bool); diff --git a/src/mpdpp.cpp b/src/mpdpp.cpp index 6301f2ba..53f09058 100644 --- a/src/mpdpp.cpp +++ b/src/mpdpp.cpp @@ -160,7 +160,7 @@ void Connection::UpdateStatus() { itsChanges.Playlist = 1; itsChanges.SongID = 1; - itsChanges.Database = 1; + itsChanges.Database = 0; itsChanges.DBUpdating = 1; itsChanges.Volume = 1; itsChanges.ElapsedTime = 1; diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index e746bcd9..03259b44 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -133,27 +133,6 @@ int main(int argc, char *argv[]) if (!Config.statusbar_visibility) MainHeight++; - myPlaylist->Init(); - myBrowser->Init(); - mySearcher->Init(); - myLibrary->Init(); - myPlaylistEditor->Init(); - -# ifdef HAVE_TAGLIB_H - myTinyTagEditor->Init(); - myTagEditor->Init(); -# endif // HAVE_TAGLIB_H -# ifdef ENABLE_OUTPUTS - myOutputs->Init(); -# endif // ENABLE_OUTPUTS -# ifdef ENABLE_CLOCK - myClock->Init(); -# endif // ENABLE_CLOCK - - myHelp->Init(); - myInfo->Init(); - myLyrics->Init(); - if (Config.header_visibility) { wHeader = new Window(0, 0, COLS, 1, "", Config.header_color, brNone); @@ -169,8 +148,7 @@ int main(int argc, char *argv[]) wFooter->CreateHistory(); *wFooter << fmtBold; // bold by default - myScreen = myPlaylist; - + myPlaylist->SwitchTo(); myPlaylist->UpdateTimer(); Mpd->SetStatusUpdater(NcmpcppStatusChanged, NULL); diff --git a/src/outputs.cpp b/src/outputs.cpp index dd8e2daa..902cac47 100644 --- a/src/outputs.cpp +++ b/src/outputs.cpp @@ -38,6 +38,7 @@ void Outputs::Init() w->SetItemDisplayer(Display::Pairs); FetchList(); + isInitialized = 1; } void Outputs::SwitchTo() @@ -45,6 +46,9 @@ void Outputs::SwitchTo() if (myScreen == this) return; + if (!isInitialized) + Init(); + if (hasToBeResized) Resize(); diff --git a/src/outputs.h b/src/outputs.h index eaf50b5f..046c2cfd 100644 --- a/src/outputs.h +++ b/src/outputs.h @@ -34,7 +34,6 @@ class Outputs : public Screen< Menu<MPD::Output> > { public: - virtual void Init(); virtual void SwitchTo(); virtual void Resize(); @@ -49,6 +48,9 @@ class Outputs : public Screen< Menu<MPD::Output> > virtual List *GetList() { return w; } void FetchList(); + + protected: + virtual void Init(); }; extern Outputs *myOutputs; diff --git a/src/playlist.cpp b/src/playlist.cpp index f191fbb9..20366181 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -80,6 +80,8 @@ void Playlist::Init() SortDialog->AddOption(std::make_pair("Sort", static_cast<MPD::Song::GetFunction>(0))); SortDialog->AddOption(std::make_pair("Reverse", static_cast<MPD::Song::GetFunction>(0))); SortDialog->AddOption(std::make_pair("Cancel", static_cast<MPD::Song::GetFunction>(0))); + + isInitialized = 1; } void Playlist::SwitchTo() @@ -87,6 +89,9 @@ void Playlist::SwitchTo() if (myScreen == this) return; + if (!isInitialized) + Init(); + itsScrollBegin = 0; if (hasToBeResized) diff --git a/src/playlist.h b/src/playlist.h index ef75de32..05654794 100644 --- a/src/playlist.h +++ b/src/playlist.h @@ -33,7 +33,6 @@ class Playlist : public Screen< Menu<MPD::Song> > Playlist() : NowPlaying(-1), OldPlaying(-1), itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0) { } ~Playlist() { } - virtual void Init(); virtual void SwitchTo(); virtual void Resize(); @@ -76,6 +75,9 @@ class Playlist : public Screen< Menu<MPD::Song> > static bool BlockUpdate; static bool BlockRefreshing; + protected: + virtual void Init(); + private: std::string TotalLength(); diff --git a/src/playlist_editor.cpp b/src/playlist_editor.cpp index bb7e4bf3..4f231dfd 100644 --- a/src/playlist_editor.cpp +++ b/src/playlist_editor.cpp @@ -64,6 +64,7 @@ void PlaylistEditor::Init() Content->SetGetStringFunctionUserData(&Config.song_list_format); w = Playlists; + isInitialized = 1; } void PlaylistEditor::Resize() @@ -97,6 +98,9 @@ void PlaylistEditor::SwitchTo() if (myScreen == this) return; + if (!isInitialized) + Init(); + if (hasToBeResized) Resize(); diff --git a/src/playlist_editor.h b/src/playlist_editor.h index dc399397..d2ef553b 100644 --- a/src/playlist_editor.h +++ b/src/playlist_editor.h @@ -26,7 +26,6 @@ class PlaylistEditor : public Screen<Window> { public: - virtual void Init(); virtual void SwitchTo(); virtual void Resize(); @@ -54,7 +53,10 @@ class PlaylistEditor : public Screen<Window> Menu<std::string> *Playlists; Menu<MPD::Song> *Content; - + + protected: + virtual void Init(); + private: void AddToPlaylist(bool); diff --git a/src/screen.h b/src/screen.h index f7a79041..902f572a 100644 --- a/src/screen.h +++ b/src/screen.h @@ -30,12 +30,11 @@ class BasicScreen { public: - BasicScreen() : hasToBeResized(0) { } + BasicScreen() : hasToBeResized(0), isInitialized(0) { } virtual ~BasicScreen() { } virtual void *ActiveWindow() = 0; - virtual void Init() = 0; virtual void SwitchTo() = 0; virtual void Resize() = 0; @@ -62,6 +61,11 @@ class BasicScreen virtual List *GetList() = 0; bool hasToBeResized; + + protected: + virtual void Init() = 0; + + bool isInitialized; }; template <typename WindowType> class Screen : public BasicScreen diff --git a/src/search_engine.cpp b/src/search_engine.cpp index a413f3f8..ed41a117 100644 --- a/src/search_engine.cpp +++ b/src/search_engine.cpp @@ -52,6 +52,7 @@ void SearchEngine::Init() w->SetSelectPrefix(&Config.selected_item_prefix); w->SetSelectSuffix(&Config.selected_item_suffix); w->SetGetStringFunction(SearchEngineOptionToString); + isInitialized = 1; } void SearchEngine::Resize() @@ -65,6 +66,9 @@ void SearchEngine::SwitchTo() if (myScreen == this) return; + if (!isInitialized) + Init(); + if (hasToBeResized) Resize(); diff --git a/src/search_engine.h b/src/search_engine.h index 1d38e6f5..95adc466 100644 --- a/src/search_engine.h +++ b/src/search_engine.h @@ -40,7 +40,6 @@ class SearchEngine : public Screen< Menu< std::pair<Buffer *, MPD::Song *> > > }; public: - virtual void Init(); virtual void Resize(); virtual void SwitchTo(); @@ -69,6 +68,9 @@ class SearchEngine : public Screen< Menu< std::pair<Buffer *, MPD::Song *> > > static const char *NormalMode; static const char *StrictMode; + protected: + virtual void Init(); + private: void Prepare(); void Search(); diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp index 56fc1bf4..2bfe6880 100644 --- a/src/tag_editor.cpp +++ b/src/tag_editor.cpp @@ -52,6 +52,7 @@ void TinyTagEditor::Init() w->SetTimeout(ncmpcpp_window_timeout); w->CyclicScrolling(Config.use_cyclic_scrolling); w->SetItemDisplayer(Display::Generic); + isInitialized = 1; } void TinyTagEditor::Resize() @@ -258,6 +259,9 @@ bool TinyTagEditor::GetTags() ext = ext.substr(ext.rfind(".")+1); ToLower(ext); + if (!isInitialized) + Init(); + w->Clear(); w->Reset(); @@ -353,6 +357,7 @@ void TagEditor::Init() Tags->SetGetStringFunctionUserData(TagTypes); w = LeftColumn; + isInitialized = 1; } void TagEditor::Resize() @@ -383,6 +388,9 @@ void TagEditor::SwitchTo() if (myScreen == this) return; + if (!isInitialized) + Init(); + if (hasToBeResized) Resize(); diff --git a/src/tag_editor.h b/src/tag_editor.h index 2ee2f001..396529fa 100644 --- a/src/tag_editor.h +++ b/src/tag_editor.h @@ -36,7 +36,6 @@ class TinyTagEditor : public Screen< Menu<Buffer> > { public: - virtual void Init(); virtual void Resize(); virtual void SwitchTo(); @@ -52,6 +51,9 @@ class TinyTagEditor : public Screen< Menu<Buffer> > bool SetEdited(MPD::Song *); + protected: + virtual void Init(); + private: bool GetTags(); MPD::Song itsEdited; @@ -64,7 +66,6 @@ class TagEditor : public Screen<Window> public: TagEditor() : itsBrowsedDir("/") { } - virtual void Init(); virtual void Resize(); virtual void SwitchTo(); @@ -102,6 +103,9 @@ class TagEditor : public Screen<Window> static void ReadTags(mpd_Song *); static bool WriteTags(MPD::Song &); + protected: + virtual void Init(); + private: static std::string CapitalizeFirstLetters(const std::string &); static void CapitalizeFirstLetters(MPD::Song &); |