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
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 @@ void ClientMenu::update(FbTk::Subject *subj) {
if (cl_item && fsubj == &win.dieSig()) {
remove(cl_item->getIndex());
}
} else
FbTk::Menu::update(subj);
}
}

View file

@ -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<FluxboxWindow *> Focusables;

View file

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

View file

@ -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 @@ 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<MenuTheme> &m_theme;
Menu *m_parent;