aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/FbCommands.cc2
-rw-r--r--src/MenuCreator.cc22
-rw-r--r--src/MenuCreator.hh9
-rw-r--r--src/Screen.cc2
4 files changed, 13 insertions, 22 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index 059031c..cb55469 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -348,7 +348,7 @@ void ShowCustomMenuCmd::execute() {
348 if (screen == 0) 348 if (screen == 0)
349 return; 349 return;
350 m_menu = MenuCreator::createFromFile(custom_menu_file, 350 m_menu = MenuCreator::createFromFile(custom_menu_file,
351 screen->screenNumber(), true); 351 screen->screenNumber());
352 if (!m_menu.get()) 352 if (!m_menu.get())
353 return; 353 return;
354 ::showMenu(*screen, **m_menu); 354 ::showMenu(*screen, **m_menu);
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc
index 9f20155..b420d3f 100644
--- a/src/MenuCreator.cc
+++ b/src/MenuCreator.cc
@@ -255,13 +255,13 @@ void translateMenuItem(FbTk::Parser &parse, ParseItem &pitem, FbTk::StringConver
255 if (FbTk::FileUtil::isRegularFile(thisfile.c_str()) && 255 if (FbTk::FileUtil::isRegularFile(thisfile.c_str()) &&
256 (filelist[file_index][0] != '.') && 256 (filelist[file_index][0] != '.') &&
257 (thisfile[thisfile.length() - 1] != '~')) { 257 (thisfile[thisfile.length() - 1] != '~')) {
258 MenuCreator::createFromFile(thisfile, menu, false); 258 MenuCreator::createFromFile(thisfile, menu);
259 } 259 }
260 } 260 }
261 261
262 } else { 262 } else {
263 // inject this file into the current menu 263 // inject this file into the current menu
264 MenuCreator::createFromFile(newfile, menu, false); 264 MenuCreator::createFromFile(newfile, menu);
265 } 265 }
266 266
267 safe_counter--; 267 safe_counter--;
@@ -394,7 +394,7 @@ FbTk::Menu *MenuCreator::createMenu(const string &label, int screen_number) {
394 return menu; 394 return menu;
395} 395}
396 396
397FbTk::Menu *MenuCreator::createFromFile(const string &filename, int screen_number, bool require_begin) { 397FbTk::Menu *MenuCreator::createFromFile(const string &filename, int screen_number) {
398 string real_filename = FbTk::StringUtil::expandFilename(filename); 398 string real_filename = FbTk::StringUtil::expandFilename(filename);
399 Fluxbox::instance()->saveMenuFilename(real_filename.c_str()); 399 Fluxbox::instance()->saveMenuFilename(real_filename.c_str());
400 400
@@ -404,7 +404,7 @@ FbTk::Menu *MenuCreator::createFromFile(const string &filename, int screen_numbe
404 404
405 startFile(); 405 startFile();
406 string label; 406 string label;
407 if (require_begin && !getStart(parser, label, m_stringconvertor)) { 407 if (!getStart(parser, label, m_stringconvertor)) {
408 endFile(); 408 endFile();
409 return 0; 409 return 0;
410 } 410 }
@@ -420,7 +420,7 @@ FbTk::Menu *MenuCreator::createFromFile(const string &filename, int screen_numbe
420 420
421 421
422bool MenuCreator::createFromFile(const string &filename, 422bool MenuCreator::createFromFile(const string &filename,
423 FbTk::Menu &inject_into, bool require_begin) { 423 FbTk::Menu &inject_into) {
424 string real_filename = FbTk::StringUtil::expandFilename(filename); 424 string real_filename = FbTk::StringUtil::expandFilename(filename);
425 425
426 FbMenuParser parser(real_filename); 426 FbMenuParser parser(real_filename);
@@ -428,11 +428,6 @@ bool MenuCreator::createFromFile(const string &filename,
428 return false; 428 return false;
429 429
430 startFile(); 430 startFile();
431 string label;
432 if (require_begin && !getStart(parser, label, m_stringconvertor)) {
433 endFile();
434 return false;
435 }
436 431
437 // save menu filename, so we can check if it changes 432 // save menu filename, so we can check if it changes
438 Fluxbox::instance()->saveMenuFilename(real_filename.c_str()); 433 Fluxbox::instance()->saveMenuFilename(real_filename.c_str());
@@ -445,8 +440,7 @@ bool MenuCreator::createFromFile(const string &filename,
445 440
446 441
447bool MenuCreator::createWindowMenuFromFile(const string &filename, 442bool MenuCreator::createWindowMenuFromFile(const string &filename,
448 FbTk::Menu &inject_into, 443 FbTk::Menu &inject_into) {
449 bool require_begin) {
450 string real_filename = FbTk::StringUtil::expandFilename(filename); 444 string real_filename = FbTk::StringUtil::expandFilename(filename);
451 FbMenuParser parser(real_filename); 445 FbMenuParser parser(real_filename);
452 if (!parser.isLoaded()) 446 if (!parser.isLoaded())
@@ -455,7 +449,7 @@ bool MenuCreator::createWindowMenuFromFile(const string &filename,
455 string label; 449 string label;
456 450
457 startFile(); 451 startFile();
458 if (require_begin && !getStart(parser, label, m_stringconvertor)) { 452 if (!getStart(parser, label, m_stringconvertor)) {
459 endFile(); 453 endFile();
460 return false; 454 return false;
461 } 455 }
@@ -481,7 +475,7 @@ FbTk::Menu *MenuCreator::createMenuType(const string &type, int screen_num) {
481 475
482 menu->disableTitle(); // not titlebar 476 menu->disableTitle(); // not titlebar
483 if (screen->windowMenuFilename().empty() || 477 if (screen->windowMenuFilename().empty() ||
484 ! createWindowMenuFromFile(screen->windowMenuFilename(), *menu, true)) { 478 ! createWindowMenuFromFile(screen->windowMenuFilename(), *menu)) {
485 const char *default_menu[] = { 479 const char *default_menu[] = {
486 "shade", 480 "shade",
487 "stick", 481 "stick",
diff --git a/src/MenuCreator.hh b/src/MenuCreator.hh
index c5d85ad..4494dc7 100644
--- a/src/MenuCreator.hh
+++ b/src/MenuCreator.hh
@@ -36,13 +36,10 @@ class FluxboxWindow;
36class MenuCreator { 36class MenuCreator {
37public: 37public:
38 static FbTk::Menu *createMenu(const std::string &label, int screen_num); 38 static FbTk::Menu *createMenu(const std::string &label, int screen_num);
39 static FbTk::Menu *createFromFile(const std::string &filename, int screen_num, 39 static FbTk::Menu *createFromFile(const std::string &filename, int screen_num);
40 bool require_begin);
41 static FbTk::Menu *createMenuType(const std::string &label, int screen_num); 40 static FbTk::Menu *createMenuType(const std::string &label, int screen_num);
42 static bool createFromFile(const std::string &filename, FbTk::Menu &inject_into, 41 static bool createFromFile(const std::string &filename, FbTk::Menu &inject_into);
43 bool require_begin); 42 static bool createWindowMenuFromFile(const std::string &filename, FbTk::Menu &inject_into);
44 static bool createWindowMenuFromFile(const std::string &filename, FbTk::Menu &inject_into,
45 bool require_begin);
46 static bool createWindowMenuItem(const std::string &type, const std::string &label, 43 static bool createWindowMenuItem(const std::string &type, const std::string &label,
47 FbTk::Menu &inject_into); 44 FbTk::Menu &inject_into);
48 45
diff --git a/src/Screen.cc b/src/Screen.cc
index f06fc43..7950b83 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -1518,7 +1518,7 @@ void BScreen::initMenu() {
1518 Fluxbox * const fb = Fluxbox::instance(); 1518 Fluxbox * const fb = Fluxbox::instance();
1519 if (!fb->getMenuFilename().empty()) { 1519 if (!fb->getMenuFilename().empty()) {
1520 m_rootmenu.reset(MenuCreator::createFromFile(fb->getMenuFilename(), 1520 m_rootmenu.reset(MenuCreator::createFromFile(fb->getMenuFilename(),
1521 screenNumber(), true)); 1521 screenNumber()));
1522 1522
1523 } 1523 }
1524 1524