From fa15400cc24ddcfd6e361bd068ae1986b9f9e561 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Sat, 30 Apr 2011 11:32:10 +0200 Subject: Remove the Observer dependency from FbTk::Menu --- src/ClientMenu.cc | 9 +++------ src/ClientMenu.hh | 4 ++-- src/FbTk/Menu.cc | 2 +- src/FbTk/Menu.hh | 8 ++------ 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/ClientMenu.cc b/src/ClientMenu.cc index faa1d3f..4a3dacd 100644 --- a/src/ClientMenu.cc +++ b/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(subj); + if (Focusable::FocusSubject *fsubj = dynamic_cast(subj)) { Focusable &win = fsubj->win(); // find correct menu item @@ -169,6 +167,5 @@ void ClientMenu::update(FbTk::Subject *subj) { if (cl_item && fsubj == &win.dieSig()) { remove(cl_item->getIndex()); } - } else - FbTk::Menu::update(subj); + } } diff --git a/src/ClientMenu.hh b/src/ClientMenu.hh index 6b59e71..61fd198 100644 --- a/src/ClientMenu.hh +++ b/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 @@ class Focusable; * 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 Focusables; diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index da5760d..40f81c8 100644 --- a/src/FbTk/Menu.cc +++ b/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; diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 7b59cf7..bd830b4 100644 --- a/src/FbTk/Menu.hh +++ b/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 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 @@ public: protected: + void themeReconfigured(); void setTitleVisibility(bool b) { m_title_vis = b; m_need_update = true; if (!b) @@ -187,15 +186,12 @@ protected: 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 &m_theme; Menu *m_parent; -- cgit v0.11.2