From 307da13fff916694f870ecb77aaf3ce0cf51d09e Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 17 Apr 2002 23:07:11 +0000 Subject: [PATCH] menus update their values when they are reconfigure()d. the screen, toolbar and slit rc values are reloaded in BScreen::reconfigure() before the menus. the toolbar and slit rc values are explicitly loaded in their constructors, as is BScreen's. --- src/Configmenu.cc | 27 +++++++++++++++++++++++++-- src/Configmenu.h | 15 +++++++++++---- src/Screen.cc | 11 +++++++---- src/Slit.cc | 23 ++++++++++++++++++----- src/Slit.h | 4 +++- src/Toolbar.cc | 11 ++++++++--- src/Toolbar.h | 1 + src/openbox.cc | 1 - 8 files changed, 73 insertions(+), 20 deletions(-) diff --git a/src/Configmenu.cc b/src/Configmenu.cc index 9de8864d..a12ca5ad 100644 --- a/src/Configmenu.cc +++ b/src/Configmenu.cc @@ -63,6 +63,10 @@ Configmenu::Configmenu(BScreen &scr) : Basemenu(scr), screen(scr) "Hide toolbar"), 6); update(); + setValues(); +} + +void Configmenu::setValues() { setItemSelected(2, screen.getImageControl()->doDither()); setItemSelected(3, screen.opaqueMove()); setItemSelected(4, screen.fullMax()); @@ -71,7 +75,7 @@ Configmenu::Configmenu(BScreen &scr) : Basemenu(scr), screen(scr) setItemSelected(7, screen.hideToolbar()); } -Configmenu::~Configmenu(void) { +Configmenu::~Configmenu() { delete focusmenu; delete placementmenu; } @@ -130,7 +134,8 @@ void Configmenu::itemSelected(int button, int index) { } // switch } -void Configmenu::reconfigure(void) { +void Configmenu::reconfigure() { + setValues(); focusmenu->reconfigure(); placementmenu->reconfigure(); @@ -152,12 +157,21 @@ Configmenu::Focusmenu::Focusmenu(Configmenu *cm) : Basemenu(cm->screen) { "Auto Raise"), 3); update(); + setValues(); +} + +void Configmenu::Focusmenu::setValues() { setItemSelected(0, !configmenu->screen.sloppyFocus()); setItemSelected(1, configmenu->screen.sloppyFocus()); setItemEnabled(2, configmenu->screen.sloppyFocus()); setItemSelected(2, configmenu->screen.autoRaise()); } +void Configmenu::Focusmenu::reconfigure() { + setValues(); + Basemenu::reconfigure(); +} + void Configmenu::Focusmenu::itemSelected(int button, int index) { if (button != 1) return; @@ -234,6 +248,10 @@ Configmenu::Placementmenu::Placementmenu(Configmenu *cm) : "Bottom to Top"), BScreen::BottomTop); update(); + setValues(); +} + +void Configmenu::Placementmenu::setValues() { switch (configmenu->screen.placementPolicy()) { case BScreen::RowSmartPlacement: setItemSelected(0, True); @@ -264,6 +282,11 @@ Configmenu::Placementmenu::Placementmenu(Configmenu *cm) : setItemSelected(7, !tb); } +void Configmenu::Placementmenu::reconfigure() { + setValues(); + Basemenu::reconfigure(); +} + void Configmenu::Placementmenu::itemSelected(int button, int index) { if (button != 1) return; diff --git a/src/Configmenu.h b/src/Configmenu.h index b39fac67..dd343b6a 100644 --- a/src/Configmenu.h +++ b/src/Configmenu.h @@ -38,9 +38,11 @@ private: protected: virtual void itemSelected(int, int); + virtual void setValues(); public: Focusmenu(Configmenu *); + void reconfigure(); }; class Placementmenu : public Basemenu { @@ -49,9 +51,12 @@ private: protected: virtual void itemSelected(int, int); + virtual void setValues(); + public: Placementmenu(Configmenu *); + void reconfigure(); }; BScreen &screen; @@ -63,15 +68,17 @@ private: protected: virtual void itemSelected(int, int); + virtual void setValues(); + public: Configmenu(BScreen &); - virtual ~Configmenu(void); + virtual ~Configmenu(); - inline Basemenu *getFocusmenu(void) { return focusmenu; } - inline Basemenu *getPlacementmenu(void) { return placementmenu; } + inline Basemenu *getFocusmenu() { return focusmenu; } + inline Basemenu *getPlacementmenu() { return placementmenu; } - void reconfigure(void); + void reconfigure(); }; #endif // __Configmenu_hh diff --git a/src/Screen.cc b/src/Screen.cc index 251faadd..50bc4ceb 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -249,9 +249,6 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), openbox.getSessionCursor()); workspaceNames = new LinkedList; - - load(); // load config options from Resources - workspacesList = new LinkedList; rootmenuList = new LinkedList; netizenList = new LinkedList; @@ -265,6 +262,7 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), image_control->setDither(resource.image_dither); + load(); // load config options from Resources LoadStyle(); XGCValues gcv; @@ -1040,7 +1038,8 @@ void BScreen::save() { #ifdef HAVE_STRFTIME // it deletes the current value before setting the new one, so we have to // duplicate the current value. - setStrftimeFormat(bstrdup(resource.strftime_format)); + std::string s = resource.strftime_format; + setStrftimeFormat(s.c_str()); #else // !HAVE_STRFTIME setDateFormat(resource.date_format); setClock24Hour(resource.clock24hour); @@ -1211,6 +1210,10 @@ void BScreen::load() { void BScreen::reconfigure(void) { load(); + toolbar->load(); +#ifdef SLIT + slit->load(); +#endif // SLIT LoadStyle(); XGCValues gcv; diff --git a/src/Slit.cc b/src/Slit.cc index 19796814..2fbce2d1 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -52,6 +52,7 @@ Slit::Slit(BScreen &scr, Resource &conf) : screen(scr), m_direction = Vertical; m_ontop = false; m_hidden = m_autohide = false; + load(); display = screen.getBaseDisplay().getXDisplay(); frame.window = frame.pixmap = None; @@ -314,8 +315,6 @@ void Slit::load() { } void Slit::reconfigure(void) { - load(); - frame.area.setSize(0, 0); LinkedListIterator it(clientList); SlitClient *client; @@ -710,8 +709,12 @@ Slitmenu::Slitmenu(Slit &sl) : Basemenu(sl.screen), slit(sl) { update(); - if (slit.onTop()) setItemSelected(2, True); - if (slit.autoHide()) setItemSelected(3, True); + setValues(); +} + +void Slitmenu::setValues() { + setItemSelected(2, slit.onTop()); + setItemSelected(3, slit.autoHide()); } @@ -757,6 +760,7 @@ void Slitmenu::internal_hide(void) { void Slitmenu::reconfigure(void) { + setValues(); directionmenu->reconfigure(); placementmenu->reconfigure(); @@ -776,12 +780,21 @@ Slitmenu::Directionmenu::Directionmenu(Slitmenu &sm) update(); - if (sm.slit.direction() == Slit::Horizontal) + setValues(); +} + + +void Slitmenu::Directionmenu::setValues() { + if (slitmenu.slit.direction() == Slit::Horizontal) setItemSelected(0, True); else setItemSelected(1, True); } +void Slitmenu::Directionmenu::reconfigure() { + setValues(); +} + void Slitmenu::Directionmenu::itemSelected(int button, int index) { if (button != 1) diff --git a/src/Slit.h b/src/Slit.h index cb6b454a..f7feb6b1 100644 --- a/src/Slit.h +++ b/src/Slit.h @@ -42,9 +42,11 @@ private: protected: virtual void itemSelected(int, int); + virtual void setValues(); public: Directionmenu(Slitmenu &); + void reconfigure(); }; class Placementmenu : public Basemenu { @@ -71,7 +73,7 @@ private: protected: virtual void itemSelected(int, int); virtual void internal_hide(); - + virtual void setValues(); public: Slitmenu(Slit &); diff --git a/src/Toolbar.cc b/src/Toolbar.cc index f5aa7f90..d0753aab 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -73,6 +73,7 @@ Toolbar::Toolbar(BScreen &scrn, Resource &conf) : screen(scrn), m_placement = BottomCenter; m_ontop = false; m_hidden = m_autohide = false; + load(); // get the clock updating every minute clock_timer = new BTimer(openbox, *this); @@ -1271,9 +1272,13 @@ Toolbarmenu::Toolbarmenu(Toolbar &tb) : Basemenu(tb.screen), toolbar(tb) { "Edit current workspace name"), 3); update(); + + setValues(); +} - if (toolbar.onTop()) setItemSelected(1, True); - if (toolbar.autoHide()) setItemSelected(2, True); +void Toolbarmenu::setValues() { + setItemSelected(1, toolbar.onTop()); + setItemSelected(2, toolbar.autoHide()); } @@ -1328,6 +1333,7 @@ void Toolbarmenu::internal_hide() { void Toolbarmenu::reconfigure() { + setValues(); placementmenu->reconfigure(); Basemenu::reconfigure(); @@ -1356,7 +1362,6 @@ Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu &tm) update(); } - void Toolbarmenu::Placementmenu::itemSelected(int button, int index) { if (button != 1) return; diff --git a/src/Toolbar.h b/src/Toolbar.h index ecf2fd2a..bf67b506 100644 --- a/src/Toolbar.h +++ b/src/Toolbar.h @@ -56,6 +56,7 @@ private: protected: virtual void itemSelected(int, int); virtual void internal_hide(); + virtual void setValues(); public: Toolbarmenu(Toolbar &); diff --git a/src/openbox.cc b/src/openbox.cc index c86b2124..25d274f1 100644 --- a/src/openbox.cc +++ b/src/openbox.cc @@ -1072,7 +1072,6 @@ void Openbox::real_reconfigure() { grab(); load(); - save(); for (int i = 0, n = menuTimestamps->count(); i < n; i++) { MenuTimestamp *ts = menuTimestamps->remove(0); -- 2.45.2