From 57acca0b601277982e63fa34eb78ae7881873e09 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Sat, 7 May 2011 22:41:59 +0200 Subject: Convert ToolbarItem::resizeSig to FbTk::Signal --- src/ClockTool.cc | 4 ++-- src/SystemTray.cc | 6 +++--- src/Toolbar.cc | 8 ++------ src/Toolbar.hh | 2 -- src/ToolbarItem.hh | 8 +++----- src/WorkspaceNameTool.cc | 2 +- 6 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/ClockTool.cc b/src/ClockTool.cc index 6642985..95176a2 100644 --- a/src/ClockTool.cc +++ b/src/ClockTool.cc @@ -260,7 +260,7 @@ void ClockTool::themeReconfigured() { translateSize(orientation(), new_width, new_height); if (new_width != m_button.width() || new_height != m_button.height()) { resize(new_width, new_height); - resizeSig().notify(); + resizeSig().emit(); } } @@ -305,7 +305,7 @@ void ClockTool::updateTime() { unsigned int new_width = m_theme->font().textWidth(time_string, time_string_len) + 2; if (new_width > m_button.width()) { resize(new_width, m_button.height()); - resizeSig().notify(); + resizeSig().emit(); } #else // dont have strftime so we have to set it to hour:minut // sprintf(time_string, "%d:%d", ); diff --git a/src/SystemTray.cc b/src/SystemTray.cc index 66e350f..846181f 100644 --- a/src/SystemTray.cc +++ b/src/SystemTray.cc @@ -246,7 +246,7 @@ void SystemTray::resize(unsigned int width, unsigned int height) { m_window.resize(width, height); if (m_num_visible_clients) rearrangeClients(); - resizeSig().notify(); + resizeSig().emit(); } } @@ -257,7 +257,7 @@ void SystemTray::moveResize(int x, int y, m_window.moveResize(x, y, width, height); if (m_num_visible_clients) rearrangeClients(); - resizeSig().notify(); + resizeSig().emit(); } else { move(x, y); } @@ -435,7 +435,7 @@ void SystemTray::handleEvent(XEvent &event) { (*it)->sendConfigureNotify(0, 0, (*it)->width(), (*it)->height()); // so toolbar know that we changed size // done inside this loop, because otherwise we can get into nasty looping - resizeSig().notify(); + resizeSig().emit(); } } diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 9c2d2bf..a8b2c5b 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -51,7 +51,6 @@ #include "FbTk/BoolMenuItem.hh" #include "FbTk/IntMenuItem.hh" #include "FbTk/Shape.hh" -#include "FbTk/SimpleObserver.hh" #include "FbTk/MemFun.hh" #include "FbTk/STLUtil.hh" #include "FbTk/Util.hh" @@ -227,8 +226,6 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::Layer &layer, size_t width): m_shape(new FbTk::Shape(frame.window, 0)), m_resize_lock(false) { _FB_USES_NLS; - // NOTE: first subject is always the rearrangeItem ! - m_observers.push_back(makeObserver(*this, &Toolbar::rearrangeItems)); // get this on antialias change m_signal_tracker.join(screen().reconfigureSig(), @@ -425,9 +422,8 @@ void Toolbar::reconfigure() { if (item == 0) continue; m_item_list.push_back(item); - // attach to first observer ( which must be rearrangeItems ) - item->resizeSig().attach(m_observers[0]); - + m_signal_tracker.join(item->resizeSig(), + FbTk::MemFun(*this, &Toolbar::rearrangeItems)); } // show all items frame.window.showSubwindows(); diff --git a/src/Toolbar.hh b/src/Toolbar.hh index 3c9d048..9f737b4 100644 --- a/src/Toolbar.hh +++ b/src/Toolbar.hh @@ -197,8 +197,6 @@ private: StringList m_tools; bool m_resize_lock; ///< to lock rearrangeItems or not - /// observers for various signals - std::vector m_observers; FbTk::SignalTracker m_signal_tracker; }; diff --git a/src/ToolbarItem.hh b/src/ToolbarItem.hh index f5d1a2a..bd5b38f 100644 --- a/src/ToolbarItem.hh +++ b/src/ToolbarItem.hh @@ -23,7 +23,7 @@ #ifndef TOOLBARITEM_HH #define TOOLBARITEM_HH -#include "FbTk/Subject.hh" +#include "FbTk/Signal.hh" #include "FbTk/Orientation.hh" /// An item in the toolbar that has either fixed or relative size to the toolbar @@ -62,7 +62,7 @@ public: // just update theme items that affect the size virtual void updateSizing() = 0; - FbTk::Subject &resizeSig() { return m_resize_sig; } + FbTk::Signal<> &resizeSig() { return m_resize_sig; } void setType(Type type) { m_type = type; } Type type() const { return m_type; } @@ -70,14 +70,12 @@ public: FbTk::Orientation orientation() const { return m_orientation; } virtual void setOrientation(FbTk::Orientation orient) { m_orientation = orient; } - class ToolbarItemSubject : public FbTk::Subject {}; - private: Type m_type; FbTk::Orientation m_orientation; - ToolbarItemSubject m_resize_sig; + FbTk::Signal<> m_resize_sig; }; #endif // TOOLBARITEM_HH diff --git a/src/WorkspaceNameTool.cc b/src/WorkspaceNameTool.cc index 6451a0a..84f62e5 100644 --- a/src/WorkspaceNameTool.cc +++ b/src/WorkspaceNameTool.cc @@ -74,7 +74,7 @@ void WorkspaceNameTool::update() { m_button.setText(m_screen.currentWorkspace()->name()); if (m_button.width() != width()) { resize(width(), height()); - resizeSig().notify(); + resizeSig().emit(); } reRender(); m_button.clear(); -- cgit v0.11.2