From ac9c672a1e9f2b1665a2046d87500c1e096fb5d7 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Fri, 6 Jun 2008 06:58:20 -0700 Subject: allow window menu items in ordinary menus --- ChangeLog | 3 +++ src/FbCommands.cc | 2 ++ src/MenuCreator.cc | 57 +++--------------------------------------------------- src/MenuCreator.hh | 3 --- src/Screen.cc | 5 ++--- 5 files changed, 10 insertions(+), 60 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4750fd..8f0a6bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 1.1 +*08/06/06: + * Allow window menu items in ordinary menus (Mark) + MenuCreator.cc/hh *08/06/04: * Leave titlebar and handle borders alone with borderless windows (Mark) FbWinFrame.cc/hh 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) { fbmenu->reloadHelper()->checkReload(); } + FbMenu::setWindow(FocusControl::focusedFbWindow()); + Window root_ret; // not used Window window_ret; // not used 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, MenuCreator::startEncoding(str_cmd); } else if (str_key == "endencoding") { MenuCreator::endEncoding(); - } - else { // ok, if we didn't find any special menu item we try with command parser - // we need to attach command with arguments so command parser can parse it + } else if (!MenuCreator::createWindowMenuItem(str_key, str_label, menu)) { + // if we didn't find any special menu item we try with command parser + // we need to attach command to arguments so command parser can parse it string line = str_key + " " + str_cmd; FbTk::RefCount > command(FbTk::CommandParser::instance().parse(line)); if (*command != 0) { @@ -347,32 +347,6 @@ void translateMenuItem(FbTk::Parser &parse, ParseItem &pitem, } } - -void parseWindowMenu(FbTk::Parser &parse, FbTk::Menu &menu, - FbTk::StringConvertor &labelconvertor, - AutoReloadHelper *reloader) { - - ParseItem pitem(&menu); - while (!parse.eof()) { - pitem.load(parse, labelconvertor); - if (MenuCreator::createWindowMenuItem(pitem.key(), pitem.label(), menu)) - continue; - - if (pitem.key() == "end") - return; - if (pitem.key() == "submenu") { - FbTk::Menu *submenu = MenuCreator::createMenu(pitem.label(), menu.screenNumber()); - parseWindowMenu(parse, *submenu, labelconvertor, reloader); - submenu->updateMenu(); - menu.insert(pitem.label(), submenu); - - } else { // try non window menu specific stuff - translateMenuItem(parse, pitem, labelconvertor, reloader); - } - } -} - - bool getStart(FbMenuParser &parser, string &label, FbTk::StringConvertor &labelconvertor) { ParseItem pitem(0); while (!parser.eof()) { @@ -434,31 +408,6 @@ bool MenuCreator::createFromFile(const string &filename, return true; } - -void MenuCreator::createWindowMenuFromFile(const string &filename, - FbTk::Menu &inject_into, - AutoReloadHelper *reloader) { - string real_filename = FbTk::StringUtil::expandFilename(filename); - FbMenuParser parser(real_filename); - if (!parser.isLoaded()) - return; - - string label; - - startFile(); - if (!getStart(parser, label, m_stringconvertor)) { - endFile(); - return; - } - - if (reloader) - reloader->addFile(real_filename); - - parseWindowMenu(parser, inject_into, m_stringconvertor, reloader); - endFile(); -} - - FbMenu *MenuCreator::createMenuType(const string &type, int screen_num) { BScreen *screen = Fluxbox::instance()->findScreen(screen_num); 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: FbTk::Menu &inject_into, FbTk::AutoReloadHelper *reloader = NULL, bool begin = true); - static void createWindowMenuFromFile(const std::string &filename, - FbTk::Menu &inject_into, - FbTk::AutoReloadHelper *reloader); static bool createWindowMenuItem(const std::string &type, const std::string &label, FbTk::Menu &inject_into); 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() { m_windowmenu->removeAll(); if (!windowMenuFilename().empty()) - MenuCreator::createWindowMenuFromFile(windowMenuFilename(), - *m_windowmenu, - m_windowmenu->reloadHelper()); + MenuCreator::createFromFile(windowMenuFilename(), *m_windowmenu, + m_windowmenu->reloadHelper()); if (m_windowmenu->numberOfItems() == 0) { const char *defaults[] = { -- cgit v0.11.2