aboutsummaryrefslogtreecommitdiff
path: root/src/MenuCreator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/MenuCreator.cc')
-rw-r--r--src/MenuCreator.cc43
1 files changed, 14 insertions, 29 deletions
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc
index 14035c0..b357dce 100644
--- a/src/MenuCreator.cc
+++ b/src/MenuCreator.cc
@@ -302,11 +302,11 @@ string getField(lua::state &l, int pos, const char *field, FbTk::StringConvertor
302} 302}
303 303
304void 304void
305createMenu_(FbMenu &inject_into, lua::state &l, int screen_number, FbTk::StringConvertor &conv, 305createMenu_(FbTk::Menu &inject_into, lua::state &l, FbTk::StringConvertor &conv,
306 FbTk::AutoReloadHelper *reloader); 306 FbTk::AutoReloadHelper *reloader);
307 307
308void 308void
309insertMenuItem(lua::state &l, FbMenu &menu, FbTk::StringConvertor &parent_conv, 309insertMenuItem(lua::state &l, FbTk::Menu &menu, FbTk::StringConvertor &parent_conv,
310 FbTk::AutoReloadHelper *reloader) { 310 FbTk::AutoReloadHelper *reloader) {
311 lua::stack_sentry s(l, -1); 311 lua::stack_sentry s(l, -1);
312 l.checkstack(1); 312 l.checkstack(1);
@@ -357,7 +357,7 @@ insertMenuItem(lua::state &l, FbMenu &menu, FbTk::StringConvertor &parent_conv,
357 } else if(str_key == "menu") { 357 } else if(str_key == "menu") {
358 std::auto_ptr<FbMenu> t(MenuCreator::createMenu("", screen_number)); 358 std::auto_ptr<FbMenu> t(MenuCreator::createMenu("", screen_number));
359 l.pushvalue(-1); 359 l.pushvalue(-1);
360 createMenu_(*t, l, screen_number, *conv, reloader); 360 createMenu_(*t, l, *conv, reloader);
361 menu.insert(str_label, t.release()); 361 menu.insert(str_label, t.release());
362 } else { 362 } else {
363 // items that have a parameter 363 // items that have a parameter
@@ -397,7 +397,7 @@ insertMenuItem(lua::state &l, FbMenu &menu, FbTk::StringConvertor &parent_conv,
397} 397}
398 398
399void 399void
400createMenu_(FbMenu &inject_into, lua::state &l, int screen_number, FbTk::StringConvertor &conv, 400createMenu_(FbTk::Menu &inject_into, lua::state &l, FbTk::StringConvertor &conv,
401 FbTk::AutoReloadHelper *reloader) { 401 FbTk::AutoReloadHelper *reloader) {
402 402
403 lua::stack_sentry s(l, -1); 403 lua::stack_sentry s(l, -1);
@@ -420,7 +420,7 @@ createMenu_(FbMenu &inject_into, lua::state &l, int screen_number, FbTk::StringC
420} // end of anonymous namespace 420} // end of anonymous namespace
421 421
422void 422void
423MenuCreator::createMenu(FbMenu &inject_into, lua::state &l, int screen_number, FbTk::AutoReloadHelper *reloader) { 423MenuCreator::createMenu(FbTk::Menu &inject_into, lua::state &l, FbTk::AutoReloadHelper *reloader) {
424 lua::stack_sentry s(l, -1); 424 lua::stack_sentry s(l, -1);
425 425
426 if(l.type(-1) != lua::TTABLE) { 426 if(l.type(-1) != lua::TTABLE) {
@@ -436,7 +436,7 @@ MenuCreator::createMenu(FbMenu &inject_into, lua::state &l, int screen_number, F
436 if(!enc.empty()) 436 if(!enc.empty())
437 conv->setSource(enc); 437 conv->setSource(enc);
438 438
439 createMenu_(inject_into, l, screen_number, *conv, reloader); 439 createMenu_(inject_into, l, *conv, reloader);
440} 440}
441 441
442 442
@@ -454,33 +454,18 @@ FbMenu *MenuCreator::createMenu(const string &label, int screen_number) {
454 return menu; 454 return menu;
455} 455}
456 456
457bool MenuCreator::createFromFile(const string &filename, 457void MenuCreator::createFromFile(const string &filename,
458 FbTk::Menu &inject_into, 458 FbTk::Menu &inject_into,
459 AutoReloadHelper *reloader, bool begin) { 459 AutoReloadHelper *reloader) {
460 string real_filename = FbTk::StringUtil::expandFilename(filename); 460 string real_filename = FbTk::StringUtil::expandFilename(filename);
461 461
462 FbMenuParser parser(real_filename); 462 lua::state &l = Fluxbox::instance()->lua();
463 if (!parser.isLoaded()) 463 l.checkstack(1);
464 return false; 464 lua::stack_sentry s(l);
465
466 startFile();
467 if (begin) {
468 string label;
469 if (!getStart(parser, label, s_stringconvertor)) {
470 endFile();
471 return false;
472 }
473 inject_into.setLabel(label);
474 }
475
476 // save menu filename, so we can check if it changes
477 if (reloader)
478 reloader->addFile(real_filename);
479
480 parseMenu(parser, inject_into, s_stringconvertor, reloader);
481 endFile();
482 465
483 return true; 466 l.loadfile(real_filename.c_str());
467 l.call(0, 1);
468 createMenu(inject_into, l, reloader);
484} 469}
485 470
486FbMenu *MenuCreator::createMenuType(const string &type, int screen_num) { 471FbMenu *MenuCreator::createMenuType(const string &type, int screen_num) {