aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/LResource.cc
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-08-15 12:07:53 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-11-01 10:04:02 (GMT)
commit678a98de943963e993827540496741ae814af8bd (patch)
tree12ca6bb8baf02ce9a65e4cc7a473da9ba647333d /src/FbTk/LResource.cc
parent41e9c390274c2c84a4696fee0b5c63daae2ed6fe (diff)
downloadfluxbox_pavel-678a98de943963e993827540496741ae814af8bd.zip
fluxbox_pavel-678a98de943963e993827540496741ae814af8bd.tar.bz2
More preparation for automatic updating of config files
Diffstat (limited to 'src/FbTk/LResource.cc')
-rw-r--r--src/FbTk/LResource.cc34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/FbTk/LResource.cc b/src/FbTk/LResource.cc
index 18209cb..589e52f 100644
--- a/src/FbTk/LResource.cc
+++ b/src/FbTk/LResource.cc
@@ -89,21 +89,6 @@ namespace {
89 89
90} // anonymous namespace 90} // anonymous namespace
91 91
92void LResourceManager::convert(ResourceManager &old, const std::string &new_file) {
93 Lua l;
94
95 LResourceManager new_rm(old.root(), l);
96 for(ResourceList::const_iterator i = old.begin(); i != old.end(); ++i) {
97 // adding the resource to new_rm will set it to default value
98 // we save the value to a temp variable so we can restore it later
99 const std::string &t = (*i)->getString();
100 new_rm.addResource(**i);
101 (*i)->setFromString(t.c_str());
102 }
103
104 new_rm.save(new_file.c_str(), NULL);
105}
106
107LResourceManager::LResourceManager(const std::string &root, Lua &l, unsigned int autosave) 92LResourceManager::LResourceManager(const std::string &root, Lua &l, unsigned int autosave)
108 : ResourceManager_base(root), m_l(&l) { 93 : ResourceManager_base(root), m_l(&l) {
109 94
@@ -116,6 +101,25 @@ LResourceManager::LResourceManager(const std::string &root, Lua &l, unsigned int
116 setLua(l); 101 setLua(l);
117} 102}
118 103
104LResourceManager::LResourceManager(ResourceManager &old, Lua &l)
105 : ResourceManager_base(old.root()), m_l(&l) {
106
107 // We create a copy of the list so we can safely traverse it while the resources disassociate
108 // themselves from the old resource manager
109 ResourceList list;
110 for(ResourceList::const_iterator i = old.begin(); i != old.end(); ++i) {
111 list.push_back(*i);
112 }
113
114 for(ResourceList::const_iterator i = list.begin(); i != list.end(); ++i) {
115 // adding the resource to this resource manager will set it to default value
116 // we save the value to a temp variable so we can restore it later
117 const std::string &t = (*i)->getString();
118 (*i)->setResourceManager(*this);
119 (*i)->setFromString(t.c_str());
120 }
121}
122
119void LResourceManager::doLoad(const std::string &filename) { 123void LResourceManager::doLoad(const std::string &filename) {
120 m_l->checkstack(1); 124 m_l->checkstack(1);
121 lua::stack_sentry s(*m_l); 125 lua::stack_sentry s(*m_l);