From e1b0decf559113b43162d9e54bdbf75ee1d80b1f Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Sat, 7 May 2011 22:03:08 +0200 Subject: Convert Focusable::attentionSig to FbTk::Signal --- src/Focusable.hh | 24 ++++-------------------- src/FocusableTheme.hh | 10 +++------- src/IconButton.cc | 19 ++----------------- src/IconButton.hh | 4 +--- 4 files changed, 10 insertions(+), 47 deletions(-) diff --git a/src/Focusable.hh b/src/Focusable.hh index cf2169a..679e00b 100644 --- a/src/Focusable.hh +++ b/src/Focusable.hh @@ -24,7 +24,6 @@ #include "FbTk/PixmapWithMask.hh" #include "FbTk/ITypeAheadable.hh" -#include "FbTk/Subject.hh" #include "FbTk/Signal.hh" #include "FbTk/FbString.hh" @@ -41,7 +40,7 @@ public: m_screen(scr), m_fbwin(fbwin), m_instance_name("fluxbox"), m_class_name("fluxbox"), m_focused(false), m_attention_state(false), - m_attentionsig(*this), + m_attentionsig(), m_focussig(), m_diesig(), m_titlesig() { } @@ -62,7 +61,7 @@ public: bool getAttentionState() const { return m_attention_state; } /// @set the attention state virtual void setAttentionState(bool value) { - m_attention_state = value; attentionSig().notify(); + m_attention_state = value; attentionSig().emit(*this); } /// @return the screen in which this object resides @@ -101,19 +100,6 @@ public: virtual const FbTk::BiDiString &title() const { return m_title; } /// @return type ahead string const std::string &iTypeString() const { return title().logical(); } - /** - * Signaling object to attatch observers to. - */ - class FocusSubject: public FbTk::Subject { - public: - explicit FocusSubject(Focusable &w):m_win(w) { } - /// @return context focusable for this signal - Focusable &win() { return m_win; } - /// @return context focusable for this signal - const Focusable &win() const { return m_win; } - private: - Focusable &m_win; //< the context - }; /** @name signals @@ -126,8 +112,7 @@ public: const TitleSignal &titleSig() const { return m_titlesig; } FbTk::Signal &focusSig() { return m_focussig; } FbTk::Signal &dieSig() { return m_diesig; } - FbTk::Subject &attentionSig() { return m_attentionsig; } - const FbTk::Subject &attentionSig() const { return m_attentionsig; } + FbTk::Signal &attentionSig() { return m_attentionsig; } /** @} */ // end group signals /// Notify any listeners that the focus changed for this window. @@ -147,10 +132,9 @@ protected: bool m_attention_state; //< state of icon button while demanding attention FbTk::PixmapWithMask m_icon; //< icon pixmap with mask - // state and hint signals - FocusSubject m_attentionsig; private: + FbTk::Signal m_attentionsig; FbTk::Signal m_focussig; FbTk::Signal m_diesig; TitleSignal m_titlesig; diff --git a/src/FocusableTheme.hh b/src/FocusableTheme.hh index d379c15..df73881 100644 --- a/src/FocusableTheme.hh +++ b/src/FocusableTheme.hh @@ -23,13 +23,11 @@ #define FOCUSABLETHEME_HH #include "Focusable.hh" -#include "FbTk/Observer.hh" #include "FbTk/Theme.hh" #include "FbTk/RelaySignal.hh" template -class FocusableTheme: public FbTk::ThemeProxy, - private FbTk::Observer { +class FocusableTheme: public FbTk::ThemeProxy { public: FocusableTheme(Focusable &win, FbTk::ThemeProxy &focused, FbTk::ThemeProxy &unfocused): @@ -37,8 +35,8 @@ public: m_signals.join(m_win.focusSig(), FbTk::MemFunIgnoreArgs(m_reconfig_sig, &FbTk::Signal<>::emit)); - - m_win.attentionSig().attach(this); + m_signals.join(m_win.attentionSig(), + FbTk::MemFunIgnoreArgs(m_reconfig_sig, &FbTk::Signal<>::emit)); m_signals.join(m_focused_theme.reconfigSig(), FbTk::MemFun(m_reconfig_sig, &FbTk::Signal<>::emit)); m_signals.join(m_unfocused_theme.reconfigSig(), @@ -66,8 +64,6 @@ public: } private: - void update(FbTk::Subject *subj) { m_reconfig_sig.emit(); } - Focusable &m_win; FbTk::ThemeProxy &m_focused_theme, &m_unfocused_theme; FbTk::Signal<> m_reconfig_sig; diff --git a/src/IconButton.cc b/src/IconButton.cc index b08e51a..7c70a63 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -61,7 +61,8 @@ IconButton::IconButton(const FbTk::FbWindow &parent, m_signals.join(m_win.focusSig(), MemFunIgnoreArgs(*this, &IconButton::reconfigAndClear)); - m_win.attentionSig().attach(this); + m_signals.join(m_win.attentionSig(), + MemFunIgnoreArgs(*this, &IconButton::reconfigAndClear)); FbTk::EventManager::instance()->add(*this, m_icon_window); @@ -250,22 +251,6 @@ void IconButton::clientTitleChanged() { showTooltip(); } -void IconButton::update(FbTk::Subject *subj) { - // if the window's focus state changed, we need to update the background - if (subj == &m_win.attentionSig()) { - reconfigAndClear(); - return; - } - - // we got signal that either title or - // icon pixmap was updated, - // so we refresh everything - // if the title was changed AND the mouse is over *this, - // update the tooltip - - refreshEverything(subj != 0); -} - void IconButton::setupWindow() { m_icon_window.clear(); setText(m_win.title()); diff --git a/src/IconButton.hh b/src/IconButton.hh index d1eb17e..36781d1 100644 --- a/src/IconButton.hh +++ b/src/IconButton.hh @@ -27,7 +27,6 @@ #include "FbTk/CachedPixmap.hh" #include "FbTk/FbPixmap.hh" -#include "FbTk/Observer.hh" #include "FbTk/TextButton.hh" #include "FbTk/Signal.hh" @@ -37,7 +36,7 @@ namespace FbTk { template class ThemeProxy; } -class IconButton: public FbTk::TextButton, public FbTk::Observer { +class IconButton: public FbTk::TextButton { public: IconButton(const FbTk::FbWindow &parent, FbTk::ThemeProxy &focused_theme, @@ -58,7 +57,6 @@ public: void reconfigTheme(); - void update(FbTk::Subject *subj); void setPixmap(bool use); Focusable &win() { return m_win; } -- cgit v0.11.2