aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/LResource.cc
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-06-12 18:24:14 (GMT)
committerPavel Labath <pavelo@centrum.sk>2013-02-16 23:51:49 (GMT)
commitfd3886025a9715a9d82319ebb6220925cf3f2744 (patch)
treef7decf26064ff82bccbdc46709a2a9f45a05a9e9 /src/FbTk/LResource.cc
parent28cce15aa3bd123e2875d4f76d2dbae7c4c3b233 (diff)
downloadfluxbox_pavel-fd3886025a9715a9d82319ebb6220925cf3f2744.zip
fluxbox_pavel-fd3886025a9715a9d82319ebb6220925cf3f2744.tar.bz2
Add a function for converting from XResources to lua ones
Diffstat (limited to 'src/FbTk/LResource.cc')
-rw-r--r--src/FbTk/LResource.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/FbTk/LResource.cc b/src/FbTk/LResource.cc
index 78511eb..2e2a7c7 100644
--- a/src/FbTk/LResource.cc
+++ b/src/FbTk/LResource.cc
@@ -82,6 +82,22 @@ void LResourceManager::initState(lua::state &l) {
82 l.setfield(lua::REGISTRYINDEX, make_root); 82 l.setfield(lua::REGISTRYINDEX, make_root);
83} 83}
84 84
85void LResourceManager::convert(ResourceManager &old, const std::string &new_file) {
86 lua::state l;
87 initState(l);
88
89 LResourceManager new_rm(old.root(), l);
90 for(ResourceList::const_iterator i = old.begin(); i != old.end(); ++i) {
91 // adding the resource to new_rm will set it to default value
92 // we save the value to a temp variable so we can restore it later
93 const std::string &t = (*i)->getString();
94 new_rm.addResource(**i);
95 (*i)->setFromString(t.c_str());
96 }
97
98 new_rm.save(new_file.c_str(), NULL);
99}
100
85LResourceManager::LResourceManager(const std::string &root, lua::state &l) 101LResourceManager::LResourceManager(const std::string &root, lua::state &l)
86 : ResourceManager_base(root), m_l(&l) { 102 : ResourceManager_base(root), m_l(&l) {
87 l.checkstack(2); 103 l.checkstack(2);