allow window menu items in ordinary menus

This commit is contained in:
Mark Tiefenbruck 2008-06-06 06:58:20 -07:00
parent 11a066ec13
commit ac9c672a1e
5 changed files with 10 additions and 60 deletions

View file

@ -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

View file

@ -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

View file

@ -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<FbTk::Command<void> > command(FbTk::CommandParser<void>::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)

View file

@ -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);

View file

@ -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[] = {