aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/LResource.cc4
-rw-r--r--src/FbTk/LResource.hh3
-rw-r--r--src/FbTk/Resource.cc18
-rw-r--r--src/FbTk/Resource.hh7
-rw-r--r--src/fluxbox.cc42
-rw-r--r--src/main.cc4
6 files changed, 42 insertions, 36 deletions
diff --git a/src/FbTk/LResource.cc b/src/FbTk/LResource.cc
index 5842b65..78511eb 100644
--- a/src/FbTk/LResource.cc
+++ b/src/FbTk/LResource.cc
@@ -82,8 +82,8 @@ void LResourceManager::initState(lua::state &l) {
82 l.setfield(lua::REGISTRYINDEX, make_root); 82 l.setfield(lua::REGISTRYINDEX, make_root);
83} 83}
84 84
85LResourceManager::LResourceManager(lua::state &l, const std::string &root) 85LResourceManager::LResourceManager(const std::string &root, lua::state &l)
86 : m_l(&l), m_root(root) { 86 : ResourceManager_base(root), m_l(&l) {
87 l.checkstack(2); 87 l.checkstack(2);
88 lua::stack_sentry s(l); 88 lua::stack_sentry s(l);
89 89
diff --git a/src/FbTk/LResource.hh b/src/FbTk/LResource.hh
index 0853687..185a029 100644
--- a/src/FbTk/LResource.hh
+++ b/src/FbTk/LResource.hh
@@ -39,7 +39,7 @@ class LResourceManager: public ResourceManager_base {
39public: 39public:
40 static void initState(lua::state &l); 40 static void initState(lua::state &l);
41 41
42 LResourceManager(lua::state &l, const std::string &root); 42 LResourceManager(const std::string &root, lua::state &l);
43 virtual bool save(const char *filename, const char *); 43 virtual bool save(const char *filename, const char *);
44 virtual void addResource(Resource_base &r); 44 virtual void addResource(Resource_base &r);
45 virtual void removeResource(Resource_base &r); 45 virtual void removeResource(Resource_base &r);
@@ -47,7 +47,6 @@ public:
47private: 47private:
48 48
49 lua::state *m_l; 49 lua::state *m_l;
50 std::string m_root;
51}; 50};
52 51
53} // end namespace FbTk 52} // end namespace FbTk
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
85ResourceManager::ResourceManager(const char *filename, bool lock_db) : 85ResourceManager::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;
diff --git a/src/FbTk/Resource.hh b/src/FbTk/Resource.hh
index 33a6bb2..744178b 100644
--- a/src/FbTk/Resource.hh
+++ b/src/FbTk/Resource.hh
@@ -87,6 +87,8 @@ class ResourceManager_base
87public: 87public:
88 typedef std::list<Resource_base *> ResourceList; 88 typedef std::list<Resource_base *> ResourceList;
89 89
90 ResourceManager_base(const std::string &root) : m_root(root) {}
91
90 virtual ~ResourceManager_base() {} 92 virtual ~ResourceManager_base() {}
91 93
92 /// Save all resouces registered to this class 94 /// Save all resouces registered to this class
@@ -123,6 +125,7 @@ public:
123 125
124protected: 126protected:
125 ResourceList m_resourcelist; 127 ResourceList m_resourcelist;
128 const std::string m_root;
126}; 129};
127 130
128class ResourceManager: public ResourceManager_base 131class ResourceManager: public ResourceManager_base
@@ -130,7 +133,8 @@ class ResourceManager: public ResourceManager_base
130public: 133public:
131 // lock specifies if the database should be opened with one level locked 134 // lock specifies if the database should be opened with one level locked
132 // (useful for constructing inside initial set of constructors) 135 // (useful for constructing inside initial set of constructors)
133 ResourceManager(const char *filename, bool lock_db); 136 ResourceManager(const std::string &root, const std::string &alt_root,
137 const char *filename, bool lock_db);
134 virtual ~ResourceManager(); 138 virtual ~ResourceManager();
135 139
136 /// Load all resources registered to this class 140 /// Load all resources registered to this class
@@ -169,6 +173,7 @@ private:
169 XrmDatabaseHelper *m_database; 173 XrmDatabaseHelper *m_database;
170 174
171 std::string m_filename; 175 std::string m_filename;
176 std::string m_alt_root;
172}; 177};
173 178
174 179
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 4ef6a67..73d91ba 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -237,27 +237,27 @@ Fluxbox::Fluxbox(int argc, char **argv,
237 const std::string& rc_path, const std::string& rc_filename, bool xsync) 237 const std::string& rc_path, const std::string& rc_filename, bool xsync)
238 : FbTk::App(dpy_name.c_str()), 238 : FbTk::App(dpy_name.c_str()),
239 m_fbatoms(FbAtoms::instance()), 239 m_fbatoms(FbAtoms::instance()),
240 m_resourcemanager(rc_filename.c_str(), true), 240 m_resourcemanager("session", "Session", rc_filename.c_str(), true),
241 // TODO: shouldn't need a separate one for screen 241 // TODO: shouldn't need a separate one for screen
242 m_screen_rm(m_resourcemanager), 242 m_screen_rm(m_resourcemanager),
243 243
244 m_RC_PATH(rc_path), 244 m_RC_PATH(rc_path),
245 m_rc_ignoreborder(m_resourcemanager, false, "session.ignoreBorder", "Session.IgnoreBorder"), 245 m_rc_ignoreborder(m_resourcemanager, false, "ignoreBorder", "IgnoreBorder"),
246 m_rc_pseudotrans(m_resourcemanager, false, "session.forcePseudoTransparency", "Session.forcePseudoTransparency"), 246 m_rc_pseudotrans(m_resourcemanager, false, "forcePseudoTransparency", "forcePseudoTransparency"),
247 m_rc_colors_per_channel(m_resourcemanager, 4, 247 m_rc_colors_per_channel(m_resourcemanager, 4,
248 "session.colorsPerChannel", "Session.ColorsPerChannel"), 248 "colorsPerChannel", "ColorsPerChannel"),
249 m_rc_double_click_interval(m_resourcemanager, 250, "session.doubleClickInterval", "Session.DoubleClickInterval"), 249 m_rc_double_click_interval(m_resourcemanager, 250, "doubleClickInterval", "DoubleClickInterval"),
250 m_rc_tabs_padding(m_resourcemanager, 0, "session.tabPadding", "Session.TabPadding"), 250 m_rc_tabs_padding(m_resourcemanager, 0, "tabPadding", "TabPadding"),
251 m_rc_stylefile(m_resourcemanager, DEFAULTSTYLE, "session.styleFile", "Session.StyleFile"), 251 m_rc_stylefile(m_resourcemanager, DEFAULTSTYLE, "styleFile", "StyleFile"),
252 m_rc_styleoverlayfile(m_resourcemanager, m_RC_PATH + "/overlay", "session.styleOverlay", "Session.StyleOverlay"), 252 m_rc_styleoverlayfile(m_resourcemanager, m_RC_PATH + "/overlay", "styleOverlay", "StyleOverlay"),
253 m_rc_menufile(m_resourcemanager, m_RC_PATH + "/menu", "session.menuFile", "Session.MenuFile"), 253 m_rc_menufile(m_resourcemanager, m_RC_PATH + "/menu", "menuFile", "MenuFile"),
254 m_rc_keyfile(m_resourcemanager, m_RC_PATH + "/keys", "session.keyFile", "Session.KeyFile"), 254 m_rc_keyfile(m_resourcemanager, m_RC_PATH + "/keys", "keyFile", "KeyFile"),
255 m_rc_slitlistfile(m_resourcemanager, m_RC_PATH + "/slitlist", "session.slitlistFile", "Session.SlitlistFile"), 255 m_rc_slitlistfile(m_resourcemanager, m_RC_PATH + "/slitlist", "slitlistFile", "SlitlistFile"),
256 m_rc_appsfile(m_resourcemanager, m_RC_PATH + "/apps", "session.appsFile", "Session.AppsFile"), 256 m_rc_appsfile(m_resourcemanager, m_RC_PATH + "/apps", "appsFile", "AppsFile"),
257 m_rc_tabs_attach_area(m_resourcemanager, ATTACH_AREA_WINDOW, "session.tabsAttachArea", "Session.TabsAttachArea"), 257 m_rc_tabs_attach_area(m_resourcemanager, ATTACH_AREA_WINDOW, "tabsAttachArea", "TabsAttachArea"),
258 m_rc_cache_life(m_resourcemanager, 5, "session.cacheLife", "Session.CacheLife"), 258 m_rc_cache_life(m_resourcemanager, 5, "cacheLife", "CacheLife"),
259 m_rc_cache_max(m_resourcemanager, 200, "session.cacheMax", "Session.CacheMax"), 259 m_rc_cache_max(m_resourcemanager, 200, "cacheMax", "CacheMax"),
260 m_rc_auto_raise_delay(m_resourcemanager, 250, "session.autoRaiseDelay", "Session.AutoRaiseDelay"), 260 m_rc_auto_raise_delay(m_resourcemanager, 250, "autoRaiseDelay", "AutoRaiseDelay"),
261 m_masked_window(0), 261 m_masked_window(0),
262 m_mousescreen(0), 262 m_mousescreen(0),
263 m_keyscreen(0), 263 m_keyscreen(0),
@@ -400,8 +400,8 @@ Fluxbox::Fluxbox(int argc, char **argv,
400 for (size_t s = 0; s < screens.size(); s++) { 400 for (size_t s = 0; s < screens.size(); s++) {
401 std::string sc_nr = FbTk::StringUtil::number2String(screens[s]); 401 std::string sc_nr = FbTk::StringUtil::number2String(screens[s]);
402 BScreen *screen = new BScreen(m_screen_rm.lock(), 402 BScreen *screen = new BScreen(m_screen_rm.lock(),
403 std::string("session.screen") + sc_nr, 403 std::string("screen") + sc_nr,
404 std::string("session.Screen") + sc_nr, 404 std::string("Screen") + sc_nr,
405 screens[s], ::ResourceLayer::NUM_LAYERS); 405 screens[s], ::ResourceLayer::NUM_LAYERS);
406 406
407 // already handled 407 // already handled
@@ -1155,7 +1155,7 @@ void Fluxbox::save_rc() {
1155 for (; it != it_end; ++it) { 1155 for (; it != it_end; ++it) {
1156 BScreen *screen = *it; 1156 BScreen *screen = *it;
1157 1157
1158 std::string workspaces_string("session.screen"); 1158 std::string workspaces_string("screen");
1159 workspaces_string += FbTk::StringUtil::number2String(screen->screenNumber()); 1159 workspaces_string += FbTk::StringUtil::number2String(screen->screenNumber());
1160 workspaces_string += ".workspaceNames: "; 1160 workspaces_string += ".workspaceNames: ";
1161 1161
@@ -1248,10 +1248,10 @@ void Fluxbox::load_rc(BScreen &screen) {
1248 1248
1249 std::string screen_number = FbTk::StringUtil::number2String(screen.screenNumber()); 1249 std::string screen_number = FbTk::StringUtil::number2String(screen.screenNumber());
1250 1250
1251 std::string name_lookup("session.screen"); 1251 std::string name_lookup("screen");
1252 name_lookup += screen_number; 1252 name_lookup += screen_number;
1253 name_lookup += ".workspaceNames"; 1253 name_lookup += ".workspaceNames";
1254 std::string class_lookup("session.screen"); 1254 std::string class_lookup("screen");
1255 class_lookup += screen_number; 1255 class_lookup += screen_number;
1256 class_lookup += ".WorkspaceNames"; 1256 class_lookup += ".WorkspaceNames";
1257 1257
diff --git a/src/main.cc b/src/main.cc
index 1a61ff2..6e6e47d 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -414,8 +414,8 @@ void updateConfigFilesIfNeeded(const std::string& rc_file) {
414 414
415 const int CONFIG_VERSION = 13; // TODO: move this to 'defaults.hh' or 'config.h' 415 const int CONFIG_VERSION = 13; // TODO: move this to 'defaults.hh' or 'config.h'
416 416
417 FbTk::ResourceManager r_mgr(rc_file.c_str(), false); 417 FbTk::ResourceManager r_mgr("session", "Session", rc_file.c_str(), false);
418 FbTk::IntResource c_version(r_mgr, 0, "session.configVersion", "Session.ConfigVersion"); 418 FbTk::IntResource c_version(r_mgr, 0, "configVersion", "ConfigVersion");
419 419
420 if (!r_mgr.load(rc_file.c_str())) { 420 if (!r_mgr.load(rc_file.c_str())) {
421 _FB_USES_NLS; 421 _FB_USES_NLS;