Merge lp:~3v1n0/unity/panel-shared-dbus-model into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3290
Proposed branch: lp:~3v1n0/unity/panel-shared-dbus-model
Merge into: lp:unity
Diff against target: 116 lines (+19/-8)
6 files modified
panel/PanelController.cpp (+4/-3)
panel/PanelIndicatorsView.cpp (+3/-0)
panel/PanelView.cpp (+5/-2)
panel/PanelView.h (+1/-1)
panel/StandalonePanel.cpp (+5/-1)
tests/test_panel_view.cpp (+1/-1)
To merge this branch: bzr merge lp:~3v1n0/unity/panel-shared-dbus-model
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
Review via email: mp+157780@code.launchpad.net

Commit message

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.

Description of the change

In the past I already updated DBusIndicators to be multi-monitor friendly, but I've never shared it between panels.

We can safely do it, having just one DBusProxy that monitors our panel service to update indicators (and to callback it).

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panel/PanelController.cpp'
2--- panel/PanelController.cpp 2013-03-05 14:29:18 +0000
3+++ panel/PanelController.cpp 2013-04-09 02:13:24 +0000
4@@ -79,6 +79,7 @@
5 int menus_discovery_;
6 int menus_discovery_fadein_;
7 int menus_discovery_fadeout_;
8+ indicator::DBusIndicators::Ptr dbus_indicators_;
9 };
10
11
12@@ -90,8 +91,8 @@
13 , menus_discovery_(0)
14 , menus_discovery_fadein_(0)
15 , menus_discovery_fadeout_(0)
16-{
17-}
18+ , dbus_indicators_(std::make_shared<indicator::DBusIndicators>())
19+{}
20
21 std::vector<Window> Controller::Impl::GetTrayXids() const
22 {
23@@ -243,7 +244,7 @@
24 {
25 nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION);
26
27- PanelView* view = new PanelView();
28+ PanelView* view = new PanelView(dbus_indicators_);
29 view->SetMaximumHeight(panel::Style::Instance().panel_height);
30 view->SetOpacity(opacity_);
31 view->SetOpacityMaximizedToggle(opacity_maximized_toggle_);
32
33=== modified file 'panel/PanelIndicatorsView.cpp'
34--- panel/PanelIndicatorsView.cpp 2012-12-13 20:06:11 +0000
35+++ panel/PanelIndicatorsView.cpp 2013-04-09 02:13:24 +0000
36@@ -65,6 +65,9 @@
37
38 std::vector<sigc::connection> connections;
39
40+ for (auto const& entry : indicator->GetEntries())
41+ AddEntry(entry);
42+
43 auto entry_added_conn = indicator->on_entry_added.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryAdded));
44 connections.push_back(entry_added_conn);
45
46
47=== modified file 'panel/PanelView.cpp'
48--- panel/PanelView.cpp 2013-03-19 18:47:01 +0000
49+++ panel/PanelView.cpp 2013-04-09 02:13:24 +0000
50@@ -55,8 +55,9 @@
51
52 NUX_IMPLEMENT_OBJECT_TYPE(PanelView);
53
54-PanelView::PanelView(NUX_FILE_LINE_DECL)
55+PanelView::PanelView(indicator::DBusIndicators::Ptr const& remote, NUX_FILE_LINE_DECL)
56 : View(NUX_FILE_LINE_PARAM)
57+ , remote_(remote)
58 , is_dirty_(true)
59 , opacity_maximized_toggle_(false)
60 , needs_geo_sync_(false)
61@@ -105,7 +106,9 @@
62 indicators_ = new PanelIndicatorsView();
63 AddPanelView(indicators_, 0);
64
65- remote_ = indicator::DBusIndicators::Ptr(new indicator::DBusIndicators());
66+ for (auto const& object : remote_->GetIndicators())
67+ OnObjectAdded(object);
68+
69 remote_->on_object_added.connect(sigc::mem_fun(this, &PanelView::OnObjectAdded));
70 remote_->on_object_removed.connect(sigc::mem_fun(this, &PanelView::OnObjectRemoved));
71 remote_->on_entry_activate_request.connect(sigc::mem_fun(this, &PanelView::OnEntryActivateRequest));
72
73=== modified file 'panel/PanelView.h'
74--- panel/PanelView.h 2013-03-04 23:56:40 +0000
75+++ panel/PanelView.h 2013-04-09 02:13:24 +0000
76@@ -46,7 +46,7 @@
77 {
78 NUX_DECLARE_OBJECT_TYPE(PanelView, nux::View);
79 public:
80- PanelView(NUX_FILE_LINE_PROTO);
81+ PanelView(indicator::DBusIndicators::Ptr const&, NUX_FILE_LINE_PROTO);
82 ~PanelView();
83
84 void SetPrimary(bool primary);
85
86=== modified file 'panel/StandalonePanel.cpp'
87--- panel/StandalonePanel.cpp 2012-12-12 17:30:20 +0000
88+++ panel/StandalonePanel.cpp 2013-04-09 02:13:24 +0000
89@@ -47,9 +47,13 @@
90 }
91
92 private:
93- class StandalonePanelView : public PanelView
94+ struct StandalonePanelView : public PanelView
95 {
96 // Used to sync menu geometries
97+ StandalonePanelView()
98+ : PanelView(std::make_shared<indicator::DBusIndicators>())
99+ {}
100+
101 std::string GetName() const { return "StandalonePanel"; }
102 };
103
104
105=== modified file 'tests/test_panel_view.cpp'
106--- tests/test_panel_view.cpp 2013-03-04 23:09:52 +0000
107+++ tests/test_panel_view.cpp 2013-04-09 02:13:24 +0000
108@@ -39,7 +39,7 @@
109 nux::ObjectPtr<unity::PanelView> panel_view_;
110
111 TestPanelView()
112- : panel_view_(new unity::PanelView())
113+ : panel_view_(new unity::PanelView(std::make_shared<unity::indicator::DBusIndicators>()))
114 {}
115
116 };