diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-05-04 16:26:15 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2011-05-10 11:00:45 (GMT) |
commit | ae68b7f7cd47c91e776fadee7aecb93d5b3ee3df (patch) | |
tree | eb364477359197a8c4c84a0ae7c5cbc674076c21 | |
parent | 19ac8e40d85235328e0e2c7c428a2d3e1e86872c (diff) | |
download | fluxbox_pavel-ae68b7f7cd47c91e776fadee7aecb93d5b3ee3df.zip fluxbox_pavel-ae68b7f7cd47c91e776fadee7aecb93d5b3ee3df.tar.bz2 |
Convert Focusable::orderSig,addSig,removeSig,resetSig to FbTk::Signal
-rw-r--r-- | src/FocusableList.cc | 63 | ||||
-rw-r--r-- | src/FocusableList.hh | 33 | ||||
-rw-r--r-- | src/IconbarTool.cc | 47 | ||||
-rw-r--r-- | src/IconbarTool.hh | 8 |
4 files changed, 72 insertions, 79 deletions
diff --git a/src/FocusableList.cc b/src/FocusableList.cc index a130ec0..73d865e 100644 --- a/src/FocusableList.cc +++ b/src/FocusableList.cc | |||
@@ -125,40 +125,41 @@ void FocusableList::update(FbTk::Subject *subj) { | |||
125 | checkUpdate(**it); | 125 | checkUpdate(**it); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | if (typeid(*subj) == typeid(FocusableListSubject)) { | 128 | } |
129 | FocusableListSubject *fsubj = | 129 | |
130 | static_cast<FocusableListSubject *>(subj); | 130 | void FocusableList::parentOrderChanged(Focusable *win) { |
131 | if (subj == &m_parent->addSig()) { | 131 | if(!m_screen.isShuttingdown() && contains(*win)) { |
132 | attachSignals(*fsubj->win()); | 132 | if(insertFromParent(*win)) |
133 | if (m_pat->match(*fsubj->win())) { | 133 | m_ordersig.emit(win); |
134 | insertFromParent(*fsubj->win()); | 134 | } |
135 | m_addsig.notify(fsubj->win()); | 135 | } |
136 | } | 136 | |
137 | } else if (subj == &m_parent->removeSig()) | 137 | void FocusableList::parentWindowAdded(Focusable *win) { |
138 | remove(*fsubj->win()); | 138 | if(!m_screen.isShuttingdown()) { |
139 | else if (subj == &m_parent->resetSig()) | 139 | attachSignals(*win); |
140 | reset(); | 140 | if (m_pat->match(*win)) { |
141 | else if (subj == &m_parent->orderSig()) { | 141 | insertFromParent(*win); |
142 | Focusable *win = fsubj->win(); | 142 | m_addsig.emit(win); |
143 | if (!win || !contains(*win)) | ||
144 | return; | ||
145 | if (insertFromParent(*win)) | ||
146 | m_ordersig.notify(win); | ||
147 | } | 143 | } |
148 | } | 144 | } |
149 | } | 145 | } |
150 | 146 | ||
147 | void FocusableList::parentWindowRemoved(Focusable *win) { | ||
148 | if(!m_screen.isShuttingdown()) | ||
149 | remove(*win); | ||
150 | } | ||
151 | |||
151 | void FocusableList::checkUpdate(Focusable &win) { | 152 | void FocusableList::checkUpdate(Focusable &win) { |
152 | if (contains(win)) { | 153 | if (contains(win)) { |
153 | if (!m_pat->match(win)) { | 154 | if (!m_pat->match(win)) { |
154 | m_list.remove(&win); | 155 | m_list.remove(&win); |
155 | m_pat->removeMatch(); | 156 | m_pat->removeMatch(); |
156 | m_removesig.notify(&win); | 157 | m_removesig.emit(&win); |
157 | } | 158 | } |
158 | } else if (m_pat->match(win)) { | 159 | } else if (m_pat->match(win)) { |
159 | insertFromParent(win); | 160 | insertFromParent(win); |
160 | m_pat->addMatch(); | 161 | m_pat->addMatch(); |
161 | m_addsig.notify(&win); | 162 | m_addsig.emit(&win); |
162 | } | 163 | } |
163 | } | 164 | } |
164 | 165 | ||
@@ -203,13 +204,13 @@ void FocusableList::addMatching() { | |||
203 | void FocusableList::pushFront(Focusable &win) { | 204 | void FocusableList::pushFront(Focusable &win) { |
204 | m_list.push_front(&win); | 205 | m_list.push_front(&win); |
205 | attachSignals(win); | 206 | attachSignals(win); |
206 | m_addsig.notify(&win); | 207 | m_addsig.emit(&win); |
207 | } | 208 | } |
208 | 209 | ||
209 | void FocusableList::pushBack(Focusable &win) { | 210 | void FocusableList::pushBack(Focusable &win) { |
210 | m_list.push_back(&win); | 211 | m_list.push_back(&win); |
211 | attachSignals(win); | 212 | attachSignals(win); |
212 | m_addsig.notify(&win); | 213 | m_addsig.emit(&win); |
213 | } | 214 | } |
214 | 215 | ||
215 | void FocusableList::moveToFront(Focusable &win) { | 216 | void FocusableList::moveToFront(Focusable &win) { |
@@ -219,7 +220,7 @@ void FocusableList::moveToFront(Focusable &win) { | |||
219 | 220 | ||
220 | m_list.remove(&win); | 221 | m_list.remove(&win); |
221 | m_list.push_front(&win); | 222 | m_list.push_front(&win); |
222 | m_ordersig.notify(&win); | 223 | m_ordersig.emit(&win); |
223 | } | 224 | } |
224 | 225 | ||
225 | void FocusableList::moveToBack(Focusable &win) { | 226 | void FocusableList::moveToBack(Focusable &win) { |
@@ -229,7 +230,7 @@ void FocusableList::moveToBack(Focusable &win) { | |||
229 | 230 | ||
230 | m_list.remove(&win); | 231 | m_list.remove(&win); |
231 | m_list.push_back(&win); | 232 | m_list.push_back(&win); |
232 | m_ordersig.notify(&win); | 233 | m_ordersig.emit(&win); |
233 | } | 234 | } |
234 | 235 | ||
235 | void FocusableList::remove(Focusable &win) { | 236 | void FocusableList::remove(Focusable &win) { |
@@ -241,7 +242,7 @@ void FocusableList::remove(Focusable &win) { | |||
241 | return; | 242 | return; |
242 | } | 243 | } |
243 | m_list.remove(&win); | 244 | m_list.remove(&win); |
244 | m_removesig.notify(&win); | 245 | m_removesig.emit(&win); |
245 | } | 246 | } |
246 | 247 | ||
247 | void FocusableList::updateTitle(Focusable& win) { | 248 | void FocusableList::updateTitle(Focusable& win) { |
@@ -292,7 +293,7 @@ void FocusableList::reset() { | |||
292 | m_pat->resetMatches(); | 293 | m_pat->resetMatches(); |
293 | if (m_parent) | 294 | if (m_parent) |
294 | addMatching(); | 295 | addMatching(); |
295 | m_resetsig.notify(0); | 296 | m_resetsig.emit(); |
296 | } | 297 | } |
297 | 298 | ||
298 | bool FocusableList::contains(const Focusable &win) const { | 299 | bool FocusableList::contains(const Focusable &win) const { |
@@ -311,10 +312,10 @@ Focusable *FocusableList::find(const ClientPattern &pat) const { | |||
311 | } | 312 | } |
312 | 313 | ||
313 | void FocusableList::attachChild(FocusableList &child) const { | 314 | void FocusableList::attachChild(FocusableList &child) const { |
314 | m_addsig.attach(&child); | 315 | m_addsig.connect(FbTk::MemFun(child, &FocusableList::parentWindowAdded)); |
315 | m_removesig.attach(&child); | 316 | m_ordersig.connect(FbTk::MemFun(child, &FocusableList::parentOrderChanged)); |
316 | m_resetsig.attach(&child); | 317 | m_removesig.connect(FbTk::MemFun(child, &FocusableList::parentWindowRemoved)); |
317 | m_ordersig.attach(&child); | 318 | m_resetsig.connect(FbTk::MemFun(child, &FocusableList::reset)); |
318 | } | 319 | } |
319 | 320 | ||
320 | void FocusableList::workspaceChanged(BScreen &screen) { | 321 | void FocusableList::workspaceChanged(BScreen &screen) { |
diff --git a/src/FocusableList.hh b/src/FocusableList.hh index 6e46db9..29d536f 100644 --- a/src/FocusableList.hh +++ b/src/FocusableList.hh | |||
@@ -82,30 +82,12 @@ public: | |||
82 | @name signals | 82 | @name signals |
83 | @{ | 83 | @{ |
84 | */ | 84 | */ |
85 | FbTk::Subject &orderSig() { return m_ordersig; } | 85 | FbTk::Signal<Focusable *> &orderSig() { return m_ordersig; } |
86 | const FbTk::Subject &orderSig() const { return m_ordersig; } | 86 | FbTk::Signal<Focusable *> &addSig() { return m_addsig; } |
87 | FbTk::Subject &addSig() { return m_addsig; } | 87 | FbTk::Signal<Focusable *> &removeSig() { return m_removesig; } |
88 | const FbTk::Subject &addSig() const { return m_addsig; } | 88 | FbTk::Signal<> &resetSig() { return m_resetsig; } |
89 | FbTk::Subject &removeSig() { return m_removesig; } | ||
90 | const FbTk::Subject &removeSig() const { return m_removesig; } | ||
91 | FbTk::Subject &resetSig() { return m_resetsig; } | ||
92 | const FbTk::Subject &resetSig() const { return m_resetsig; } | ||
93 | /** @} */ // end group signals | 89 | /** @} */ // end group signals |
94 | 90 | ||
95 | /** | ||
96 | * Signaling object to attatch observers to. | ||
97 | */ | ||
98 | class FocusableListSubject: public FbTk::Subject { | ||
99 | public: | ||
100 | explicit FocusableListSubject(): m_win(0) { } | ||
101 | void notify(Focusable *win) { m_win = win; FbTk::Subject::notify(); } | ||
102 | /// @return context for this signal | ||
103 | Focusable *win() { return m_win; } | ||
104 | |||
105 | private: | ||
106 | Focusable *m_win; | ||
107 | }; | ||
108 | |||
109 | private: | 91 | private: |
110 | void init(); | 92 | void init(); |
111 | void addMatching(); | 93 | void addMatching(); |
@@ -120,13 +102,18 @@ private: | |||
120 | /// Title has changed for a window | 102 | /// Title has changed for a window |
121 | /// @param win The window that title changed for. | 103 | /// @param win The window that title changed for. |
122 | void updateTitle(Focusable& win); | 104 | void updateTitle(Focusable& win); |
105 | void parentOrderChanged(Focusable* win); | ||
106 | void parentWindowAdded(Focusable* win); | ||
107 | void parentWindowRemoved(Focusable* win); | ||
108 | |||
123 | 109 | ||
124 | std::auto_ptr<ClientPattern> m_pat; | 110 | std::auto_ptr<ClientPattern> m_pat; |
125 | const FocusableList *m_parent; | 111 | const FocusableList *m_parent; |
126 | BScreen &m_screen; | 112 | BScreen &m_screen; |
127 | std::list<Focusable *> m_list; | 113 | std::list<Focusable *> m_list; |
128 | 114 | ||
129 | mutable FocusableListSubject m_ordersig, m_addsig, m_removesig, m_resetsig; | 115 | mutable FbTk::Signal<Focusable *> m_ordersig, m_addsig, m_removesig; |
116 | mutable FbTk::Signal<> m_resetsig; | ||
130 | typedef std::map<Focusable*, FbTk::RefCount<FbTk::SignalTracker> > SignalMap; | 117 | typedef std::map<Focusable*, FbTk::RefCount<FbTk::SignalTracker> > SignalMap; |
131 | SignalMap m_signal_map; | 118 | SignalMap m_signal_map; |
132 | }; | 119 | }; |
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 42817c5..45e3a45 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc | |||
@@ -331,7 +331,7 @@ void IconbarTool::hide() { | |||
331 | 331 | ||
332 | void IconbarTool::setAlignment(FbTk::Container::Alignment align) { | 332 | void IconbarTool::setAlignment(FbTk::Container::Alignment align) { |
333 | *m_rc_alignment = align; | 333 | *m_rc_alignment = align; |
334 | update(0); | 334 | update(ALIGN, NULL); |
335 | m_menu.reconfigure(); | 335 | m_menu.reconfigure(); |
336 | } | 336 | } |
337 | 337 | ||
@@ -344,22 +344,24 @@ void IconbarTool::setMode(string mode) { | |||
344 | // lock graphics update | 344 | // lock graphics update |
345 | m_icon_container.setUpdateLock(true); | 345 | m_icon_container.setUpdateLock(true); |
346 | 346 | ||
347 | if (m_winlist.get()) { | ||
348 | m_winlist->addSig().detach(this); | ||
349 | m_winlist->removeSig().detach(this); | ||
350 | m_winlist->orderSig().detach(this); | ||
351 | m_winlist->resetSig().detach(this); | ||
352 | } | ||
353 | if (mode == "none") | 347 | if (mode == "none") |
354 | m_winlist.reset(new FocusableList(m_screen)); | 348 | m_winlist.reset(new FocusableList(m_screen)); |
355 | else | 349 | else |
356 | m_winlist.reset(new FocusableList(m_screen, | 350 | m_winlist.reset(new FocusableList(m_screen, |
357 | mode + " (iconhidden=no)")); | 351 | mode + " (iconhidden=no)")); |
358 | if (m_winlist.get()) { | 352 | if (m_winlist.get()) { |
359 | m_winlist->addSig().attach(this); | 353 | m_winlist->addSig().connect( |
360 | m_winlist->removeSig().attach(this); | 354 | std::bind1st(FbTk::MemFun(*this, &IconbarTool::update), LIST_ADD) |
361 | m_winlist->orderSig().attach(this); | 355 | ); |
362 | m_winlist->resetSig().attach(this); | 356 | m_winlist->removeSig().connect( |
357 | std::bind1st(FbTk::MemFun(*this, &IconbarTool::update), LIST_REMOVE) | ||
358 | ); | ||
359 | m_winlist->addSig().connect( | ||
360 | std::bind1st(FbTk::MemFun(*this, &IconbarTool::update), LIST_ORDER) | ||
361 | ); | ||
362 | m_winlist->resetSig().connect(FbTk::MemFunBind( | ||
363 | *this, &IconbarTool::update, LIST_RESET, static_cast<Focusable *>(0) | ||
364 | )); | ||
363 | } | 365 | } |
364 | reset(); | 366 | reset(); |
365 | 367 | ||
@@ -389,7 +391,7 @@ void IconbarTool::themeReconfigured() { | |||
389 | setMode(*m_rc_mode); | 391 | setMode(*m_rc_mode); |
390 | } | 392 | } |
391 | 393 | ||
392 | void IconbarTool::update(FbTk::Subject *subj) { | 394 | void IconbarTool::update(UpdateReason reason, Focusable *win) { |
393 | // ignore updates if we're shutting down | 395 | // ignore updates if we're shutting down |
394 | if (m_screen.isShuttingdown()) { | 396 | if (m_screen.isShuttingdown()) { |
395 | if (!m_icons.empty()) | 397 | if (!m_icons.empty()) |
@@ -405,17 +407,18 @@ void IconbarTool::update(FbTk::Subject *subj) { | |||
405 | // lock graphic update | 407 | // lock graphic update |
406 | m_icon_container.setUpdateLock(true); | 408 | m_icon_container.setUpdateLock(true); |
407 | 409 | ||
408 | if (subj && typeid(*subj) == typeid(FocusableList::FocusableListSubject)) { | 410 | switch(reason) { |
409 | FocusableList::FocusableListSubject *fsubj = | 411 | case LIST_ADD: case LIST_ORDER: |
410 | static_cast<FocusableList::FocusableListSubject *>(subj); | 412 | insertWindow(*win); |
411 | if (subj == &m_winlist->addSig()) | 413 | break; |
412 | insertWindow(*fsubj->win()); | 414 | case LIST_REMOVE: |
413 | else if (subj == &m_winlist->removeSig()) | 415 | removeWindow(*win); |
414 | removeWindow(*fsubj->win()); | 416 | break; |
415 | else if (subj == &m_winlist->resetSig()) | 417 | case LIST_RESET: |
416 | reset(); | 418 | reset(); |
417 | else if (subj == &m_winlist->orderSig()) | 419 | break; |
418 | insertWindow(*fsubj->win()); | 420 | case ALIGN: |
421 | break; | ||
419 | } | 422 | } |
420 | 423 | ||
421 | // unlock container and update graphics | 424 | // unlock container and update graphics |
diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index 92fbe63..118eacf 100644 --- a/src/IconbarTool.hh +++ b/src/IconbarTool.hh | |||
@@ -28,7 +28,6 @@ | |||
28 | 28 | ||
29 | #include "FbTk/Container.hh" | 29 | #include "FbTk/Container.hh" |
30 | #include "FbTk/CachedPixmap.hh" | 30 | #include "FbTk/CachedPixmap.hh" |
31 | #include "FbTk/Observer.hh" | ||
32 | #include "FbTk/Resource.hh" | 31 | #include "FbTk/Resource.hh" |
33 | 32 | ||
34 | #include <map> | 33 | #include <map> |
@@ -39,7 +38,7 @@ class IconButton; | |||
39 | class Focusable; | 38 | class Focusable; |
40 | class FocusableList; | 39 | class FocusableList; |
41 | 40 | ||
42 | class IconbarTool: public ToolbarItem, public FbTk::Observer { | 41 | class IconbarTool: public ToolbarItem { |
43 | public: | 42 | public: |
44 | typedef std::map<Focusable *, IconButton *> IconMap; | 43 | typedef std::map<Focusable *, IconButton *> IconMap; |
45 | 44 | ||
@@ -54,7 +53,6 @@ public: | |||
54 | void moveResize(int x, int y, | 53 | void moveResize(int x, int y, |
55 | unsigned int width, unsigned int height); | 54 | unsigned int width, unsigned int height); |
56 | 55 | ||
57 | void update(FbTk::Subject *subj); | ||
58 | void show(); | 56 | void show(); |
59 | void hide(); | 57 | void hide(); |
60 | void setAlignment(FbTk::Container::Alignment a); | 58 | void setAlignment(FbTk::Container::Alignment a); |
@@ -72,6 +70,7 @@ public: | |||
72 | 70 | ||
73 | const BScreen &screen() const { return m_screen; } | 71 | const BScreen &screen() const { return m_screen; } |
74 | private: | 72 | private: |
73 | enum UpdateReason { LIST_ORDER, LIST_ADD, LIST_REMOVE, LIST_RESET, ALIGN }; | ||
75 | 74 | ||
76 | void updateSizing(); | 75 | void updateSizing(); |
77 | 76 | ||
@@ -95,6 +94,9 @@ private: | |||
95 | /// add icons to the list | 94 | /// add icons to the list |
96 | void updateList(); | 95 | void updateList(); |
97 | 96 | ||
97 | /// called when the list emits a signal | ||
98 | void update(UpdateReason reason, Focusable *win); | ||
99 | |||
98 | void themeReconfigured(); | 100 | void themeReconfigured(); |
99 | 101 | ||
100 | BScreen &m_screen; | 102 | BScreen &m_screen; |