Remove the Observer dependency from FbTk::Menu
Pavel Labath pavelo@centrum.sk
4 files changed,
8 insertions(+),
15 deletions(-)
M
src/ClientMenu.cc
→
src/ClientMenu.cc
@@ -153,13 +153,11 @@ void ClientMenu::titleChanged(Focusable& win) {
// find correct menu item ClientMenuItem* cl_item = getMenuItem(*this, win); if (cl_item) - FbTk::Menu::update(0); + themeReconfigured(); } void ClientMenu::update(FbTk::Subject *subj) { - if (subj && typeid(*subj) == typeid(Focusable::FocusSubject)) { - - Focusable::FocusSubject *fsubj = static_cast<Focusable::FocusSubject *>(subj); + if (Focusable::FocusSubject *fsubj = dynamic_cast<Focusable::FocusSubject *>(subj)) { Focusable &win = fsubj->win(); // find correct menu item@@ -169,6 +167,5 @@ // update accordingly
if (cl_item && fsubj == &win.dieSig()) { remove(cl_item->getIndex()); } - } else - FbTk::Menu::update(subj); + } }
M
src/ClientMenu.hh
→
src/ClientMenu.hh
@@ -25,7 +25,7 @@
#include "FbMenu.hh" #include "FbTk/Signal.hh" -#include "FbTk/Subject.hh" +#include "FbTk/Observer.hh" class BScreen; class FluxboxWindow;@@ -35,7 +35,7 @@ /**
* A menu holding a set of client menus. * @see WorkspaceMenu */ -class ClientMenu: public FbMenu { +class ClientMenu: public FbMenu, public FbTk::Observer { public: typedef std::list<FluxboxWindow *> Focusables;
M
src/FbTk/Menu.cc
→
src/FbTk/Menu.cc
@@ -1233,7 +1233,7 @@ void Menu::stopHide() {
m_hide_timer.stop(); } -void Menu::update(FbTk::Subject *subj) { +void Menu::themeReconfigured() { m_need_update = true;
M
src/FbTk/Menu.hh
→
src/FbTk/Menu.hh
@@ -31,7 +31,6 @@
#include "FbString.hh" #include "FbWindow.hh" #include "EventHandler.hh" -#include "Observer.hh" #include "MenuTheme.hh" #include "Timer.hh" #include "TypeAhead.hh"@@ -44,8 +43,7 @@ class ImageControl;
template <typename T> class RefCount; /// Base class for menus -class Menu: public FbTk::EventHandler, FbTk::FbWindowRenderer, - public FbTk::Observer { +class Menu: public FbTk::EventHandler, FbTk::FbWindowRenderer { public: enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; enum { RIGHT = 1, LEFT };@@ -168,6 +166,7 @@ void renderForeground(FbWindow &win, FbDrawable &drawable);
protected: + void themeReconfigured(); void setTitleVisibility(bool b) { m_title_vis = b; m_need_update = true; if (!b)@@ -187,15 +186,12 @@ virtual void redrawFrame(FbDrawable &pm);
virtual void internal_hide(bool first = true); - virtual void update(FbTk::Subject *); - private: void openSubmenu(); void closeMenu(); void startHide(); void stopHide(); - void themeReconfigured() { update(NULL); } FbTk::ThemeProxy<MenuTheme> &m_theme; Menu *m_parent;