aboutsummaryrefslogtreecommitdiff
path: root/src/Toolbar.cc
diff options
context:
space:
mode:
authorHenrik Kinnunen <fluxgen@fluxbox.org>2008-04-27 19:22:18 (GMT)
committerHenrik Kinnunen <fluxgen@fluxbox.org>2008-04-27 19:22:18 (GMT)
commit80b10f7772b91f1f4a61eace4e5235a79060e1f0 (patch)
tree27057e59c41188e7c2f724614233265fed03c9b3 /src/Toolbar.cc
parent40e17b4d0ef1b9503f21509e697dd4dcb24d2bbf (diff)
downloadfluxbox-80b10f7772b91f1f4a61eace4e5235a79060e1f0.zip
fluxbox-80b10f7772b91f1f4a61eace4e5235a79060e1f0.tar.bz2
Added SimpleObserver class.
This class works in the same way as the SimpleCommand class. Use it with the makeObserver function. It calls the receiver's member function when the subject sends a signal.
Diffstat (limited to 'src/Toolbar.cc')
-rw-r--r--src/Toolbar.cc37
1 files changed, 16 insertions, 21 deletions
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index 26d87a8..540ceb9 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -50,7 +50,7 @@
50#include "FbTk/BoolMenuItem.hh" 50#include "FbTk/BoolMenuItem.hh"
51#include "FbTk/IntMenuItem.hh" 51#include "FbTk/IntMenuItem.hh"
52#include "FbTk/Shape.hh" 52#include "FbTk/Shape.hh"
53 53#include "FbTk/SimpleObserver.hh"
54 54
55// use GNU extensions 55// use GNU extensions
56#ifndef _GNU_SOURCE 56#ifndef _GNU_SOURCE
@@ -240,11 +240,15 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width):
240 m_shape(new FbTk::Shape(frame.window, 0)), 240 m_shape(new FbTk::Shape(frame.window, 0)),
241 m_resize_lock(false) { 241 m_resize_lock(false) {
242 _FB_USES_NLS; 242 _FB_USES_NLS;
243 // NOTE: first subject is always the rearrangeItem !
244 m_observers.push_back(makeObserver(*this, &Toolbar::rearrangeItems));
243 // we need to get notified when the theme is reloaded 245 // we need to get notified when the theme is reloaded
244 m_theme.reconfigSig().attach(this); 246 m_observers.push_back(makeObserver(*this, &Toolbar::reconfigure));
247 m_theme.reconfigSig().attach(m_observers.back());
248 screen().reconfigureSig().attach(m_observers.back()); // get this on antialias change
245 // listen to screen size changes 249 // listen to screen size changes
246 screen().resizeSig().attach(this); 250 screen().resizeSig().attach(m_observers.back());
247 screen().reconfigureSig().attach(this); // get this on antialias change 251
248 252
249 moveToLayer((*m_rc_layernum).getNum()); 253 moveToLayer((*m_rc_layernum).getNum());
250 254
@@ -370,6 +374,7 @@ void Toolbar::lower() {
370} 374}
371 375
372void Toolbar::reconfigure() { 376void Toolbar::reconfigure() {
377
373 updateVisibleState(); 378 updateVisibleState();
374 379
375 if (!doAutoHide() && isHidden()) 380 if (!doAutoHide() && isHidden())
@@ -426,7 +431,8 @@ void Toolbar::reconfigure() {
426 if (item == 0) 431 if (item == 0)
427 continue; 432 continue;
428 m_item_list.push_back(item); 433 m_item_list.push_back(item);
429 item->resizeSig().attach(this); 434 // attach to first observer ( which must be rearrangeItems )
435 item->resizeSig().attach(m_observers[0]);
430 436
431 } 437 }
432 // show all items 438 // show all items
@@ -515,6 +521,11 @@ void Toolbar::reconfigure() {
515 // area to be reserved on screen 521 // area to be reserved on screen
516 updateStrut(); 522 updateStrut();
517 523
524#ifdef XINERAMA
525 if (m_xineramaheadmenu)
526 m_xineramaheadmenu->reloadHeads();
527#endif // XINERAMA
528
518} 529}
519 530
520 531
@@ -613,22 +624,6 @@ void Toolbar::handleEvent(XEvent &event) {
613*/ 624*/
614} 625}
615 626
616void Toolbar::update(FbTk::Subject *subj) {
617
618 // either screen reconfigured, theme was reloaded
619 // or a tool resized itself
620
621 if (typeid(*subj) == typeid(ToolbarItem::ToolbarItemSubject))
622 rearrangeItems();
623 else
624 reconfigure();
625
626#ifdef XINERAMA
627 if (subj == &m_screen.resizeSig() && m_xineramaheadmenu)
628 m_xineramaheadmenu->reloadHeads();
629#endif // XINERAMA
630}
631
632void Toolbar::setPlacement(Toolbar::Placement where) { 627void Toolbar::setPlacement(Toolbar::Placement where) {
633 // disable vertical toolbar 628 // disable vertical toolbar
634 629