diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-08-04 09:02:04 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2013-02-18 21:04:25 (GMT) |
commit | 66cc0caf41cde33df4fcad250322ef744a1b234b (patch) | |
tree | 49834634301b8a3a38a871fd44493c4f011f4af5 /src/FbTk/LResource.cc | |
parent | d9be60362f364145daeaa21dcea99d0fff4c1203 (diff) | |
download | fluxbox_pavel-66cc0caf41cde33df4fcad250322ef744a1b234b.zip fluxbox_pavel-66cc0caf41cde33df4fcad250322ef744a1b234b.tar.bz2 |
Move most of the resource loading code into ResourceManager_base
I mostly do this to avoid code duplication between fluxbox and fluxbox-update_configs.
Diffstat (limited to 'src/FbTk/LResource.cc')
-rw-r--r-- | src/FbTk/LResource.cc | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/src/FbTk/LResource.cc b/src/FbTk/LResource.cc index de90b95..18209cb 100644 --- a/src/FbTk/LResource.cc +++ b/src/FbTk/LResource.cc | |||
@@ -116,34 +116,12 @@ LResourceManager::LResourceManager(const std::string &root, Lua &l, unsigned int | |||
116 | setLua(l); | 116 | setLua(l); |
117 | } | 117 | } |
118 | 118 | ||
119 | void LResourceManager::load(const std::string &filename, const std::string &fallback) { | 119 | void LResourceManager::doLoad(const std::string &filename) { |
120 | _FB_USES_NLS; | ||
121 | m_l->checkstack(1); | 120 | m_l->checkstack(1); |
122 | lua::stack_sentry s(*m_l); | 121 | lua::stack_sentry s(*m_l); |
123 | 122 | ||
124 | m_filename = filename; | 123 | m_l->loadfile(filename.c_str()); |
125 | 124 | m_l->call(0, 0); | |
126 | try { | ||
127 | m_l->loadfile(filename.c_str()); | ||
128 | m_l->call(0, 0); | ||
129 | } | ||
130 | catch(lua::exception &e) { | ||
131 | std::cerr << _FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", | ||
132 | "Failed trying to read rc file") << ":" << filename << std::endl; | ||
133 | std::cerr << "Fluxbox: " << e.what() << std::endl; | ||
134 | std::cerr << _FB_CONSOLETEXT(Fluxbox, CantLoadRCFileTrying, "Retrying with", | ||
135 | "Retrying rc file loading with (the following file)") | ||
136 | << ": " << fallback << std::endl; | ||
137 | try { | ||
138 | m_l->loadfile(fallback.c_str()); | ||
139 | m_l->call(0, 0); | ||
140 | } | ||
141 | catch(lua::exception &e) { | ||
142 | std::cerr << _FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "") | ||
143 | << ": " << fallback << std::endl; | ||
144 | std::cerr << "Fluxbox: " << e.what() << std::endl; | ||
145 | } | ||
146 | } | ||
147 | } | 125 | } |
148 | 126 | ||
149 | bool LResourceManager::save(const char *filename, const char *) { | 127 | bool LResourceManager::save(const char *filename, const char *) { |
@@ -153,8 +131,6 @@ bool LResourceManager::save(const char *filename, const char *) { | |||
153 | if(filename == NULL) | 131 | if(filename == NULL) |
154 | filename = m_filename.c_str(); | 132 | filename = m_filename.c_str(); |
155 | 133 | ||
156 | std::cerr << "XXX SAVING " << filename << std::endl; | ||
157 | |||
158 | m_l->getfield(lua::REGISTRYINDEX, dump_resources); | 134 | m_l->getfield(lua::REGISTRYINDEX, dump_resources); |
159 | m_l->getfield(lua::GLOBALSINDEX, m_root.c_str()); | 135 | m_l->getfield(lua::GLOBALSINDEX, m_root.c_str()); |
160 | m_l->pushstring(filename); | 136 | m_l->pushstring(filename); |