diff options
author | fluxgen <fluxgen> | 2003-08-19 21:25:26 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-08-19 21:25:26 (GMT) |
commit | 46ea237c383b6d305dfbea77c6bff54c7b73c2b3 (patch) | |
tree | 7301941923822c5e2f90fc50eaf6ab2541ea64f1 /src/FbTk | |
parent | ce77642a0eb1901304cc56a879d6d2e21612c850 (diff) | |
download | fluxbox_paul-46ea237c383b6d305dfbea77c6bff54c7b73c2b3.zip fluxbox_paul-46ea237c383b6d305dfbea77c6bff54c7b73c2b3.tar.bz2 |
fixed load item
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/Theme.cc | 31 | ||||
-rw-r--r-- | src/FbTk/Theme.hh | 8 |
2 files changed, 27 insertions, 12 deletions
diff --git a/src/FbTk/Theme.cc b/src/FbTk/Theme.cc index 0121eb5..6467fc7 100644 --- a/src/FbTk/Theme.cc +++ b/src/FbTk/Theme.cc | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: Theme.cc,v 1.11 2003/08/13 09:24:02 fluxgen Exp $ | 22 | // $Id: Theme.cc,v 1.12 2003/08/19 21:25:26 fluxgen Exp $ |
23 | 23 | ||
24 | #include "Theme.hh" | 24 | #include "Theme.hh" |
25 | 25 | ||
@@ -245,24 +245,35 @@ void ThemeManager::loadTheme(Theme &tm) { | |||
245 | std::list<ThemeItem_base *>::iterator i_end = tm.itemList().end(); | 245 | std::list<ThemeItem_base *>::iterator i_end = tm.itemList().end(); |
246 | for (; i != i_end; ++i) { | 246 | for (; i != i_end; ++i) { |
247 | ThemeItem_base *resource = *i; | 247 | ThemeItem_base *resource = *i; |
248 | loadItem(*resource); | 248 | if (!loadItem(*resource)) { |
249 | // try fallback resource in theme | ||
250 | if (!tm.fallback(*resource)) { | ||
251 | cerr<<"Failed to read theme item: "<<resource->name()<<endl; | ||
252 | cerr<<"Setting default value"<<endl; | ||
253 | resource->setDefaultValue(); | ||
254 | } | ||
255 | } | ||
249 | } | 256 | } |
250 | // send reconfiguration signal to theme and listeners | 257 | // send reconfiguration signal to theme and listeners |
251 | } | 258 | } |
252 | 259 | ||
253 | void ThemeManager::loadItem(ThemeItem_base &resource) { | 260 | bool ThemeManager::loadItem(ThemeItem_base &resource) { |
261 | return loadItem(resource, resource.name(), resource.altName()); | ||
262 | } | ||
263 | |||
264 | /// handles resource item loading with specific name/altname | ||
265 | bool ThemeManager::loadItem(ThemeItem_base &resource, const std::string &name, const std::string &alt_name) { | ||
254 | XrmValue value; | 266 | XrmValue value; |
255 | char *value_type; | 267 | char *value_type; |
256 | 268 | ||
257 | if (XrmGetResource(*m_database, resource.name().c_str(), | 269 | if (XrmGetResource(*m_database, name.c_str(), |
258 | resource.altName().c_str(), &value_type, &value)) { | 270 | alt_name.c_str(), &value_type, &value)) { |
259 | resource.setFromString(value.addr); | 271 | resource.setFromString(value.addr); |
260 | resource.load(); // load additional stuff by the ThemeItem | 272 | resource.load(); // load additional stuff by the ThemeItem |
261 | } else { | 273 | } else |
262 | cerr<<"Failed to read theme item: "<<resource.name()<<endl; | 274 | return false; |
263 | cerr<<"Setting default value"<<endl; | 275 | |
264 | resource.setDefaultValue(); | 276 | return true; |
265 | } | ||
266 | } | 277 | } |
267 | 278 | ||
268 | std::string ThemeManager::resourceValue(const std::string &name, const std::string &altname) { | 279 | std::string ThemeManager::resourceValue(const std::string &name, const std::string &altname) { |
diff --git a/src/FbTk/Theme.hh b/src/FbTk/Theme.hh index a857f67..ef9a13f 100644 --- a/src/FbTk/Theme.hh +++ b/src/FbTk/Theme.hh | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: Theme.hh,v 1.6 2003/08/13 09:24:33 fluxgen Exp $ | 22 | // $Id: Theme.hh,v 1.7 2003/08/19 21:25:26 fluxgen Exp $ |
23 | 23 | ||
24 | /** | 24 | /** |
25 | @file holds ThemeItem<T>, Theme and ThemeManager which is the base for any theme | 25 | @file holds ThemeItem<T>, Theme and ThemeManager which is the base for any theme |
@@ -80,6 +80,8 @@ public: | |||
80 | inline T *operator->() { return &m_value; } | 80 | inline T *operator->() { return &m_value; } |
81 | inline const T *operator->() const { return &m_value; } | 81 | inline const T *operator->() const { return &m_value; } |
82 | /**@}*/ | 82 | /**@}*/ |
83 | |||
84 | FbTk::Theme &theme() { return m_tm; } | ||
83 | private: | 85 | private: |
84 | 86 | ||
85 | T m_value; | 87 | T m_value; |
@@ -102,6 +104,7 @@ public: | |||
102 | /// remove ThemeItem | 104 | /// remove ThemeItem |
103 | template <typename T> | 105 | template <typename T> |
104 | void remove(ThemeItem<T> &item); | 106 | void remove(ThemeItem<T> &item); |
107 | virtual bool fallback(ThemeItem_base &base) { return false; } | ||
105 | FbTk::Subject &reconfigSig() { return m_reconfig_sig; } | 108 | FbTk::Subject &reconfigSig() { return m_reconfig_sig; } |
106 | private: | 109 | private: |
107 | const int m_screen_num; | 110 | const int m_screen_num; |
@@ -121,7 +124,8 @@ public: | |||
121 | bool load(const std::string &filename); | 124 | bool load(const std::string &filename); |
122 | std::string resourceValue(const std::string &name, const std::string &altname); | 125 | std::string resourceValue(const std::string &name, const std::string &altname); |
123 | void loadTheme(Theme &tm); | 126 | void loadTheme(Theme &tm); |
124 | void loadItem(ThemeItem_base &resource); | 127 | bool loadItem(ThemeItem_base &resource); |
128 | bool loadItem(ThemeItem_base &resource, const std::string &name, const std::string &altname); | ||
125 | private: | 129 | private: |
126 | ThemeManager(); | 130 | ThemeManager(); |
127 | ~ThemeManager() { } | 131 | ~ThemeManager() { } |