aboutsummaryrefslogtreecommitdiff
path: root/src/fluxbox.cc
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-06-16 19:09:37 (GMT)
committerPavel Labath <pavelo@centrum.sk>2013-02-16 23:54:31 (GMT)
commit9f2c3883b7cf08a5f9d311fd8f7fc317574b605b (patch)
tree55461e357b95ddaa582b73c840f4c5e6846b0f69 /src/fluxbox.cc
parent590efd07bb2ed1ce78ce6e5e6750b57311904f1f (diff)
downloadfluxbox_pavel-9f2c3883b7cf08a5f9d311fd8f7fc317574b605b.zip
fluxbox_pavel-9f2c3883b7cf08a5f9d311fd8f7fc317574b605b.tar.bz2
Replace ResourceManager with the lua version
Loading of an init file with the new manager works ok. Saving and restarting is still not completed. This touches many files because i removed the alternative name of resources. Unlike Xrm, lua does not have native support for alt names. It should be fairly easy to add them, but I think that is unnecessary and would be confusing.
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r--src/fluxbox.cc38
1 files changed, 11 insertions, 27 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 73d91ba..7d0fc15 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -45,7 +45,7 @@
45#include "FbTk/EventManager.hh" 45#include "FbTk/EventManager.hh"
46#include "FbTk/StringUtil.hh" 46#include "FbTk/StringUtil.hh"
47#include "FbTk/Util.hh" 47#include "FbTk/Util.hh"
48#include "FbTk/Resource.hh" 48#include "FbTk/LResource.hh"
49#include "FbTk/SimpleCommand.hh" 49#include "FbTk/SimpleCommand.hh"
50#include "FbTk/XrmDatabaseHelper.hh" 50#include "FbTk/XrmDatabaseHelper.hh"
51#include "FbTk/Command.hh" 51#include "FbTk/Command.hh"
@@ -236,10 +236,9 @@ Fluxbox::Fluxbox(int argc, char **argv,
236 const std::string& dpy_name, 236 const std::string& dpy_name,
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_l(new lua::state()),
239 m_fbatoms(FbAtoms::instance()), 240 m_fbatoms(FbAtoms::instance()),
240 m_resourcemanager("session", "Session", rc_filename.c_str(), true), 241 m_resourcemanager("session", *m_l),
241 // TODO: shouldn't need a separate one for screen
242 m_screen_rm(m_resourcemanager),
243 242
244 m_RC_PATH(rc_path), 243 m_RC_PATH(rc_path),
245 m_rc_ignoreborder(m_resourcemanager, false, "ignoreBorder", "IgnoreBorder"), 244 m_rc_ignoreborder(m_resourcemanager, false, "ignoreBorder", "IgnoreBorder"),
@@ -399,9 +398,8 @@ Fluxbox::Fluxbox(int argc, char **argv,
399 // create screens 398 // create screens
400 for (size_t s = 0; s < screens.size(); s++) { 399 for (size_t s = 0; s < screens.size(); s++) {
401 std::string sc_nr = FbTk::StringUtil::number2String(screens[s]); 400 std::string sc_nr = FbTk::StringUtil::number2String(screens[s]);
402 BScreen *screen = new BScreen(m_screen_rm.lock(), 401 BScreen *screen = new BScreen(m_resourcemanager,
403 std::string("screen") + sc_nr, 402 std::string("screen") + sc_nr,
404 std::string("Screen") + sc_nr,
405 screens[s], ::ResourceLayer::NUM_LAYERS); 403 screens[s], ::ResourceLayer::NUM_LAYERS);
406 404
407 // already handled 405 // already handled
@@ -443,20 +441,13 @@ Fluxbox::Fluxbox(int argc, char **argv,
443 441
444 m_reconfigure_wait = false; 442 m_reconfigure_wait = false;
445 443
446 m_resourcemanager.unlock();
447 ungrab(); 444 ungrab();
448 445
449 if (m_resourcemanager.lockDepth() != 0) {
450 fbdbg<<"--- resource manager lockdepth = "<<m_resourcemanager.lockDepth()<<endl;
451 }
452
453 m_starting = false; 446 m_starting = false;
454 // 447 //
455 // For dumping theme items 448 // For dumping theme items
456 // FbTk::ThemeManager::instance().listItems(); 449 // FbTk::ThemeManager::instance().listItems();
457 // 450 //
458 // m_resourcemanager.dump();
459
460} 451}
461 452
462 453
@@ -1145,7 +1136,6 @@ void Fluxbox::save_rc() {
1145 1136
1146 if (!dbfile.empty()) { 1137 if (!dbfile.empty()) {
1147 m_resourcemanager.save(dbfile.c_str(), dbfile.c_str()); 1138 m_resourcemanager.save(dbfile.c_str(), dbfile.c_str());
1148 m_screen_rm.save(dbfile.c_str(), dbfile.c_str());
1149 } else 1139 } else
1150 cerr<<_FB_CONSOLETEXT(Fluxbox, BadRCFile, "rc filename is invalid!", "Bad settings file")<<endl; 1140 cerr<<_FB_CONSOLETEXT(Fluxbox, BadRCFile, "rc filename is invalid!", "Bad settings file")<<endl;
1151 1141
@@ -1199,9 +1189,14 @@ string Fluxbox::getDefaultDataFilename(const char *name) const {
1199/// loads resources 1189/// loads resources
1200void Fluxbox::load_rc() { 1190void Fluxbox::load_rc() {
1201 _FB_USES_NLS; 1191 _FB_USES_NLS;
1192 lua::stack_sentry s(*m_l);
1202 1193
1203 string dbfile(getRcFilename()); 1194 string dbfile(getRcFilename());
1204 1195
1196 m_l->loadfile(dbfile.c_str());
1197 m_l->call(0, 0);
1198
1199 /* XXX
1205 if (!dbfile.empty()) { 1200 if (!dbfile.empty()) {
1206 if (!m_resourcemanager.load(dbfile.c_str())) { 1201 if (!m_resourcemanager.load(dbfile.c_str())) {
1207 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "Failed trying to read rc file")<<":"<<dbfile<<endl; 1202 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "Failed trying to read rc file")<<":"<<dbfile<<endl;
@@ -1212,7 +1207,7 @@ void Fluxbox::load_rc() {
1212 } else { 1207 } else {
1213 if (!m_resourcemanager.load(DEFAULT_INITFILE)) 1208 if (!m_resourcemanager.load(DEFAULT_INITFILE))
1214 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "")<<": "<<DEFAULT_INITFILE<<endl; 1209 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "")<<": "<<DEFAULT_INITFILE<<endl;
1215 } 1210 } */
1216 1211
1217 if (m_rc_menufile->empty()) 1212 if (m_rc_menufile->empty())
1218 m_rc_menufile.setDefaultValue(); 1213 m_rc_menufile.setDefaultValue();
@@ -1239,6 +1234,7 @@ void Fluxbox::load_rc(BScreen &screen) {
1239 1234
1240 XrmDatabaseHelper database; 1235 XrmDatabaseHelper database;
1241 1236
1237 // XXX make this a regular resource
1242 database = XrmGetFileDatabase(dbfile.c_str()); 1238 database = XrmGetFileDatabase(dbfile.c_str());
1243 if (database==0) 1239 if (database==0)
1244 database = XrmGetFileDatabase(DEFAULT_INITFILE); 1240 database = XrmGetFileDatabase(DEFAULT_INITFILE);
@@ -1273,18 +1269,6 @@ void Fluxbox::load_rc(BScreen &screen) {
1273 } 1269 }
1274 1270
1275 } 1271 }
1276
1277 if (!dbfile.empty()) {
1278 if (!m_screen_rm.load(dbfile.c_str())) {
1279 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "Failed trying to read rc file")<<":"<<dbfile<<endl;
1280 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFileTrying, "Retrying with", "Retrying rc file loading with (the following file)")<<": "<<DEFAULT_INITFILE<<endl;
1281 if (!m_screen_rm.load(DEFAULT_INITFILE))
1282 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "")<<": "<<DEFAULT_INITFILE<<endl;
1283 }
1284 } else {
1285 if (!m_screen_rm.load(DEFAULT_INITFILE))
1286 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "")<<": "<<DEFAULT_INITFILE<<endl;
1287 }
1288} 1272}
1289 1273
1290void Fluxbox::reconfigure() { 1274void Fluxbox::reconfigure() {