diff --git a/src/Makefile.am b/src/Makefile.am index 35e601c8..2efb5a32 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,6 +30,7 @@ ncmpcpp_SOURCES = \ playlist_editor.cpp \ regexes.cpp \ screen.cpp \ + screen_type.cpp \ scrollpad.cpp \ search_engine.cpp \ sel_items_adder.cpp \ @@ -88,6 +89,7 @@ noinst_HEADERS = \ regexes.h \ screen.h \ screen_switcher.h \ + screen_type.h \ scrollpad.h \ search_engine.h \ sel_items_adder.h \ diff --git a/src/browser.h b/src/browser.h index 31a0ad50..91cea973 100644 --- a/src/browser.h +++ b/src/browser.h @@ -34,6 +34,7 @@ struct Browser: Screen>, Filterable, HasSongs, Searchable, T virtual void switchTo() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::Browser; } virtual void update() OVERRIDE { } diff --git a/src/clock.h b/src/clock.h index dd835806..d749eddd 100644 --- a/src/clock.h +++ b/src/clock.h @@ -37,6 +37,7 @@ struct Clock: Screen, Tabbable virtual void switchTo() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::Clock; } virtual void update() OVERRIDE; virtual void scroll(NC::Where) OVERRIDE { } diff --git a/src/help.h b/src/help.h index 543c9ee0..8383de7c 100644 --- a/src/help.h +++ b/src/help.h @@ -33,6 +33,7 @@ struct Help: Screen, Tabbable virtual void switchTo() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::Help; } virtual void update() OVERRIDE { } diff --git a/src/lastfm.h b/src/lastfm.h index 1f440d0a..c44ea9f4 100644 --- a/src/lastfm.h +++ b/src/lastfm.h @@ -40,6 +40,7 @@ struct Lastfm: Screen, Tabbable virtual void resize() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::Lastfm; } virtual void update() OVERRIDE; diff --git a/src/lyrics.h b/src/lyrics.h index aace697d..927e2c25 100644 --- a/src/lyrics.h +++ b/src/lyrics.h @@ -38,6 +38,7 @@ struct Lyrics: Screen, Tabbable virtual void switchTo() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::Lyrics; } virtual void update() OVERRIDE; diff --git a/src/media_library.h b/src/media_library.h index 1c76ae01..bd048efb 100644 --- a/src/media_library.h +++ b/src/media_library.h @@ -32,6 +32,7 @@ struct MediaLibrary: Screen, Filterable, HasColumns, HasSongs, Sea virtual void resize() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::MediaLibrary; } virtual void refresh() OVERRIDE; virtual void update() OVERRIDE; diff --git a/src/outputs.h b/src/outputs.h index 4aac7be5..d7f5f374 100644 --- a/src/outputs.h +++ b/src/outputs.h @@ -39,6 +39,7 @@ struct Outputs: Screen>, Tabbable virtual void resize() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::Outputs; } virtual void update() OVERRIDE { } diff --git a/src/playlist.h b/src/playlist.h index 10e81ed5..242459ae 100644 --- a/src/playlist.h +++ b/src/playlist.h @@ -36,6 +36,7 @@ struct Playlist: Screen>, Filterable, HasSongs, Searchable, virtual void resize() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::Playlist; } virtual void update() OVERRIDE { } diff --git a/src/playlist_editor.h b/src/playlist_editor.h index e96407e8..00db4920 100644 --- a/src/playlist_editor.h +++ b/src/playlist_editor.h @@ -32,6 +32,7 @@ struct PlaylistEditor: Screen, Filterable, HasColumns, HasSongs, S virtual void resize() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::PlaylistEditor; } virtual void refresh() OVERRIDE; virtual void update() OVERRIDE; diff --git a/src/screen.h b/src/screen.h index f476a1b6..a821a744 100644 --- a/src/screen.h +++ b/src/screen.h @@ -23,6 +23,7 @@ #include "menu.h" #include "scrollpad.h" +#include "screen_type.h" void genericMouseButtonPressed(NC::Window &w, MEVENT me); void scrollpadMouseButtonPressed(NC::Scrollpad &w, MEVENT me); @@ -60,6 +61,9 @@ struct BaseScreen /// @return title of the screen virtual std::wstring title() = 0; + /// @return type of the screen + virtual ScreenType type() = 0; + /// If the screen contantly has to update itself /// somehow, it should be called by this function. virtual void update() = 0; diff --git a/src/screen_type.cpp b/src/screen_type.cpp new file mode 100644 index 00000000..28c9d88b --- /dev/null +++ b/src/screen_type.cpp @@ -0,0 +1,70 @@ +/*************************************************************************** + * Copyright (C) 2008-2012 by Andrzej Rybczak * + * electricityispower@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include "screen_type.h" + +ScreenType stringtoStarterScreenType(const std::string &s) +{ + ScreenType result = ScreenType::Unknown; + if (s == "browser") + result = ScreenType::Browser; + else if (s == "clock") + result = ScreenType::Clock; + else if (s == "help") + result = ScreenType::Help; + else if (s == "media_library") + result = ScreenType::MediaLibrary; + else if (s == "outputs") + result = ScreenType::Outputs; + else if (s == "playlist") + result = ScreenType::Playlist; + else if (s == "playlist_editor") + result = ScreenType::PlaylistEditor; + else if (s == "search_engine") + result = ScreenType::SearchEngine; + else if (s == "tag_editor") + result = ScreenType::TagEditor; + else if (s == "visualizer") + result = ScreenType::Visualizer; + return result; +} + +ScreenType stringToScreenType(const std::string &s) +{ + ScreenType result = stringtoStarterScreenType(s); + if (result == ScreenType::Unknown) + { + if (s == "last_fm") + result = ScreenType::Lastfm; + else if (s == "lyrics") + result = ScreenType::Lyrics; + else if (s == "selected_items_adder") + result = ScreenType::SelectedItemsAdder; + else if (s == "server_info") + result = ScreenType::ServerInfo; + else if (s == "song_info") + result = ScreenType::SongInfo; + else if (s == "sort_playlist_dialog") + result = ScreenType::SortPlaylistDialog; + else if (s == "tiny_tag_editor") + result = ScreenType::TinyTagEditor; + } + return result; +} diff --git a/src/screen_type.h b/src/screen_type.h new file mode 100644 index 00000000..44d1f3c9 --- /dev/null +++ b/src/screen_type.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2008-2012 by Andrzej Rybczak * + * electricityispower@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef NCMPCPP_SCREEN_TYPE_H +#define NCMPCPP_SCREEN_TYPE_H + +#include + +enum class ScreenType { + Browser, + Clock, + Help, + Lastfm, + Lyrics, + MediaLibrary, + Outputs, + Playlist, + PlaylistEditor, + SearchEngine, + SelectedItemsAdder, + ServerInfo, + SongInfo, + SortPlaylistDialog, + TagEditor, + TinyTagEditor, + Unknown, + Visualizer, +}; + +ScreenType stringtoStarterScreenType(const std::string &s); +ScreenType stringToScreenType(const std::string &s); + +#endif // NCMPCPP_SCREEN_TYPE_H diff --git a/src/search_engine.h b/src/search_engine.h index 2653ae5b..2bf2ec6f 100644 --- a/src/search_engine.h +++ b/src/search_engine.h @@ -82,6 +82,7 @@ struct SearchEngine: Screen>, Filterable, HasSongs, Searchable, virtual void switchTo() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::SearchEngine; } virtual void update() OVERRIDE { } diff --git a/src/sel_items_adder.h b/src/sel_items_adder.h index 36750a61..3b24d3e1 100644 --- a/src/sel_items_adder.h +++ b/src/sel_items_adder.h @@ -37,6 +37,7 @@ struct SelectedItemsAdder: Screen> *>, Ta virtual void refresh() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::SelectedItemsAdder; } virtual void update() OVERRIDE { } diff --git a/src/server_info.h b/src/server_info.h index 48877bdc..d2067b6f 100644 --- a/src/server_info.h +++ b/src/server_info.h @@ -33,6 +33,7 @@ struct ServerInfo: Screen, Tabbable virtual void resize() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::ServerInfo; } virtual void update() OVERRIDE; diff --git a/src/song_info.h b/src/song_info.h index 6c00e5a1..5f51083f 100644 --- a/src/song_info.h +++ b/src/song_info.h @@ -41,6 +41,7 @@ struct SongInfo: Screen, Tabbable virtual void resize() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::SongInfo; } virtual void update() OVERRIDE { } diff --git a/src/sort_playlist.h b/src/sort_playlist.h index 6a7188a7..12221c70 100644 --- a/src/sort_playlist.h +++ b/src/sort_playlist.h @@ -35,6 +35,7 @@ struct SortPlaylistDialog virtual void resize() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::SortPlaylistDialog; } virtual void update() OVERRIDE { } diff --git a/src/tag_editor.h b/src/tag_editor.h index 0270e07e..1498c751 100644 --- a/src/tag_editor.h +++ b/src/tag_editor.h @@ -40,6 +40,7 @@ struct TagEditor: Screen, Filterable, HasColumns, HasSongs, Search virtual void switchTo() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::TagEditor; } virtual void refresh() OVERRIDE; virtual void update() OVERRIDE; diff --git a/src/tiny_tag_editor.h b/src/tiny_tag_editor.h index 83777081..f298d718 100644 --- a/src/tiny_tag_editor.h +++ b/src/tiny_tag_editor.h @@ -38,6 +38,7 @@ struct TinyTagEditor: Screen> virtual void switchTo() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::TinyTagEditor; } virtual void update() OVERRIDE { } diff --git a/src/visualizer.h b/src/visualizer.h index 4285212d..f3cc9911 100644 --- a/src/visualizer.h +++ b/src/visualizer.h @@ -41,6 +41,7 @@ struct Visualizer: Screen, Tabbable virtual void resize() OVERRIDE; virtual std::wstring title() OVERRIDE; + virtual ScreenType type() OVERRIDE { return ScreenType::Visualizer; } virtual void update() OVERRIDE; virtual void scroll(NC::Where) OVERRIDE { }