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>2011-06-16 19:13:35 (GMT)
commitabe30f34b20970420b09a3b02ea98444d39afc94 (patch)
tree7aaf91f299301718f07cdac5be4e4b9b0122dab4 /src/fluxbox.cc
parent76af1583937dbf0321fe607954abbd97c266b395 (diff)
downloadfluxbox_pavel-abe30f34b20970420b09a3b02ea98444d39afc94.zip
fluxbox_pavel-abe30f34b20970420b09a3b02ea98444d39afc94.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 590a946..635f383 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"
@@ -232,10 +232,9 @@ Fluxbox::Fluxbox(int argc, char **argv,
232 const std::string& dpy_name, 232 const std::string& dpy_name,
233 const std::string& rc_path, const std::string& rc_filename, bool xsync) 233 const std::string& rc_path, const std::string& rc_filename, bool xsync)
234 : FbTk::App(dpy_name.c_str()), 234 : FbTk::App(dpy_name.c_str()),
235 m_l(new lua::state()),
235 m_fbatoms(FbAtoms::instance()), 236 m_fbatoms(FbAtoms::instance()),
236 m_resourcemanager("session", "Session", rc_filename.c_str(), true), 237 m_resourcemanager("session", *m_l),
237 // TODO: shouldn't need a separate one for screen
238 m_screen_rm(m_resourcemanager),
239 238
240 m_RC_PATH(rc_path), 239 m_RC_PATH(rc_path),
241 m_RC_INIT_FILE("init"), 240 m_RC_INIT_FILE("init"),
@@ -398,9 +397,8 @@ Fluxbox::Fluxbox(int argc, char **argv,
398 // create screens 397 // create screens
399 for (size_t s = 0; s < screens.size(); s++) { 398 for (size_t s = 0; s < screens.size(); s++) {
400 std::string sc_nr = FbTk::StringUtil::number2String(screens[s]); 399 std::string sc_nr = FbTk::StringUtil::number2String(screens[s]);
401 BScreen *screen = new BScreen(m_screen_rm.lock(), 400 BScreen *screen = new BScreen(m_resourcemanager,
402 std::string("screen") + sc_nr, 401 std::string("screen") + sc_nr,
403 std::string("Screen") + sc_nr,
404 screens[s], ::ResourceLayer::NUM_LAYERS); 402 screens[s], ::ResourceLayer::NUM_LAYERS);
405 403
406 // already handled 404 // already handled
@@ -445,20 +443,13 @@ Fluxbox::Fluxbox(int argc, char **argv,
445 443
446 m_reconfigure_wait = false; 444 m_reconfigure_wait = false;
447 445
448 m_resourcemanager.unlock();
449 ungrab(); 446 ungrab();
450 447
451 if (m_resourcemanager.lockDepth() != 0) {
452 fbdbg<<"--- resource manager lockdepth = "<<m_resourcemanager.lockDepth()<<endl;
453 }
454
455 m_starting = false; 448 m_starting = false;
456 // 449 //
457 // For dumping theme items 450 // For dumping theme items
458 // FbTk::ThemeManager::instance().listItems(); 451 // FbTk::ThemeManager::instance().listItems();
459 // 452 //
460 // m_resourcemanager.dump();
461
462} 453}
463 454
464 455
@@ -1137,7 +1128,6 @@ void Fluxbox::save_rc() {
1137 1128
1138 if (!dbfile.empty()) { 1129 if (!dbfile.empty()) {
1139 m_resourcemanager.save(dbfile.c_str(), dbfile.c_str()); 1130 m_resourcemanager.save(dbfile.c_str(), dbfile.c_str());
1140 m_screen_rm.save(dbfile.c_str(), dbfile.c_str());
1141 } else 1131 } else
1142 cerr<<_FB_CONSOLETEXT(Fluxbox, BadRCFile, "rc filename is invalid!", "Bad settings file")<<endl; 1132 cerr<<_FB_CONSOLETEXT(Fluxbox, BadRCFile, "rc filename is invalid!", "Bad settings file")<<endl;
1143 1133
@@ -1191,9 +1181,14 @@ string Fluxbox::getDefaultDataFilename(const char *name) const {
1191/// loads resources 1181/// loads resources
1192void Fluxbox::load_rc() { 1182void Fluxbox::load_rc() {
1193 _FB_USES_NLS; 1183 _FB_USES_NLS;
1184 lua::stack_sentry s(*m_l);
1194 1185
1195 string dbfile(getRcFilename()); 1186 string dbfile(getRcFilename());
1196 1187
1188 m_l->loadfile(dbfile.c_str());
1189 m_l->call(0, 0);
1190
1191 /* XXX
1197 if (!dbfile.empty()) { 1192 if (!dbfile.empty()) {
1198 if (!m_resourcemanager.load(dbfile.c_str())) { 1193 if (!m_resourcemanager.load(dbfile.c_str())) {
1199 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "Failed trying to read rc file")<<":"<<dbfile<<endl; 1194 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "Failed trying to read rc file")<<":"<<dbfile<<endl;
@@ -1204,7 +1199,7 @@ void Fluxbox::load_rc() {
1204 } else { 1199 } else {
1205 if (!m_resourcemanager.load(DEFAULT_INITFILE)) 1200 if (!m_resourcemanager.load(DEFAULT_INITFILE))
1206 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "")<<": "<<DEFAULT_INITFILE<<endl; 1201 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "")<<": "<<DEFAULT_INITFILE<<endl;
1207 } 1202 } */
1208 1203
1209 if (m_rc_menufile->empty()) 1204 if (m_rc_menufile->empty())
1210 m_rc_menufile.setDefaultValue(); 1205 m_rc_menufile.setDefaultValue();
@@ -1231,6 +1226,7 @@ void Fluxbox::load_rc(BScreen &screen) {
1231 1226
1232 XrmDatabaseHelper database; 1227 XrmDatabaseHelper database;
1233 1228
1229 // XXX make this a regular resource
1234 database = XrmGetFileDatabase(dbfile.c_str()); 1230 database = XrmGetFileDatabase(dbfile.c_str());
1235 if (database==0) 1231 if (database==0)
1236 database = XrmGetFileDatabase(DEFAULT_INITFILE); 1232 database = XrmGetFileDatabase(DEFAULT_INITFILE);
@@ -1265,18 +1261,6 @@ void Fluxbox::load_rc(BScreen &screen) {
1265 } 1261 }
1266 1262
1267 } 1263 }
1268
1269 if (!dbfile.empty()) {
1270 if (!m_screen_rm.load(dbfile.c_str())) {
1271 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "Failed trying to read rc file")<<":"<<dbfile<<endl;
1272 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFileTrying, "Retrying with", "Retrying rc file loading with (the following file)")<<": "<<DEFAULT_INITFILE<<endl;
1273 if (!m_screen_rm.load(DEFAULT_INITFILE))
1274 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "")<<": "<<DEFAULT_INITFILE<<endl;
1275 }
1276 } else {
1277 if (!m_screen_rm.load(DEFAULT_INITFILE))
1278 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "")<<": "<<DEFAULT_INITFILE<<endl;
1279 }
1280} 1264}
1281 1265
1282void Fluxbox::reconfigure() { 1266void Fluxbox::reconfigure() {