From c8d1e5491bf5ca9b7e3a7d16780faebb4a40793e Mon Sep 17 00:00:00 2001 From: rathnor Date: Sun, 16 Nov 2003 22:33:56 +0000 Subject: add better theme path searching --- ChangeLog | 7 +++++++ src/FbTk/Image.cc | 6 +++++- src/FbTk/Image.hh | 4 +++- src/FbTk/Theme.cc | 40 ++++++++++++++++++++++++++++++++++++---- src/FbTk/Theme.hh | 4 +++- src/Screen.cc | 5 +++-- 6 files changed, 57 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2b179b8..0d6018c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ (Format: Year/Month/Day) Changes for 0.9.6: +*03/11/16: + * Add image search paths when loading a style (Simon) + - now looks for pixmaps in and /pixmaps + - now looks for styles in //theme.cfg + => for this, stylebase is the style directory + - pixmap styles should use the new format for portability + Theme.hh/cc Image.hh/cc Screen.cc *03/11/15: * Moved fluxbox-generate_menu to fluxbox-generate_menu.in (Thanks Han) fixed empty submenu problem diff --git a/src/FbTk/Image.cc b/src/FbTk/Image.cc index e4ab6ac..f5ffc24 100644 --- a/src/FbTk/Image.cc +++ b/src/FbTk/Image.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Image.cc,v 1.1 2003/08/22 21:25:14 fluxgen Exp $ +// $Id: Image.cc,v 1.2 2003/11/16 22:33:55 rathnor Exp $ #include "Image.hh" #include "StringUtil.hh" @@ -113,6 +113,10 @@ void Image::addSearchPath(const std::string &search_path) { s_search_paths.push_back(search_path); } +void Image::removeSearchPath(const std::string &search_path) { + s_search_paths.remove(search_path); +} + void Image::removeAllSearchPaths() { s_search_paths.clear(); } diff --git a/src/FbTk/Image.hh b/src/FbTk/Image.hh index c655a2e..1dc3f1b 100644 --- a/src/FbTk/Image.hh +++ b/src/FbTk/Image.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Image.hh,v 1.1 2003/08/22 21:25:14 fluxgen Exp $ +// $Id: Image.hh,v 1.2 2003/11/16 22:33:55 rathnor Exp $ #ifndef FBTK_IMAGE_HH #define FBTK_IMAGE_HH @@ -46,6 +46,8 @@ public: static void remove(ImageBase &base); /// adds a path to search images from static void addSearchPath(const std::string &search_path); + /// removes a path to search images from + static void removeSearchPath(const std::string &search_path); /// adds a path to search images from static void removeAllSearchPaths(); private: diff --git a/src/FbTk/Theme.cc b/src/FbTk/Theme.cc index c554545..59e9817 100644 --- a/src/FbTk/Theme.cc +++ b/src/FbTk/Theme.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Theme.cc,v 1.20 2003/10/13 22:57:14 fluxgen Exp $ +// $Id: Theme.cc,v 1.21 2003/11/16 22:33:55 rathnor Exp $ #include "Theme.hh" @@ -27,10 +27,12 @@ #include "App.hh" #include "StringUtil.hh" #include "ThemeItems.hh" +#include "Directory.hh" #include #include #include + using namespace std; namespace FbTk { @@ -50,7 +52,8 @@ ThemeManager &ThemeManager::instance() { ThemeManager::ThemeManager(): m_max_screens(ScreenCount(FbTk::App::instance()->display())), - m_verbose(false) { + m_verbose(false), + m_themelocation("") { } @@ -71,10 +74,39 @@ bool ThemeManager::unregisterTheme(Theme &tm) { } bool ThemeManager::load(const std::string &filename) { - - if (!m_database.load(FbTk::StringUtil::expandFilename(filename).c_str())) + std::string location = FbTk::StringUtil::expandFilename(filename).c_str(); + std::string prefix = ""; + + if (Directory::isDirectory(filename)) { + prefix = location; + + location.append("/theme.cfg"); + if (!Directory::isRegularFile(location)) { + cerr<<"Error loading theme file "<, Theme and ThemeManager which is the base for any theme @@ -149,6 +149,8 @@ private: const int m_max_screens; XrmDatabaseHelper m_database; bool m_verbose; + + std::string m_themelocation; }; diff --git a/src/Screen.cc b/src/Screen.cc index 1aa2e73..5194434 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.240 2003/10/31 10:37:09 rathnor Exp $ +// $Id: Screen.cc,v 1.241 2003/11/16 22:33:55 rathnor Exp $ #include "Screen.hh" @@ -2016,7 +2016,8 @@ void BScreen::createStyleMenu(FbTk::Menu &menu, for (size_t file_index = 0; file_index < dir.entries(); file_index++) { std::string style(stylesdir + '/' + filelist[file_index]); // add to menu only if the file is a regular file - if (FbTk::Directory::isRegularFile(style)) + if (FbTk::Directory::isRegularFile(style) || + FbTk::Directory::isRegularFile(style + "/theme.cfg")) menu.insert(new StyleMenuItem(filelist[file_index], style)); } // update menu graphics -- cgit v0.11.2