all repos — fluxbox @ 46ea237c383b6d305dfbea77c6bff54c7b73c2b3

custom fork of the fluxbox windowmanager

fixed load item
fluxgen fluxgen
commit

46ea237c383b6d305dfbea77c6bff54c7b73c2b3

parent

ce77642a0eb1901304cc56a879d6d2e21612c850

2 files changed, 27 insertions(+), 12 deletions(-)

jump to
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.11 2003/08/13 09:24:02 fluxgen Exp $ +// $Id: Theme.cc,v 1.12 2003/08/19 21:25:26 fluxgen Exp $ #include "Theme.hh"

@@ -245,24 +245,35 @@ std::list<ThemeItem_base *>::iterator i = tm.itemList().begin();

std::list<ThemeItem_base *>::iterator i_end = tm.itemList().end(); for (; i != i_end; ++i) { ThemeItem_base *resource = *i; - loadItem(*resource); + if (!loadItem(*resource)) { + // try fallback resource in theme + if (!tm.fallback(*resource)) { + cerr<<"Failed to read theme item: "<<resource->name()<<endl; + cerr<<"Setting default value"<<endl; + resource->setDefaultValue(); + } + } } // send reconfiguration signal to theme and listeners } -void ThemeManager::loadItem(ThemeItem_base &resource) { +bool ThemeManager::loadItem(ThemeItem_base &resource) { + return loadItem(resource, resource.name(), resource.altName()); +} + +/// handles resource item loading with specific name/altname +bool ThemeManager::loadItem(ThemeItem_base &resource, const std::string &name, const std::string &alt_name) { XrmValue value; char *value_type; - if (XrmGetResource(*m_database, resource.name().c_str(), - resource.altName().c_str(), &value_type, &value)) { + if (XrmGetResource(*m_database, name.c_str(), + alt_name.c_str(), &value_type, &value)) { resource.setFromString(value.addr); resource.load(); // load additional stuff by the ThemeItem - } else { - cerr<<"Failed to read theme item: "<<resource.name()<<endl; - cerr<<"Setting default value"<<endl; - resource.setDefaultValue(); - } + } else + return false; + + return true; } std::string ThemeManager::resourceValue(const std::string &name, const std::string &altname) {
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.6 2003/08/13 09:24:33 fluxgen Exp $ +// $Id: Theme.hh,v 1.7 2003/08/19 21:25:26 fluxgen Exp $ /** @file holds ThemeItem<T>, Theme and ThemeManager which is the base for any theme

@@ -80,6 +80,8 @@ inline const T& operator*() const { return m_value; }

inline T *operator->() { return &m_value; } inline const T *operator->() const { return &m_value; } /**@}*/ + + FbTk::Theme &theme() { return m_tm; } private: T m_value;

@@ -102,6 +104,7 @@ void add(ThemeItem<T> &item);

/// remove ThemeItem template <typename T> void remove(ThemeItem<T> &item); + virtual bool fallback(ThemeItem_base &base) { return false; } FbTk::Subject &reconfigSig() { return m_reconfig_sig; } private: const int m_screen_num;

@@ -121,7 +124,8 @@ static ThemeManager &instance();

bool load(const std::string &filename); std::string resourceValue(const std::string &name, const std::string &altname); void loadTheme(Theme &tm); - void loadItem(ThemeItem_base &resource); + bool loadItem(ThemeItem_base &resource); + bool loadItem(ThemeItem_base &resource, const std::string &name, const std::string &altname); private: ThemeManager(); ~ThemeManager() { }