Remove the Observer dependency from FbTk::Menu

This commit is contained in:
Pavel Labath 2011-04-30 11:32:10 +02:00
parent f7d7dfd2a8
commit fa15400cc2
4 changed files with 8 additions and 15 deletions

View file

@ -153,13 +153,11 @@ void ClientMenu::titleChanged(Focusable& win) {
// find correct menu item // find correct menu item
ClientMenuItem* cl_item = getMenuItem(*this, win); ClientMenuItem* cl_item = getMenuItem(*this, win);
if (cl_item) if (cl_item)
FbTk::Menu::update(0); themeReconfigured();
} }
void ClientMenu::update(FbTk::Subject *subj) { void ClientMenu::update(FbTk::Subject *subj) {
if (subj && typeid(*subj) == typeid(Focusable::FocusSubject)) { if (Focusable::FocusSubject *fsubj = dynamic_cast<Focusable::FocusSubject *>(subj)) {
Focusable::FocusSubject *fsubj = static_cast<Focusable::FocusSubject *>(subj);
Focusable &win = fsubj->win(); Focusable &win = fsubj->win();
// find correct menu item // find correct menu item
@ -169,6 +167,5 @@ void ClientMenu::update(FbTk::Subject *subj) {
if (cl_item && fsubj == &win.dieSig()) { if (cl_item && fsubj == &win.dieSig()) {
remove(cl_item->getIndex()); remove(cl_item->getIndex());
} }
} else }
FbTk::Menu::update(subj);
} }

View file

@ -25,7 +25,7 @@
#include "FbMenu.hh" #include "FbMenu.hh"
#include "FbTk/Signal.hh" #include "FbTk/Signal.hh"
#include "FbTk/Subject.hh" #include "FbTk/Observer.hh"
class BScreen; class BScreen;
class FluxboxWindow; class FluxboxWindow;
@ -35,7 +35,7 @@ class Focusable;
* A menu holding a set of client menus. * A menu holding a set of client menus.
* @see WorkspaceMenu * @see WorkspaceMenu
*/ */
class ClientMenu: public FbMenu { class ClientMenu: public FbMenu, public FbTk::Observer {
public: public:
typedef std::list<FluxboxWindow *> Focusables; typedef std::list<FluxboxWindow *> Focusables;

View file

@ -1233,7 +1233,7 @@ void Menu::stopHide() {
m_hide_timer.stop(); m_hide_timer.stop();
} }
void Menu::update(FbTk::Subject *subj) { void Menu::themeReconfigured() {
m_need_update = true; m_need_update = true;

View file

@ -31,7 +31,6 @@
#include "FbString.hh" #include "FbString.hh"
#include "FbWindow.hh" #include "FbWindow.hh"
#include "EventHandler.hh" #include "EventHandler.hh"
#include "Observer.hh"
#include "MenuTheme.hh" #include "MenuTheme.hh"
#include "Timer.hh" #include "Timer.hh"
#include "TypeAhead.hh" #include "TypeAhead.hh"
@ -44,8 +43,7 @@ class ImageControl;
template <typename T> class RefCount; template <typename T> class RefCount;
/// Base class for menus /// Base class for menus
class Menu: public FbTk::EventHandler, FbTk::FbWindowRenderer, class Menu: public FbTk::EventHandler, FbTk::FbWindowRenderer {
public FbTk::Observer {
public: public:
enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM };
enum { RIGHT = 1, LEFT }; enum { RIGHT = 1, LEFT };
@ -168,6 +166,7 @@ public:
protected: protected:
void themeReconfigured();
void setTitleVisibility(bool b) { void setTitleVisibility(bool b) {
m_title_vis = b; m_need_update = true; m_title_vis = b; m_need_update = true;
if (!b) if (!b)
@ -187,15 +186,12 @@ protected:
virtual void internal_hide(bool first = true); virtual void internal_hide(bool first = true);
virtual void update(FbTk::Subject *);
private: private:
void openSubmenu(); void openSubmenu();
void closeMenu(); void closeMenu();
void startHide(); void startHide();
void stopHide(); void stopHide();
void themeReconfigured() { update(NULL); }
FbTk::ThemeProxy<MenuTheme> &m_theme; FbTk::ThemeProxy<MenuTheme> &m_theme;
Menu *m_parent; Menu *m_parent;