aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-05-07 20:03:08 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-05-10 11:00:46 (GMT)
commite1b0decf559113b43162d9e54bdbf75ee1d80b1f (patch)
tree21d9aeb76fe873bb97f68afdb1332991fe7da4bb
parent2073ae12a4e633d18f49559111131fffbc495dbd (diff)
downloadfluxbox_paul-e1b0decf559113b43162d9e54bdbf75ee1d80b1f.zip
fluxbox_paul-e1b0decf559113b43162d9e54bdbf75ee1d80b1f.tar.bz2
Convert Focusable::attentionSig to FbTk::Signal
-rw-r--r--src/Focusable.hh24
-rw-r--r--src/FocusableTheme.hh10
-rw-r--r--src/IconButton.cc19
-rw-r--r--src/IconButton.hh4
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 @@
24 24
25#include "FbTk/PixmapWithMask.hh" 25#include "FbTk/PixmapWithMask.hh"
26#include "FbTk/ITypeAheadable.hh" 26#include "FbTk/ITypeAheadable.hh"
27#include "FbTk/Subject.hh"
28#include "FbTk/Signal.hh" 27#include "FbTk/Signal.hh"
29#include "FbTk/FbString.hh" 28#include "FbTk/FbString.hh"
30 29
@@ -41,7 +40,7 @@ public:
41 m_screen(scr), m_fbwin(fbwin), 40 m_screen(scr), m_fbwin(fbwin),
42 m_instance_name("fluxbox"), m_class_name("fluxbox"), 41 m_instance_name("fluxbox"), m_class_name("fluxbox"),
43 m_focused(false), m_attention_state(false), 42 m_focused(false), m_attention_state(false),
44 m_attentionsig(*this), 43 m_attentionsig(),
45 m_focussig(), 44 m_focussig(),
46 m_diesig(), 45 m_diesig(),
47 m_titlesig() { } 46 m_titlesig() { }
@@ -62,7 +61,7 @@ public:
62 bool getAttentionState() const { return m_attention_state; } 61 bool getAttentionState() const { return m_attention_state; }
63 /// @set the attention state 62 /// @set the attention state
64 virtual void setAttentionState(bool value) { 63 virtual void setAttentionState(bool value) {
65 m_attention_state = value; attentionSig().notify(); 64 m_attention_state = value; attentionSig().emit(*this);
66 } 65 }
67 66
68 /// @return the screen in which this object resides 67 /// @return the screen in which this object resides
@@ -101,19 +100,6 @@ public:
101 virtual const FbTk::BiDiString &title() const { return m_title; } 100 virtual const FbTk::BiDiString &title() const { return m_title; }
102 /// @return type ahead string 101 /// @return type ahead string
103 const std::string &iTypeString() const { return title().logical(); } 102 const std::string &iTypeString() const { return title().logical(); }
104 /**
105 * Signaling object to attatch observers to.
106 */
107 class FocusSubject: public FbTk::Subject {
108 public:
109 explicit FocusSubject(Focusable &w):m_win(w) { }
110 /// @return context focusable for this signal
111 Focusable &win() { return m_win; }
112 /// @return context focusable for this signal
113 const Focusable &win() const { return m_win; }
114 private:
115 Focusable &m_win; //< the context
116 };
117 103
118 /** 104 /**
119 @name signals 105 @name signals
@@ -126,8 +112,7 @@ public:
126 const TitleSignal &titleSig() const { return m_titlesig; } 112 const TitleSignal &titleSig() const { return m_titlesig; }
127 FbTk::Signal<Focusable&> &focusSig() { return m_focussig; } 113 FbTk::Signal<Focusable&> &focusSig() { return m_focussig; }
128 FbTk::Signal<Focusable&> &dieSig() { return m_diesig; } 114 FbTk::Signal<Focusable&> &dieSig() { return m_diesig; }
129 FbTk::Subject &attentionSig() { return m_attentionsig; } 115 FbTk::Signal<Focusable&> &attentionSig() { return m_attentionsig; }
130 const FbTk::Subject &attentionSig() const { return m_attentionsig; }
131 /** @} */ // end group signals 116 /** @} */ // end group signals
132 117
133 /// Notify any listeners that the focus changed for this window. 118 /// Notify any listeners that the focus changed for this window.
@@ -147,10 +132,9 @@ protected:
147 bool m_attention_state; //< state of icon button while demanding attention 132 bool m_attention_state; //< state of icon button while demanding attention
148 FbTk::PixmapWithMask m_icon; //< icon pixmap with mask 133 FbTk::PixmapWithMask m_icon; //< icon pixmap with mask
149 134
150 // state and hint signals
151 FocusSubject m_attentionsig;
152 135
153private: 136private:
137 FbTk::Signal<Focusable&> m_attentionsig;
154 FbTk::Signal<Focusable&> m_focussig; 138 FbTk::Signal<Focusable&> m_focussig;
155 FbTk::Signal<Focusable&> m_diesig; 139 FbTk::Signal<Focusable&> m_diesig;
156 TitleSignal m_titlesig; 140 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 @@
23#define FOCUSABLETHEME_HH 23#define FOCUSABLETHEME_HH
24 24
25#include "Focusable.hh" 25#include "Focusable.hh"
26#include "FbTk/Observer.hh"
27#include "FbTk/Theme.hh" 26#include "FbTk/Theme.hh"
28#include "FbTk/RelaySignal.hh" 27#include "FbTk/RelaySignal.hh"
29 28
30template <typename BaseTheme> 29template <typename BaseTheme>
31class FocusableTheme: public FbTk::ThemeProxy<BaseTheme>, 30class FocusableTheme: public FbTk::ThemeProxy<BaseTheme> {
32 private FbTk::Observer {
33public: 31public:
34 FocusableTheme(Focusable &win, FbTk::ThemeProxy<BaseTheme> &focused, 32 FocusableTheme(Focusable &win, FbTk::ThemeProxy<BaseTheme> &focused,
35 FbTk::ThemeProxy<BaseTheme> &unfocused): 33 FbTk::ThemeProxy<BaseTheme> &unfocused):
@@ -37,8 +35,8 @@ public:
37 35
38 m_signals.join(m_win.focusSig(), 36 m_signals.join(m_win.focusSig(),
39 FbTk::MemFunIgnoreArgs(m_reconfig_sig, &FbTk::Signal<>::emit)); 37 FbTk::MemFunIgnoreArgs(m_reconfig_sig, &FbTk::Signal<>::emit));
40 38 m_signals.join(m_win.attentionSig(),
41 m_win.attentionSig().attach(this); 39 FbTk::MemFunIgnoreArgs(m_reconfig_sig, &FbTk::Signal<>::emit));
42 m_signals.join(m_focused_theme.reconfigSig(), 40 m_signals.join(m_focused_theme.reconfigSig(),
43 FbTk::MemFun(m_reconfig_sig, &FbTk::Signal<>::emit)); 41 FbTk::MemFun(m_reconfig_sig, &FbTk::Signal<>::emit));
44 m_signals.join(m_unfocused_theme.reconfigSig(), 42 m_signals.join(m_unfocused_theme.reconfigSig(),
@@ -66,8 +64,6 @@ public:
66 } 64 }
67 65
68private: 66private:
69 void update(FbTk::Subject *subj) { m_reconfig_sig.emit(); }
70
71 Focusable &m_win; 67 Focusable &m_win;
72 FbTk::ThemeProxy<BaseTheme> &m_focused_theme, &m_unfocused_theme; 68 FbTk::ThemeProxy<BaseTheme> &m_focused_theme, &m_unfocused_theme;
73 FbTk::Signal<> m_reconfig_sig; 69 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,
61 m_signals.join(m_win.focusSig(), 61 m_signals.join(m_win.focusSig(),
62 MemFunIgnoreArgs(*this, &IconButton::reconfigAndClear)); 62 MemFunIgnoreArgs(*this, &IconButton::reconfigAndClear));
63 63
64 m_win.attentionSig().attach(this); 64 m_signals.join(m_win.attentionSig(),
65 MemFunIgnoreArgs(*this, &IconButton::reconfigAndClear));
65 66
66 FbTk::EventManager::instance()->add(*this, m_icon_window); 67 FbTk::EventManager::instance()->add(*this, m_icon_window);
67 68
@@ -250,22 +251,6 @@ void IconButton::clientTitleChanged() {
250 showTooltip(); 251 showTooltip();
251} 252}
252 253
253void IconButton::update(FbTk::Subject *subj) {
254 // if the window's focus state changed, we need to update the background
255 if (subj == &m_win.attentionSig()) {
256 reconfigAndClear();
257 return;
258 }
259
260 // we got signal that either title or
261 // icon pixmap was updated,
262 // so we refresh everything
263 // if the title was changed AND the mouse is over *this,
264 // update the tooltip
265
266 refreshEverything(subj != 0);
267}
268
269void IconButton::setupWindow() { 254void IconButton::setupWindow() {
270 m_icon_window.clear(); 255 m_icon_window.clear();
271 setText(m_win.title()); 256 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 @@
27 27
28#include "FbTk/CachedPixmap.hh" 28#include "FbTk/CachedPixmap.hh"
29#include "FbTk/FbPixmap.hh" 29#include "FbTk/FbPixmap.hh"
30#include "FbTk/Observer.hh"
31#include "FbTk/TextButton.hh" 30#include "FbTk/TextButton.hh"
32#include "FbTk/Signal.hh" 31#include "FbTk/Signal.hh"
33 32
@@ -37,7 +36,7 @@ namespace FbTk {
37template <class T> class ThemeProxy; 36template <class T> class ThemeProxy;
38} 37}
39 38
40class IconButton: public FbTk::TextButton, public FbTk::Observer { 39class IconButton: public FbTk::TextButton {
41public: 40public:
42 IconButton(const FbTk::FbWindow &parent, 41 IconButton(const FbTk::FbWindow &parent,
43 FbTk::ThemeProxy<IconbarTheme> &focused_theme, 42 FbTk::ThemeProxy<IconbarTheme> &focused_theme,
@@ -58,7 +57,6 @@ public:
58 57
59 void reconfigTheme(); 58 void reconfigTheme();
60 59
61 void update(FbTk::Subject *subj);
62 void setPixmap(bool use); 60 void setPixmap(bool use);
63 61
64 Focusable &win() { return m_win; } 62 Focusable &win() { return m_win; }