diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-07-01 21:30:54 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2011-07-01 21:30:54 (GMT) |
commit | f61f4d830eefff411889d9b3c1dfaa2ef95ee05d (patch) | |
tree | bae3bc00a1ac8c5b1b4f634fa4d86a2d65296db4 /src/Screen.cc | |
parent | cf91b0e81ba4b14bfc095f7bbfe17dfe8da87bb7 (diff) | |
download | fluxbox_pavel-f61f4d830eefff411889d9b3c1dfaa2ef95ee05d.zip fluxbox_pavel-f61f4d830eefff411889d9b3c1dfaa2ef95ee05d.tar.bz2 |
Convert windowmenu to lua
also, i've restored the autoreloading capability of menus.
Diffstat (limited to 'src/Screen.cc')
-rw-r--r-- | src/Screen.cc | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/Screen.cc b/src/Screen.cc index f384476..7b81469 100644 --- a/src/Screen.cc +++ b/src/Screen.cc | |||
@@ -259,7 +259,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager_base &rm, | |||
259 | click_raises(rm, true, scrname+".clickRaises"), | 259 | click_raises(rm, true, scrname+".clickRaises"), |
260 | default_deco(rm, "NORMAL", scrname+".defaultDeco"), | 260 | default_deco(rm, "NORMAL", scrname+".defaultDeco"), |
261 | tab_placement(rm, FbWinFrame::TOPLEFT, scrname+".tab.placement"), | 261 | tab_placement(rm, FbWinFrame::TOPLEFT, scrname+".tab.placement"), |
262 | windowmenufile(rm, Fluxbox::instance()->getDefaultDataFilename("windowmenu"), scrname+".windowMenu"), | 262 | windowmenufile(rm, Fluxbox::instance()->getDefaultDataFilename("windowmenu2"), scrname+".windowMenu"), |
263 | typing_delay(rm, 0, scrname+".noFocusWhileTypingDelay"), | 263 | typing_delay(rm, 0, scrname+".noFocusWhileTypingDelay"), |
264 | workspaces(rm, 4, scrname+".workspaces"), | 264 | workspaces(rm, 4, scrname+".workspaces"), |
265 | edge_snap_threshold(rm, 10, scrname+".edgeSnapThreshold"), | 265 | edge_snap_threshold(rm, 10, scrname+".edgeSnapThreshold"), |
@@ -1392,26 +1392,25 @@ void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id, | |||
1392 | } | 1392 | } |
1393 | 1393 | ||
1394 | void BScreen::initMenus() { | 1394 | void BScreen::initMenus() { |
1395 | lua::state &l = Fluxbox::instance()->lua(); | ||
1396 | m_workspacemenu.reset(MenuCreator::createMenuType("workspacemenu", screenNumber())); | 1395 | m_workspacemenu.reset(MenuCreator::createMenuType("workspacemenu", screenNumber())); |
1397 | l.loadfile(FbTk::StringUtil::expandFilename(Fluxbox::instance()->getMenuFilename()).c_str()); | 1396 | |
1398 | l.call(0, 0); | 1397 | m_rootmenu->reloadHelper()->setMainFile(Fluxbox::instance()->getMenuFilename()); |
1399 | l.getglobal("menu"); | ||
1400 | m_rootmenu = MenuCreator::createMenu(l, 0); | ||
1401 | // m_rootmenu->reloadHelper()->setMainFile(Fluxbox::instance()->getMenuFilename()); | ||
1402 | m_windowmenu->reloadHelper()->setMainFile(windowMenuFilename()); | 1398 | m_windowmenu->reloadHelper()->setMainFile(windowMenuFilename()); |
1403 | } | 1399 | } |
1404 | 1400 | ||
1405 | 1401 | ||
1406 | void BScreen::rereadMenu() { | 1402 | void BScreen::rereadMenu() { |
1407 | 1403 | ||
1408 | m_rootmenu->removeAll(); | ||
1409 | m_rootmenu->setLabel(FbTk::BiDiString("")); | ||
1410 | |||
1411 | Fluxbox * const fb = Fluxbox::instance(); | 1404 | Fluxbox * const fb = Fluxbox::instance(); |
1412 | if (!fb->getMenuFilename().empty()) | 1405 | lua::state &l = fb->lua(); |
1413 | MenuCreator::createFromFile(fb->getMenuFilename(), *m_rootmenu, | 1406 | l.checkstack(1); |
1414 | m_rootmenu->reloadHelper()); | 1407 | lua::stack_sentry s(l); |
1408 | |||
1409 | // XXX try/catch | ||
1410 | m_rootmenu->removeAll(); | ||
1411 | l.loadfile(FbTk::StringUtil::expandFilename(fb->getMenuFilename()).c_str()); | ||
1412 | l.call(0, 1); | ||
1413 | MenuCreator::createMenu(*m_rootmenu, l, screenNumber(), m_rootmenu->reloadHelper()); | ||
1415 | 1414 | ||
1416 | if (m_rootmenu->numberOfItems() == 0) { | 1415 | if (m_rootmenu->numberOfItems() == 0) { |
1417 | _FB_USES_NLS; | 1416 | _FB_USES_NLS; |
@@ -1438,12 +1437,16 @@ const std::string BScreen::windowMenuFilename() const { | |||
1438 | } | 1437 | } |
1439 | 1438 | ||
1440 | void BScreen::rereadWindowMenu() { | 1439 | void BScreen::rereadWindowMenu() { |
1440 | lua::state &l = Fluxbox::instance()->lua(); | ||
1441 | l.checkstack(1); | ||
1442 | lua::stack_sentry s(l); | ||
1441 | 1443 | ||
1442 | m_windowmenu->removeAll(); | ||
1443 | if (!windowMenuFilename().empty()) | ||
1444 | MenuCreator::createFromFile(windowMenuFilename(), *m_windowmenu, | ||
1445 | m_windowmenu->reloadHelper()); | ||
1446 | 1444 | ||
1445 | // XXX try/catch | ||
1446 | m_windowmenu->removeAll(); | ||
1447 | l.loadfile(FbTk::StringUtil::expandFilename(windowMenuFilename()).c_str()); | ||
1448 | l.call(0, 1); | ||
1449 | MenuCreator::createMenu(*m_windowmenu, l, screenNumber(), m_windowmenu->reloadHelper()); | ||
1447 | } | 1450 | } |
1448 | 1451 | ||
1449 | void BScreen::addConfigMenu(const FbTk::FbString &label, FbTk::Menu &menu) { | 1452 | void BScreen::addConfigMenu(const FbTk::FbString &label, FbTk::Menu &menu) { |