aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-06-06 13:58:20 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-06-06 13:58:20 (GMT)
commitac9c672a1e9f2b1665a2046d87500c1e096fb5d7 (patch)
tree95ed7adfb74a24fc360a4887298298a728dae726 /src
parent11a066ec1374e198fbae361aea6d8e967eefbc53 (diff)
downloadfluxbox-ac9c672a1e9f2b1665a2046d87500c1e096fb5d7.zip
fluxbox-ac9c672a1e9f2b1665a2046d87500c1e096fb5d7.tar.bz2
allow window menu items in ordinary menus
Diffstat (limited to 'src')
-rw-r--r--src/FbCommands.cc2
-rw-r--r--src/MenuCreator.cc57
-rw-r--r--src/MenuCreator.hh3
-rw-r--r--src/Screen.cc5
4 files changed, 7 insertions, 60 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index 49f727c..e70cc61 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -80,6 +80,8 @@ void showMenu(const BScreen &screen, FbTk::Menu &menu) {
80 fbmenu->reloadHelper()->checkReload(); 80 fbmenu->reloadHelper()->checkReload();
81 } 81 }
82 82
83 FbMenu::setWindow(FocusControl::focusedFbWindow());
84
83 Window root_ret; // not used 85 Window root_ret; // not used
84 Window window_ret; // not used 86 Window window_ret; // not used
85 87
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc
index 8c3ee6b..34dce94 100644
--- a/src/MenuCreator.cc
+++ b/src/MenuCreator.cc
@@ -321,9 +321,9 @@ void translateMenuItem(FbTk::Parser &parse, ParseItem &pitem,
321 MenuCreator::startEncoding(str_cmd); 321 MenuCreator::startEncoding(str_cmd);
322 } else if (str_key == "endencoding") { 322 } else if (str_key == "endencoding") {
323 MenuCreator::endEncoding(); 323 MenuCreator::endEncoding();
324 } 324 } else if (!MenuCreator::createWindowMenuItem(str_key, str_label, menu)) {
325 else { // ok, if we didn't find any special menu item we try with command parser 325 // if we didn't find any special menu item we try with command parser
326 // we need to attach command with arguments so command parser can parse it 326 // we need to attach command to arguments so command parser can parse it
327 string line = str_key + " " + str_cmd; 327 string line = str_key + " " + str_cmd;
328 FbTk::RefCount<FbTk::Command<void> > command(FbTk::CommandParser<void>::instance().parse(line)); 328 FbTk::RefCount<FbTk::Command<void> > command(FbTk::CommandParser<void>::instance().parse(line));
329 if (*command != 0) { 329 if (*command != 0) {
@@ -347,32 +347,6 @@ void translateMenuItem(FbTk::Parser &parse, ParseItem &pitem,
347 } 347 }
348} 348}
349 349
350
351void parseWindowMenu(FbTk::Parser &parse, FbTk::Menu &menu,
352 FbTk::StringConvertor &labelconvertor,
353 AutoReloadHelper *reloader) {
354
355 ParseItem pitem(&menu);
356 while (!parse.eof()) {
357 pitem.load(parse, labelconvertor);
358 if (MenuCreator::createWindowMenuItem(pitem.key(), pitem.label(), menu))
359 continue;
360
361 if (pitem.key() == "end")
362 return;
363 if (pitem.key() == "submenu") {
364 FbTk::Menu *submenu = MenuCreator::createMenu(pitem.label(), menu.screenNumber());
365 parseWindowMenu(parse, *submenu, labelconvertor, reloader);
366 submenu->updateMenu();
367 menu.insert(pitem.label(), submenu);
368
369 } else { // try non window menu specific stuff
370 translateMenuItem(parse, pitem, labelconvertor, reloader);
371 }
372 }
373}
374
375
376bool getStart(FbMenuParser &parser, string &label, FbTk::StringConvertor &labelconvertor) { 350bool getStart(FbMenuParser &parser, string &label, FbTk::StringConvertor &labelconvertor) {
377 ParseItem pitem(0); 351 ParseItem pitem(0);
378 while (!parser.eof()) { 352 while (!parser.eof()) {
@@ -434,31 +408,6 @@ bool MenuCreator::createFromFile(const string &filename,
434 return true; 408 return true;
435} 409}
436 410
437
438void MenuCreator::createWindowMenuFromFile(const string &filename,
439 FbTk::Menu &inject_into,
440 AutoReloadHelper *reloader) {
441 string real_filename = FbTk::StringUtil::expandFilename(filename);
442 FbMenuParser parser(real_filename);
443 if (!parser.isLoaded())
444 return;
445
446 string label;
447
448 startFile();
449 if (!getStart(parser, label, m_stringconvertor)) {
450 endFile();
451 return;
452 }
453
454 if (reloader)
455 reloader->addFile(real_filename);
456
457 parseWindowMenu(parser, inject_into, m_stringconvertor, reloader);
458 endFile();
459}
460
461
462FbMenu *MenuCreator::createMenuType(const string &type, int screen_num) { 411FbMenu *MenuCreator::createMenuType(const string &type, int screen_num) {
463 BScreen *screen = Fluxbox::instance()->findScreen(screen_num); 412 BScreen *screen = Fluxbox::instance()->findScreen(screen_num);
464 if (screen == 0) 413 if (screen == 0)
diff --git a/src/MenuCreator.hh b/src/MenuCreator.hh
index 8fb0242..a9fb649 100644
--- a/src/MenuCreator.hh
+++ b/src/MenuCreator.hh
@@ -43,9 +43,6 @@ public:
43 FbTk::Menu &inject_into, 43 FbTk::Menu &inject_into,
44 FbTk::AutoReloadHelper *reloader = NULL, 44 FbTk::AutoReloadHelper *reloader = NULL,
45 bool begin = true); 45 bool begin = true);
46 static void createWindowMenuFromFile(const std::string &filename,
47 FbTk::Menu &inject_into,
48 FbTk::AutoReloadHelper *reloader);
49 static bool createWindowMenuItem(const std::string &type, const std::string &label, 46 static bool createWindowMenuItem(const std::string &type, const std::string &label,
50 FbTk::Menu &inject_into); 47 FbTk::Menu &inject_into);
51 48
diff --git a/src/Screen.cc b/src/Screen.cc
index b4905f2..1525db6 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -1527,9 +1527,8 @@ void BScreen::rereadWindowMenu() {
1527 1527
1528 m_windowmenu->removeAll(); 1528 m_windowmenu->removeAll();
1529 if (!windowMenuFilename().empty()) 1529 if (!windowMenuFilename().empty())
1530 MenuCreator::createWindowMenuFromFile(windowMenuFilename(), 1530 MenuCreator::createFromFile(windowMenuFilename(), *m_windowmenu,
1531 *m_windowmenu, 1531 m_windowmenu->reloadHelper());
1532 m_windowmenu->reloadHelper());
1533 1532
1534 if (m_windowmenu->numberOfItems() == 0) { 1533 if (m_windowmenu->numberOfItems() == 0) {
1535 const char *defaults[] = { 1534 const char *defaults[] = {