aboutsummaryrefslogtreecommitdiff
path: root/src/Screen.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Screen.cc')
-rw-r--r--src/Screen.cc85
1 files changed, 54 insertions, 31 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 8b00186..609da60 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -502,6 +502,15 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
502 // own resources we must do this. 502 // own resources we must do this.
503 fluxbox->load_rc(*this); 503 fluxbox->load_rc(*this);
504 504
505 m_windowmenu.reset(createMenu(""));
506 m_windowmenu->setInternalMenu();
507 m_windowmenu->setReloadHelper(new FbTk::AutoReloadHelper());
508 m_windowmenu->reloadHelper()->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<BScreen>(*this, &BScreen::rereadWindowMenu)));
509
510 m_rootmenu.reset(createMenu(""));
511 m_rootmenu->setReloadHelper(new FbTk::AutoReloadHelper());
512 m_rootmenu->reloadHelper()->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<BScreen>(*this, &BScreen::rereadMenu)));
513
505 m_configmenu.reset(createMenu(_FB_XTEXT(Menu, Configuration, 514 m_configmenu.reset(createMenu(_FB_XTEXT(Menu, Configuration,
506 "Configuration", "Title of configuration menu"))); 515 "Configuration", "Title of configuration menu")));
507 setupConfigmenu(*m_configmenu.get()); 516 setupConfigmenu(*m_configmenu.get());
@@ -889,8 +898,8 @@ void BScreen::cycleFocus(int options, const ClientPattern *pat, bool reverse) {
889 898
890} 899}
891 900
892FbTk::Menu *BScreen::createMenu(const string &label) { 901FbMenu *BScreen::createMenu(const string &label) {
893 FbTk::Menu *menu = new FbMenu(menuTheme(), 902 FbMenu *menu = new FbMenu(menuTheme(),
894 imageControl(), 903 imageControl(),
895 *layerManager().getLayer(Layer::MENU)); 904 *layerManager().getLayer(Layer::MENU));
896 if (!label.empty()) 905 if (!label.empty())
@@ -898,8 +907,9 @@ FbTk::Menu *BScreen::createMenu(const string &label) {
898 907
899 return menu; 908 return menu;
900} 909}
901FbTk::Menu *BScreen::createToggleMenu(const string &label) { 910
902 FbTk::Menu *menu = new ToggleMenu(menuTheme(), 911FbMenu *BScreen::createToggleMenu(const string &label) {
912 FbMenu *menu = new ToggleMenu(menuTheme(),
903 imageControl(), 913 imageControl(),
904 *layerManager().getLayer(Layer::MENU)); 914 *layerManager().getLayer(Layer::MENU));
905 if (!label.empty()) 915 if (!label.empty())
@@ -912,9 +922,7 @@ void BScreen::addExtraWindowMenu(const FbTk::FbString &label, FbTk::Menu *menu)
912 menu->setInternalMenu(); 922 menu->setInternalMenu();
913 menu->disableTitle(); 923 menu->disableTitle();
914 m_extramenus.push_back(make_pair(label, menu)); 924 m_extramenus.push_back(make_pair(label, menu));
915 // recreate window menu 925 rereadWindowMenu();
916 m_windowmenu.reset(MenuCreator::createMenuType("windowmenu", screenNumber()));
917 m_windowmenu->setInternalMenu();
918} 926}
919 927
920void BScreen::reconfigure() { 928void BScreen::reconfigure() {
@@ -956,10 +964,9 @@ void BScreen::reconfigure() {
956 } 964 }
957 } 965 }
958 966
959 //reconfigure menus 967 // update menu filenames
960 // recreate window menu 968 m_rootmenu->reloadHelper()->setMainFile(fluxbox->getMenuFilename());
961 m_windowmenu.reset(MenuCreator::createMenuType("windowmenu", screenNumber())); 969 m_windowmenu->reloadHelper()->setMainFile(windowMenuFilename());
962 m_windowmenu->setInternalMenu();
963 970
964 // reconfigure workspaces 971 // reconfigure workspaces
965 for_each(m_workspaces_list.begin(), 972 for_each(m_workspaces_list.begin(),
@@ -992,12 +999,6 @@ void BScreen::reconfigureTabs() {
992 (*it)->fbwindow()->applyDecorations(); 999 (*it)->fbwindow()->applyDecorations();
993} 1000}
994 1001
995
996void BScreen::rereadMenu() {
997 initMenu();
998 m_rootmenu->reconfigure();
999}
1000
1001void BScreen::updateWorkspaceName(unsigned int w) { 1002void BScreen::updateWorkspaceName(unsigned int w) {
1002 Workspace *space = getWorkspace(w); 1003 Workspace *space = getWorkspace(w);
1003 if (space) { 1004 if (space) {
@@ -1489,23 +1490,20 @@ void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id,
1489 1490
1490void BScreen::initMenus() { 1491void BScreen::initMenus() {
1491 m_workspacemenu.reset(MenuCreator::createMenuType("workspacemenu", screenNumber())); 1492 m_workspacemenu.reset(MenuCreator::createMenuType("workspacemenu", screenNumber()));
1492 m_windowmenu.reset(MenuCreator::createMenuType("windowmenu", screenNumber())); 1493 m_rootmenu->reloadHelper()->setMainFile(Fluxbox::instance()->getMenuFilename());
1493 m_windowmenu->setInternalMenu(); 1494 m_windowmenu->reloadHelper()->setMainFile(windowMenuFilename());
1494 initMenu();
1495} 1495}
1496 1496
1497 1497
1498void BScreen::initMenu() { 1498void BScreen::rereadMenu() {
1499 1499
1500 if (m_rootmenu.get()) { 1500 m_rootmenu->removeAll();
1501 m_rootmenu->removeAll(); 1501 m_rootmenu->setLabel("");
1502 m_rootmenu->setLabel("");
1503 } else
1504 m_rootmenu.reset(createMenu(""));
1505 1502
1506 Fluxbox * const fb = Fluxbox::instance(); 1503 Fluxbox * const fb = Fluxbox::instance();
1507 if (!fb->getMenuFilename().empty()) 1504 if (!fb->getMenuFilename().empty())
1508 MenuCreator::createFromFile(fb->getMenuFilename(), *m_rootmenu); 1505 MenuCreator::createFromFile(fb->getMenuFilename(), *m_rootmenu,
1506 m_rootmenu->reloadHelper());
1509 1507
1510 if (m_rootmenu->numberOfItems() == 0) { 1508 if (m_rootmenu->numberOfItems() == 0) {
1511 _FB_USES_NLS; 1509 _FB_USES_NLS;
@@ -1521,14 +1519,39 @@ void BScreen::initMenu() {
1521 restart_fb); 1519 restart_fb);
1522 m_rootmenu->insert(_FB_XTEXT(Menu, Exit, "Exit", "Exit command"), 1520 m_rootmenu->insert(_FB_XTEXT(Menu, Exit, "Exit", "Exit command"),
1523 exit_fb); 1521 exit_fb);
1524 // still save the menu filename, in case it becomes valid later
1525 if (!fb->getMenuFilename().empty())
1526 fb->saveMenuFilename(fb->getMenuFilename().c_str());
1527 } 1522 }
1528 1523
1529 m_rootmenu->updateMenu();
1530} 1524}
1531 1525
1526void BScreen::rereadWindowMenu() {
1527
1528 m_windowmenu->removeAll();
1529 if (!windowMenuFilename().empty())
1530 MenuCreator::createWindowMenuFromFile(windowMenuFilename(),
1531 *m_windowmenu,
1532 m_windowmenu->reloadHelper());
1533
1534 if (m_windowmenu->numberOfItems() == 0) {
1535 const char *defaults[] = {
1536 "shade",
1537 "stick",
1538 "maximize",
1539 "iconify",
1540 "raise",
1541 "lower",
1542 "sendto",
1543 "layer",
1544 "alpha",
1545 "extramenus",
1546 "separator",
1547 "close",
1548 0
1549 };
1550 for (unsigned int i=0; defaults[i]; ++i)
1551 MenuCreator::createWindowMenuItem(defaults[i], "", *m_windowmenu);
1552 }
1553
1554}
1532 1555
1533void BScreen::addConfigMenu(const FbTk::FbString &label, FbTk::Menu &menu) { 1556void BScreen::addConfigMenu(const FbTk::FbString &label, FbTk::Menu &menu) {
1534 m_configmenu_list.push_back(make_pair(label, &menu)); 1557 m_configmenu_list.push_back(make_pair(label, &menu));