From 9128a64e62e733fcd008dd1018c76b883e20079f Mon Sep 17 00:00:00 2001 From: rathnor Date: Mon, 4 Oct 2004 15:37:58 +0000 Subject: don't require [begin] in included files --- ChangeLog | 2 ++ src/MenuCreator.cc | 20 ++++++++++---------- src/MenuCreator.hh | 5 +++-- src/Screen.cc | 4 ++-- src/Window.cc | 4 ++-- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 073d536..eb97024 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ (Format: Year/Month/Day) Changes for 0.9.11 *04/10/04: + * Don't require [begin] tag for included menu files (Simon) + MenuCreator.hh/cc Screen.cc Window.cc * Fix handling of setlocale return (Thanks Victor Yegorov) FbTk/XmbFontImp.cc *04/09/30: diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 4a72fae..964fc74 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MenuCreator.cc,v 1.16 2004/09/16 14:08:46 rathnor Exp $ +// $Id: MenuCreator.cc,v 1.17 2004/10/04 15:37:58 rathnor Exp $ #include "MenuCreator.hh" @@ -244,14 +244,14 @@ static void translateMenuItem(Parser &parse, ParseItem &pitem) { if (FbTk::Directory::isRegularFile(thisfile) && (filelist[file_index][0] != '.') && (thisfile[thisfile.length() - 1] != '~')) { - MenuCreator::createFromFile(thisfile, menu); + MenuCreator::createFromFile(thisfile, menu, false); Fluxbox::instance()->saveMenuFilename(thisfile.c_str()); } } } else { // inject this file into the current menu - MenuCreator::createFromFile(newfile, menu); + MenuCreator::createFromFile(newfile, menu, false); Fluxbox::instance()->saveMenuFilename(newfile.c_str()); } @@ -379,7 +379,7 @@ bool getStart(FbMenuParser &parser, std::string &label) { return true; } -FbTk::Menu *MenuCreator::createFromFile(const std::string &filename, int screen_number) { +FbTk::Menu *MenuCreator::createFromFile(const std::string &filename, int screen_number, bool require_begin) { std::string real_filename = FbTk::StringUtil::expandFilename(filename); FbMenuParser parser(real_filename); if (!parser.isLoaded()) @@ -388,7 +388,7 @@ FbTk::Menu *MenuCreator::createFromFile(const std::string &filename, int screen_ Fluxbox::instance()->saveMenuFilename(real_filename.c_str()); std::string label; - if (!getStart(parser, label)) + if (require_begin && !getStart(parser, label)) return 0; FbTk::Menu *menu = createMenu(label, screen_number); @@ -399,8 +399,8 @@ FbTk::Menu *MenuCreator::createFromFile(const std::string &filename, int screen_ } -bool MenuCreator::createFromFile(const std::string &filename, - FbTk::Menu &inject_into) { +bool MenuCreator::createFromFile(const std::string &filename, + FbTk::Menu &inject_into, bool require_begin) { std::string real_filename = FbTk::StringUtil::expandFilename(filename); FbMenuParser parser(real_filename); @@ -408,7 +408,7 @@ bool MenuCreator::createFromFile(const std::string &filename, return false; std::string label; - if (!getStart(parser, label)) + if (require_begin && !getStart(parser, label)) return false; parseMenu(parser, inject_into); @@ -418,7 +418,7 @@ bool MenuCreator::createFromFile(const std::string &filename, bool MenuCreator::createFromFile(const std::string &filename, FbTk::Menu &inject_into, - FluxboxWindow &win) { + FluxboxWindow &win, bool require_begin) { std::string real_filename = FbTk::StringUtil::expandFilename(filename); FbMenuParser parser(real_filename); if (!parser.isLoaded()) @@ -426,7 +426,7 @@ bool MenuCreator::createFromFile(const std::string &filename, std::string label; - if (!getStart(parser, label)) + if (require_begin && !getStart(parser, label)) return false; parseWindowMenu(parser, inject_into, win); diff --git a/src/MenuCreator.hh b/src/MenuCreator.hh index f916bfd..8e51948 100644 --- a/src/MenuCreator.hh +++ b/src/MenuCreator.hh @@ -36,9 +36,10 @@ public: static FbTk::Menu *createMenu(const std::string &label, int screen_num); static FbTk::Menu *createFromFile(const std::string &filename, int screen_num); static FbTk::Menu *createMenuType(const std::string &label, int screen_num); - static bool createFromFile(const std::string &filename, FbTk::Menu &inject_into); + static bool createFromFile(const std::string &filename, FbTk::Menu &inject_into, + bool require_begin); static bool createFromFile(const std::string &filename, FbTk::Menu &inject_into, - FluxboxWindow &win); + FluxboxWindow &win, bool require_begin); static bool createWindowMenuItem(const std::string &type, const std::string &label, FbTk::Menu &inject_into, FluxboxWindow &win); }; diff --git a/src/Screen.cc b/src/Screen.cc index e06d071..24e75b0 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.293 2004/09/16 10:10:36 fluxgen Exp $ +// $Id: Screen.cc,v 1.294 2004/10/04 15:37:58 rathnor Exp $ #include "Screen.hh" @@ -1670,7 +1670,7 @@ void BScreen::initMenu() { Fluxbox * const fb = Fluxbox::instance(); if (fb->getMenuFilename().size() > 0) { m_rootmenu.reset(MenuCreator::createFromFile(fb->getMenuFilename(), - screenNumber())); + screenNumber(), true)); } diff --git a/src/Window.cc b/src/Window.cc index 2185a2b..e95629d 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.300 2004/09/30 18:45:26 akir Exp $ +// $Id: Window.cc,v 1.301 2004/10/04 15:37:58 rathnor Exp $ #include "Window.hh" @@ -3583,7 +3583,7 @@ void FluxboxWindow::setupMenu() { menu().disableTitle(); // not titlebar if (screen().windowMenuFilename().empty() || - ! MenuCreator::createFromFile(screen().windowMenuFilename(), menu(), *this)) + ! MenuCreator::createFromFile(screen().windowMenuFilename(), menu(), *this, true)) { MenuCreator::createWindowMenuItem("shade", "", menu(), *this); -- cgit v0.11.2