From ace3e2e6293fa0ae5a2b9d971f24fa45b317ba2e Mon Sep 17 00:00:00 2001 From: rathnor Date: Sun, 20 Jul 2003 02:45:57 +0000 Subject: fix toolbarmode = OFF bug, plus add toolbar menu back to screen's config menu --- ChangeLog | 4 ++++ src/Screen.cc | 26 +++++++++++++++++++++++++- src/Screen.hh | 11 ++++++++++- src/ToolbarHandler.cc | 19 ++++++++++++------- 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 352ce5e..10fcb44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ (Format: Year/Month/Day) Changes for 0.9.5: +*03/07/20: + * Fix crash with toolbarmode = OFF, and put toolbar menu back into + screen's configure menu (Simon) + Screen.hh/cc ToolbarHandler.cc *03/07/19: * Make most Commands execute on mouse screen rather than screen of focused window (Simon) diff --git a/src/Screen.cc b/src/Screen.cc index 2e05b9c..b3ba39a 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.204 2003/07/19 03:59:55 rathnor Exp $ +// $Id: Screen.cc,v 1.205 2003/07/20 02:45:57 rathnor Exp $ #include "Screen.hh" @@ -1940,10 +1940,29 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) { return ((menu.numberOfItems() == 0) ? true : false); } +void BScreen::addConfigMenu(const char *label, FbTk::Menu &menu) { + m_configmenu_list.push_back(std::make_pair(label, &menu)); + setupConfigmenu(*m_configmenu.get()); +} + +void BScreen::removeConfigMenu(FbTk::Menu &menu) { + Configmenus::iterator it = m_configmenu_list.begin(); + Configmenus::iterator it_end = m_configmenu_list.end(); + for (; it != it_end; ++it) { + if (it->second == &menu) { + m_configmenu_list.erase(it); + break; + } + } + setupConfigmenu(*m_configmenu.get()); +} + void BScreen::setupConfigmenu(FbTk::Menu &menu) { I18n *i18n = I18n::instance(); using namespace FBNLS; + menu.removeAll(); + FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand(); FbTk::RefCount saverc_cmd(new FbTk::SimpleCommand(*Fluxbox::instance(), &Fluxbox::save_rc)); @@ -1997,6 +2016,11 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { } #endif // SLIT + Configmenus::iterator it = m_configmenu_list.begin(); + Configmenus::iterator it_end = m_configmenu_list.end(); + for (; it != it_end; ++it) + menu.insert(it->first, it->second); + menu.insert(new BoolMenuItem(i18n->getMessage(ConfigmenuSet, ConfigmenuImageDithering, "Image Dithering"), diff --git a/src/Screen.hh b/src/Screen.hh index c4976b5..3718d92 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.hh,v 1.114 2003/07/10 11:28:24 fluxgen Exp $ +// $Id: Screen.hh,v 1.115 2003/07/20 02:45:57 rathnor Exp $ #ifndef SCREEN_HH #define SCREEN_HH @@ -310,6 +310,12 @@ public: /// updates max avaible area for the workspace void updateAvailableWorkspaceArea(); + // for extras to add menus. These menus must be marked + // internal for their safety, and the extension must + // delete and remove the menu itself + void addConfigMenu(const char *label, FbTk::Menu &menu); + void removeConfigMenu(FbTk::Menu &menu); + enum { ROWSMARTPLACEMENT = 1, COLSMARTPLACEMENT, CASCADEPLACEMENT, UNDERMOUSEPLACEMENT, LEFTRIGHT, RIGHTLEFT, TOPBOTTOM, BOTTOMTOP }; @@ -360,9 +366,12 @@ private: typedef std::list Rootmenus; typedef std::list Netizens; + typedef std::list > Configmenus; + Rootmenus m_rootmenu_list; Netizens m_netizen_list; + Configmenus m_configmenu_list; Icons m_icon_list; // This list keeps the order of window focusing for this screen diff --git a/src/ToolbarHandler.cc b/src/ToolbarHandler.cc index f5e9255..5db8f44 100644 --- a/src/ToolbarHandler.cc +++ b/src/ToolbarHandler.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ToolbarHandler.cc,v 1.23 2003/07/18 15:40:55 rathnor Exp $ +// $Id: ToolbarHandler.cc,v 1.24 2003/07/20 02:45:57 rathnor Exp $ /** * The ToolbarHandler class acts as a rough interface to the toolbar. @@ -155,6 +155,10 @@ ToolbarHandler::ToolbarHandler(BScreen &screen) m_toolbarmenu.setInternalMenu(); setupModeMenu(m_modemenu, *this); setMode(*m_rc_mode, false); // the atomhandler part will initialise it shortly + // now add this to the config menus for the screen + // (we only want it done once, so it can't go in initforscreen) + + screen.addConfigMenu("Toolbar", m_toolbarmenu); } void ToolbarHandler::setMode(ToolbarMode newmode, bool initialise) { @@ -175,7 +179,6 @@ void ToolbarHandler::setMode(ToolbarMode newmode, bool initialise) { m_toolbarmenu.removeAll(); m_toolbar.reset(new Toolbar(m_screen, *m_screen.layerManager().getLayer(Fluxbox::instance()->getNormalLayer()), m_toolbarmenu)); - Fluxbox::instance()->load_rc(m_screen); m_toolbar->reconfigure(); m_toolbarmenu.insert("Mode...", &m_modemenu); @@ -384,14 +387,16 @@ void ToolbarHandler::updateWorkspace(FluxboxWindow &win) { } void ToolbarHandler::updateCurrentWorkspace(BScreen &screen) { - if (&screen != &m_screen) + if (&screen != &m_screen || mode() == OFF) return; m_toolbar->redrawWorkspaceLabel(true); - m_toolbar->disableUpdates(); - m_toolbar->delAllIcons(true); - initForScreen(m_screen); - m_toolbar->enableUpdates(); + if (mode() != NONE) { + m_toolbar->disableUpdates(); + m_toolbar->delAllIcons(true); + initForScreen(m_screen); + m_toolbar->enableUpdates(); + } } -- cgit v0.11.2