aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Theme.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/Theme.cc')
-rw-r--r--src/FbTk/Theme.cc31
1 files changed, 21 insertions, 10 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
253void ThemeManager::loadItem(ThemeItem_base &resource) { 260bool ThemeManager::loadItem(ThemeItem_base &resource) {
261 return loadItem(resource, resource.name(), resource.altName());
262}
263
264/// handles resource item loading with specific name/altname
265bool 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
268std::string ThemeManager::resourceValue(const std::string &name, const std::string &altname) { 279std::string ThemeManager::resourceValue(const std::string &name, const std::string &altname) {