diff options
Diffstat (limited to 'src/FbTk/Resource.cc')
-rw-r--r-- | src/FbTk/Resource.cc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/FbTk/Resource.cc b/src/FbTk/Resource.cc index fb0f595..37555b3 100644 --- a/src/FbTk/Resource.cc +++ b/src/FbTk/Resource.cc | |||
@@ -82,10 +82,13 @@ void ResourceManager_base::setResourceValue(const string &resname, const string | |||
82 | 82 | ||
83 | } | 83 | } |
84 | 84 | ||
85 | ResourceManager::ResourceManager(const char *filename, bool lock_db) : | 85 | ResourceManager::ResourceManager(const std::string &root, const std::string &alt_root, |
86 | const char *filename, bool lock_db) : | ||
87 | ResourceManager_base(root), | ||
86 | m_db_lock(0), | 88 | m_db_lock(0), |
87 | m_database(0), | 89 | m_database(0), |
88 | m_filename(filename ? filename : "") | 90 | m_filename(filename ? filename : ""), |
91 | m_alt_root(alt_root) | ||
89 | { | 92 | { |
90 | static bool xrm_initialized = false; | 93 | static bool xrm_initialized = false; |
91 | if (!xrm_initialized) { | 94 | if (!xrm_initialized) { |
@@ -131,8 +134,8 @@ bool ResourceManager::load(const char *filename) { | |||
131 | for (; i != i_end; ++i) { | 134 | for (; i != i_end; ++i) { |
132 | 135 | ||
133 | Resource_base *resource = *i; | 136 | Resource_base *resource = *i; |
134 | if (XrmGetResource(**m_database, resource->name().c_str(), | 137 | if (XrmGetResource(**m_database, (m_root + '.' + resource->name()).c_str(), |
135 | resource->altName().c_str(), &value_type, &value)) | 138 | (m_alt_root + '.' + resource->altName()).c_str(), &value_type, &value)) |
136 | resource->setFromString(value.addr); | 139 | resource->setFromString(value.addr); |
137 | else { | 140 | else { |
138 | _FB_USES_NLS; | 141 | _FB_USES_NLS; |
@@ -166,13 +169,12 @@ bool ResourceManager::save(const char *filename, const char *mergefilename) { | |||
166 | // empty database | 169 | // empty database |
167 | XrmDatabaseHelper database; | 170 | XrmDatabaseHelper database; |
168 | 171 | ||
169 | string rc_string; | ||
170 | ResourceList::iterator i = m_resourcelist.begin(); | 172 | ResourceList::iterator i = m_resourcelist.begin(); |
171 | ResourceList::iterator i_end = m_resourcelist.end(); | 173 | ResourceList::iterator i_end = m_resourcelist.end(); |
172 | //write all resources to database | 174 | //write all resources to database |
173 | for (; i != i_end; ++i) { | 175 | for (; i != i_end; ++i) { |
174 | Resource_base *resource = *i; | 176 | Resource_base *resource = *i; |
175 | rc_string = resource->name() + string(": ") + resource->getString(); | 177 | const string &rc_string = m_root + '.' + resource->name() + ": " + resource->getString(); |
176 | XrmPutLineResource(&*database, rc_string.c_str()); | 178 | XrmPutLineResource(&*database, rc_string.c_str()); |
177 | } | 179 | } |
178 | 180 | ||
@@ -248,8 +250,8 @@ void ResourceManager::addResource(Resource_base &r) { | |||
248 | char *value_type; | 250 | char *value_type; |
249 | 251 | ||
250 | // now, load the value for this resource | 252 | // now, load the value for this resource |
251 | if (XrmGetResource(**m_database, r.name().c_str(), | 253 | if (XrmGetResource(**m_database, (m_root + '.' + r.name()).c_str(), |
252 | r.altName().c_str(), &value_type, &value)) { | 254 | (m_alt_root + '.' + r.altName()).c_str(), &value_type, &value)) { |
253 | r.setFromString(value.addr); | 255 | r.setFromString(value.addr); |
254 | } else { | 256 | } else { |
255 | std::cerr<<"Failed to read: "<<r.name()<<std::endl; | 257 | std::cerr<<"Failed to read: "<<r.name()<<std::endl; |