diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2013-04-09 03:35:49 +0200 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2013-04-09 03:35:49 +0200 |
| commit | 3c92debcf13db74c7f4f310cb1e97f446cc3270e (patch) | |
| tree | 831927be4a84dd1727bf3a4c75b4f79debfe8b05 /panel | |
| parent | c597899d0ad9d13bc2df2be3f3d6bfb595149022 (diff) | |
PanelController: create only one instance of DBusIndicators and share it between Views.
We can just have one dbus-model for indicators, and use it for all our panels. This saves some unneeded allocations in multi-monitor environments. (bzr r3279.4.1)
Diffstat (limited to 'panel')
| -rw-r--r-- | panel/PanelController.cpp | 7 | ||||
| -rw-r--r-- | panel/PanelIndicatorsView.cpp | 3 | ||||
| -rw-r--r-- | panel/PanelView.cpp | 7 | ||||
| -rw-r--r-- | panel/PanelView.h | 2 |
4 files changed, 13 insertions, 6 deletions
diff --git a/panel/PanelController.cpp b/panel/PanelController.cpp index 865743aff..b30e4e659 100644 --- a/panel/PanelController.cpp +++ b/panel/PanelController.cpp @@ -79,6 +79,7 @@ private: int menus_discovery_; int menus_discovery_fadein_; int menus_discovery_fadeout_; + indicator::DBusIndicators::Ptr dbus_indicators_; }; @@ -90,8 +91,8 @@ Controller::Impl::Impl() , menus_discovery_(0) , menus_discovery_fadein_(0) , menus_discovery_fadeout_(0) -{ -} + , dbus_indicators_(std::make_shared<indicator::DBusIndicators>()) +{} std::vector<Window> Controller::Impl::GetTrayXids() const { @@ -243,7 +244,7 @@ void Controller::Impl::OnScreenChanged(unsigned int primary_monitor, { nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION); - PanelView* view = new PanelView(); + PanelView* view = new PanelView(dbus_indicators_); view->SetMaximumHeight(panel::Style::Instance().panel_height); view->SetOpacity(opacity_); view->SetOpacityMaximizedToggle(opacity_maximized_toggle_); diff --git a/panel/PanelIndicatorsView.cpp b/panel/PanelIndicatorsView.cpp index 5081bd866..6cfcc5ca2 100644 --- a/panel/PanelIndicatorsView.cpp +++ b/panel/PanelIndicatorsView.cpp @@ -65,6 +65,9 @@ void PanelIndicatorsView::AddIndicator(Indicator::Ptr const& indicator) std::vector<sigc::connection> connections; + for (auto const& entry : indicator->GetEntries()) + AddEntry(entry); + auto entry_added_conn = indicator->on_entry_added.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryAdded)); connections.push_back(entry_added_conn); diff --git a/panel/PanelView.cpp b/panel/PanelView.cpp index 25c053807..e8b9975d7 100644 --- a/panel/PanelView.cpp +++ b/panel/PanelView.cpp @@ -55,8 +55,9 @@ namespace unity NUX_IMPLEMENT_OBJECT_TYPE(PanelView); -PanelView::PanelView(NUX_FILE_LINE_DECL) +PanelView::PanelView(indicator::DBusIndicators::Ptr const& remote, NUX_FILE_LINE_DECL) : View(NUX_FILE_LINE_PARAM) + , remote_(remote) , is_dirty_(true) , opacity_maximized_toggle_(false) , needs_geo_sync_(false) @@ -105,7 +106,9 @@ PanelView::PanelView(NUX_FILE_LINE_DECL) indicators_ = new PanelIndicatorsView(); AddPanelView(indicators_, 0); - remote_ = indicator::DBusIndicators::Ptr(new indicator::DBusIndicators()); + for (auto const& object : remote_->GetIndicators()) + OnObjectAdded(object); + remote_->on_object_added.connect(sigc::mem_fun(this, &PanelView::OnObjectAdded)); remote_->on_object_removed.connect(sigc::mem_fun(this, &PanelView::OnObjectRemoved)); remote_->on_entry_activate_request.connect(sigc::mem_fun(this, &PanelView::OnEntryActivateRequest)); diff --git a/panel/PanelView.h b/panel/PanelView.h index d0f2f3d2c..3132b1859 100644 --- a/panel/PanelView.h +++ b/panel/PanelView.h @@ -46,7 +46,7 @@ class PanelView : public unity::debug::Introspectable, public nux::View { NUX_DECLARE_OBJECT_TYPE(PanelView, nux::View); public: - PanelView(NUX_FILE_LINE_PROTO); + PanelView(indicator::DBusIndicators::Ptr const&, NUX_FILE_LINE_PROTO); ~PanelView(); void SetPrimary(bool primary); |
