diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-06-06 13:58:20 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-06-06 13:58:20 (GMT) |
commit | ac9c672a1e9f2b1665a2046d87500c1e096fb5d7 (patch) | |
tree | 95ed7adfb74a24fc360a4887298298a728dae726 /src/MenuCreator.cc | |
parent | 11a066ec1374e198fbae361aea6d8e967eefbc53 (diff) | |
download | fluxbox-ac9c672a1e9f2b1665a2046d87500c1e096fb5d7.zip fluxbox-ac9c672a1e9f2b1665a2046d87500c1e096fb5d7.tar.bz2 |
allow window menu items in ordinary menus
Diffstat (limited to 'src/MenuCreator.cc')
-rw-r--r-- | src/MenuCreator.cc | 57 |
1 files changed, 3 insertions, 54 deletions
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 | |||
351 | void 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 | |||
376 | bool getStart(FbMenuParser &parser, string &label, FbTk::StringConvertor &labelconvertor) { | 350 | bool 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 | |||
438 | void 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 | |||
462 | FbMenu *MenuCreator::createMenuType(const string &type, int screen_num) { | 411 | FbMenu *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) |