all repos — fluxbox @ c8d1e5491bf5ca9b7e3a7d16780faebb4a40793e

custom fork of the fluxbox windowmanager

add better theme path searching
rathnor rathnor
commit

c8d1e5491bf5ca9b7e3a7d16780faebb4a40793e

parent

7a3bc3df9ae14fda35f40b5fbf6d059c392c6a26

6 files changed, 57 insertions(+), 9 deletions(-)

jump to
M ChangeLogChangeLog

@@ -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 <stylebase> and <stylebase>/pixmaps + - now looks for styles in <stylesdir>/<stylename>/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
M src/FbTk/Image.ccsrc/FbTk/Image.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// 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"

@@ -111,6 +111,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() {
M src/FbTk/Image.hhsrc/FbTk/Image.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// 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 @@ /// @return false on failure

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:
M src/FbTk/Theme.ccsrc/FbTk/Theme.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// 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 "XrmDatabaseHelper.hh"

#include "App.hh" #include "StringUtil.hh" #include "ThemeItems.hh" +#include "Directory.hh" #include <cstdio> #include <memory> #include <iostream> + using namespace std; namespace FbTk {

@@ -50,7 +52,8 @@ }

ThemeManager::ThemeManager(): m_max_screens(ScreenCount(FbTk::App::instance()->display())), - m_verbose(false) { + m_verbose(false), + m_themelocation("") { }

@@ -71,9 +74,38 @@ return true;

} 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 "<<location<<": not a regular file"<<endl; + return false; + } + } else { + // dirname + prefix = location.substr(0, location.find_last_of('/')); + } + + if (!m_database.load(location.c_str())) return false; + + // relies on the fact that load_rc clears search paths each time + if (m_themelocation != "") { + Image::removeSearchPath(m_themelocation); + m_themelocation.append("/pixmaps"); + Image::removeSearchPath(m_themelocation); + } + + m_themelocation = prefix; + + location = prefix; + Image::addSearchPath(location); + location.append("/pixmaps"); + Image::addSearchPath(location); //get list and go throu all the resources and load them ThemeList::iterator theme_it = m_themelist.begin();
M src/FbTk/Theme.hhsrc/FbTk/Theme.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Theme.hh,v 1.10 2003/09/14 11:17:21 fluxgen Exp $ +// $Id: Theme.hh,v 1.11 2003/11/16 22:33:56 rathnor Exp $ /** @file holds ThemeItem<T>, Theme and ThemeManager which is the base for any theme

@@ -149,6 +149,8 @@ ThemeList m_themelist;

const int m_max_screens; XrmDatabaseHelper m_database; bool m_verbose; + + std::string m_themelocation; };
M src/Screen.ccsrc/Screen.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// 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 @@ // for each file in directory add filename and path to 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