Merge lp:~azzar1/unity/fix-1044681 into lp:unity
- fix-1044681
- Merge into trunk
Proposed by
Andrea Azzarone
Status: | Merged |
---|---|
Approved by: | Andrea Azzarone |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2712 |
Proposed branch: | lp:~azzar1/unity/fix-1044681 |
Merge into: | lp:unity |
Diff against target: |
607 lines (+210/-118) 12 files modified
dash/DashController.cpp (+2/-2) dash/DashView.cpp (+8/-6) panel/WindowButtons.cpp (+6/-7) panel/WindowButtons.h (+2/-1) tests/CMakeLists.txt (+1/-0) tests/test_unity_settings.cpp (+110/-0) unity-shared/DashStyle.cpp (+4/-4) unity-shared/OverlayRenderer.cpp (+3/-3) unity-shared/PanelStyle.cpp (+3/-3) unity-shared/UnitySettings.cpp (+61/-80) unity-shared/UnitySettings.h (+9/-11) unity-standalone/StandaloneUnity.cpp (+1/-1) |
To merge this branch: | bzr merge lp:~azzar1/unity/fix-1044681 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Omer Akram (community) | functional | Approve | |
Review via email: mp+124630@code.launchpad.net |
Commit message
Refactor unity::Settings to use nux::RWProperty.
Description of the change
== Problem ==
Bug #1044681: [regression] Minimizing a window does not give focus to the window behind
== Fix ==
Refactored unity::Settings to use RWProperty.
== Test ==
Unit tests added for unity::Settings.
To post a comment you must log in.
Revision history for this message
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'dash/DashController.cpp' |
2 | --- dash/DashController.cpp 2012-09-17 10:00:38 +0000 |
3 | +++ dash/DashController.cpp 2012-09-18 13:56:19 +0000 |
4 | @@ -74,9 +74,9 @@ |
5 | |
6 | SetupWindow(); |
7 | |
8 | - Settings::Instance().changed.connect([&]() |
9 | + Settings::Instance().form_factor.changed.connect([this](FormFactor) |
10 | { |
11 | - if (window_ && view_) |
12 | + if (window_ && view_ && visible_) |
13 | { |
14 | window_->PushToFront(); |
15 | window_->SetInputFocus(); |
16 | |
17 | === modified file 'dash/DashView.cpp' |
18 | --- dash/DashView.cpp 2012-09-18 09:05:50 +0000 |
19 | +++ dash/DashView.cpp 2012-09-18 13:56:19 +0000 |
20 | @@ -98,7 +98,10 @@ |
21 | SetupViews(); |
22 | SetupUBusConnections(); |
23 | |
24 | - Settings::Instance().changed.connect(sigc::mem_fun(this, &DashView::Relayout)); |
25 | + Settings::Instance().form_factor.changed.connect([this](FormFactor) { |
26 | + Relayout(); |
27 | + }); |
28 | + |
29 | lenses_.lens_added.connect(sigc::mem_fun(this, &DashView::OnLensAdded)); |
30 | mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown)); |
31 | preview_state_machine_.PreviewActivated.connect(sigc::mem_fun(this, &DashView::BuildPreview)); |
32 | @@ -337,7 +340,6 @@ |
33 | content_geo_ = geo; |
34 | } |
35 | |
36 | - |
37 | // kinda hacky, but it makes sure the content isn't so big that it throws |
38 | // the bottom of the dash off the screen |
39 | // not hugely happy with this, so FIXME |
40 | @@ -422,7 +424,7 @@ |
41 | dash::Style& style = dash::Style::Instance(); |
42 | nux::Geometry geo(content_geo_); |
43 | |
44 | - if (Settings::Instance().GetFormFactor() == FormFactor::DESKTOP) |
45 | + if (Settings::Instance().form_factor() == FormFactor::DESKTOP) |
46 | { |
47 | geo.width += style.GetDashRightTileWidth(); |
48 | geo.height += style.GetDashBottomTileHeight(); |
49 | @@ -854,11 +856,11 @@ |
50 | |
51 | std::string form_factor("unknown"); |
52 | |
53 | - if (Settings::Instance().GetFormFactor() == FormFactor::NETBOOK) |
54 | + if (Settings::Instance().form_factor() == FormFactor::NETBOOK) |
55 | form_factor = "netbook"; |
56 | - else if (Settings::Instance().GetFormFactor() == FormFactor::DESKTOP) |
57 | + else if (Settings::Instance().form_factor() == FormFactor::DESKTOP) |
58 | form_factor = "desktop"; |
59 | - else if (Settings::Instance().GetFormFactor() == FormFactor::TV) |
60 | + else if (Settings::Instance().form_factor() == FormFactor::TV) |
61 | form_factor = "tv"; |
62 | |
63 | unity::variant::BuilderWrapper wrapper(builder); |
64 | |
65 | === modified file 'panel/WindowButtons.cpp' |
66 | --- panel/WindowButtons.cpp 2012-07-06 22:36:27 +0000 |
67 | +++ panel/WindowButtons.cpp 2012-09-18 13:56:19 +0000 |
68 | @@ -395,7 +395,7 @@ |
69 | |
70 | ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &WindowButtons::OnOverlayShown)); |
71 | ubus_manager_.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &WindowButtons::OnOverlayHidden)); |
72 | - Settings::Instance().changed.connect(sigc::mem_fun(this, &WindowButtons::OnDashSettingsUpdated)); |
73 | + Settings::Instance().form_factor.changed.connect(sigc::mem_fun(this, &WindowButtons::OnDashSettingsUpdated)); |
74 | } |
75 | |
76 | nux::Area* WindowButtons::FindAreaUnderMouse(const nux::Point& mouse, nux::NuxEventType event_type) |
77 | @@ -470,7 +470,7 @@ |
78 | |
79 | if (win_button->IsOverlayOpen()) |
80 | { |
81 | - Settings::Instance().SetFormFactor(FormFactor::DESKTOP); |
82 | + Settings::Instance().form_factor = FormFactor::DESKTOP; |
83 | } |
84 | else |
85 | { |
86 | @@ -494,7 +494,7 @@ |
87 | |
88 | if (win_button->IsOverlayOpen()) |
89 | { |
90 | - Settings::Instance().SetFormFactor(FormFactor::NETBOOK); |
91 | + Settings::Instance().form_factor = FormFactor::NETBOOK; |
92 | } |
93 | |
94 | maximize_clicked.emit(); |
95 | @@ -550,7 +550,7 @@ |
96 | if (restore_button && maximize_button) |
97 | { |
98 | Settings &dash_settings = Settings::Instance(); |
99 | - bool maximizable = (dash_settings.GetFormFactor() == FormFactor::DESKTOP); |
100 | + bool maximizable = (dash_settings.form_factor() == FormFactor::DESKTOP); |
101 | |
102 | restore_button->SetEnabled(can_maximise); |
103 | maximize_button->SetEnabled(can_maximise); |
104 | @@ -645,7 +645,7 @@ |
105 | } |
106 | } |
107 | |
108 | -void WindowButtons::OnDashSettingsUpdated() |
109 | +void WindowButtons::OnDashSettingsUpdated(FormFactor form_factor) |
110 | { |
111 | WindowButton* maximize_button = nullptr; |
112 | WindowButton* restore_button = nullptr; |
113 | @@ -672,8 +672,7 @@ |
114 | |
115 | if (restore_button && restore_button->IsOverlayOpen() && maximize_button) |
116 | { |
117 | - Settings &dash_settings = Settings::Instance(); |
118 | - bool maximizable = (dash_settings.GetFormFactor() == FormFactor::DESKTOP); |
119 | + bool maximizable = (form_factor == FormFactor::DESKTOP); |
120 | |
121 | if (maximizable != maximize_button->IsVisible()) |
122 | { |
123 | |
124 | === modified file 'panel/WindowButtons.h' |
125 | --- panel/WindowButtons.h 2012-05-06 23:48:38 +0000 |
126 | +++ panel/WindowButtons.h 2012-09-18 13:56:19 +0000 |
127 | @@ -26,6 +26,7 @@ |
128 | |
129 | #include "unity-shared/UBusWrapper.h" |
130 | #include "unity-shared/Introspectable.h" |
131 | +#include "unity-shared/UnitySettings.h" |
132 | |
133 | namespace unity |
134 | { |
135 | @@ -70,7 +71,7 @@ |
136 | void OnMaximizeClicked(nux::Button *button); |
137 | void OnOverlayShown(GVariant* data); |
138 | void OnOverlayHidden(GVariant* data); |
139 | - void OnDashSettingsUpdated(); |
140 | + void OnDashSettingsUpdated(FormFactor form_factor); |
141 | |
142 | int monitor_; |
143 | double opacity_; |
144 | |
145 | === modified file 'tests/CMakeLists.txt' |
146 | --- tests/CMakeLists.txt 2012-09-17 14:07:30 +0000 |
147 | +++ tests/CMakeLists.txt 2012-09-18 13:56:19 +0000 |
148 | @@ -231,6 +231,7 @@ |
149 | test_texture_cache.cpp |
150 | test_thumbnail_generator.cpp |
151 | test_launcher_minimize_speed.cpp |
152 | + test_unity_settings.cpp |
153 | test_volume_imp.cpp |
154 | test_volume_launcher_icon.cpp |
155 | gmockmount.c |
156 | |
157 | === added file 'tests/test_unity_settings.cpp' |
158 | --- tests/test_unity_settings.cpp 1970-01-01 00:00:00 +0000 |
159 | +++ tests/test_unity_settings.cpp 2012-09-18 13:56:19 +0000 |
160 | @@ -0,0 +1,110 @@ |
161 | +/* |
162 | + * Copyright 2012 Canonical Ltd. |
163 | + * |
164 | + * This program is free software: you can redistribute it and/or modify it |
165 | + * under the terms of the GNU General Public License version 3, as published |
166 | + * by the Free Software Foundation. |
167 | + * |
168 | + * This program is distributed in the hope that it will be useful, but |
169 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
170 | + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR |
171 | + * PURPOSE. See the GNU General Public License for more details. |
172 | + * |
173 | + * You should have received a copy of the GNU General Public License |
174 | + * version 3 along with this program. If not, see |
175 | + * <http://www.gnu.org/licenses/> |
176 | + * |
177 | + * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> |
178 | + * |
179 | + */ |
180 | + |
181 | +#include <gio/gio.h> |
182 | +#include <gtest/gtest.h> |
183 | + |
184 | +#include "test_utils.h" |
185 | +#include "unity-shared/UnitySettings.h" |
186 | + |
187 | +#include <UnityCore/GLibWrapper.h> |
188 | + |
189 | +namespace |
190 | +{ |
191 | + |
192 | +class TestUnitySettings : public testing::Test |
193 | +{ |
194 | +public: |
195 | + unity::glib::Object<GSettings> gsettings; |
196 | + std::unique_ptr<unity::Settings> unity_settings; |
197 | + |
198 | + void SetUp() |
199 | + { |
200 | + g_setenv("GSETTINGS_BACKEND", "memory", TRUE); |
201 | + |
202 | + gsettings = g_settings_new("com.canonical.Unity"); |
203 | + g_settings_set_enum(gsettings, "form-factor", static_cast<int>(unity::FormFactor::DESKTOP)); |
204 | + |
205 | + unity_settings.reset(new unity::Settings); |
206 | + } |
207 | + |
208 | + void TearDown() |
209 | + { |
210 | + g_setenv("GSETTINGS_BACKEND", "", TRUE); |
211 | + } |
212 | +}; |
213 | + |
214 | +TEST_F(TestUnitySettings, SetFormFactor) |
215 | +{ |
216 | + unity_settings->form_factor = unity::FormFactor::NETBOOK; |
217 | + |
218 | + int raw_form_factor = g_settings_get_enum(gsettings, "form-factor"); |
219 | + EXPECT_EQ(raw_form_factor, static_cast<int>(unity::FormFactor::NETBOOK)); |
220 | +} |
221 | + |
222 | +TEST_F(TestUnitySettings, GetFormFactor) |
223 | +{ |
224 | + EXPECT_EQ(unity_settings->form_factor(), unity::FormFactor::DESKTOP); |
225 | + |
226 | + g_settings_set_enum(gsettings, "form-factor", static_cast<int>(unity::FormFactor::NETBOOK)); |
227 | + EXPECT_EQ(unity_settings->form_factor(), unity::FormFactor::NETBOOK); |
228 | +} |
229 | + |
230 | +TEST_F(TestUnitySettings, FormFactorChangedSignal_Extern) |
231 | +{ |
232 | + bool signal_received = false; |
233 | + unity::FormFactor new_form_factor; |
234 | + unity_settings->form_factor.changed.connect([&](unity::FormFactor form_factor) { |
235 | + signal_received = true; |
236 | + new_form_factor = form_factor; |
237 | + }); |
238 | + |
239 | + g_settings_set_enum(gsettings, "form-factor", static_cast<int>(unity::FormFactor::NETBOOK)); |
240 | + Utils::WaitUntil(signal_received); |
241 | + EXPECT_EQ(new_form_factor, unity::FormFactor::NETBOOK); |
242 | +} |
243 | + |
244 | +TEST_F(TestUnitySettings, FormFactorChangedSignal_Extern_OtherKeys) |
245 | +{ |
246 | + bool signal_received = false; |
247 | + unity_settings->form_factor.changed.connect([&](unity::FormFactor form_factor) { |
248 | + signal_received = true; |
249 | + }); |
250 | + |
251 | + g_settings_set_int(gsettings, "minimize-count", 0); |
252 | + Utils::WaitForTimeout(1); |
253 | + EXPECT_FALSE(signal_received); |
254 | +} |
255 | + |
256 | +TEST_F(TestUnitySettings, FormFactorChangedSignal_Inter) |
257 | +{ |
258 | + bool signal_received = false; |
259 | + unity::FormFactor new_form_factor; |
260 | + unity_settings->form_factor.changed.connect([&](unity::FormFactor form_factor) { |
261 | + signal_received = true; |
262 | + new_form_factor = form_factor; |
263 | + }); |
264 | + |
265 | + unity_settings->form_factor = unity::FormFactor::NETBOOK; |
266 | + Utils::WaitUntil(signal_received); |
267 | + EXPECT_EQ(new_form_factor, unity::FormFactor::NETBOOK); |
268 | +} |
269 | + |
270 | +} |
271 | |
272 | === modified file 'unity-shared/DashStyle.cpp' |
273 | --- unity-shared/DashStyle.cpp 2012-09-16 23:45:17 +0000 |
274 | +++ unity-shared/DashStyle.cpp 2012-09-18 13:56:19 +0000 |
275 | @@ -427,14 +427,14 @@ |
276 | style_instance = this; |
277 | } |
278 | |
279 | - auto formfactor_lambda = [this] () |
280 | + auto formfactor_lambda = [this] (FormFactor) |
281 | { |
282 | - FormFactor formfactor = Settings::Instance().GetFormFactor(); |
283 | + FormFactor formfactor = Settings::Instance().form_factor(); |
284 | always_maximised = (formfactor == FormFactor::NETBOOK || formfactor == FormFactor::TV); |
285 | }; |
286 | |
287 | - Settings::Instance().changed.connect(formfactor_lambda); |
288 | - formfactor_lambda(); |
289 | + Settings::Instance().form_factor.changed.connect(formfactor_lambda); |
290 | + formfactor_lambda(FormFactor()); |
291 | } |
292 | |
293 | Style::~Style () |
294 | |
295 | === modified file 'unity-shared/OverlayRenderer.cpp' |
296 | --- unity-shared/OverlayRenderer.cpp 2012-09-14 10:26:33 +0000 |
297 | +++ unity-shared/OverlayRenderer.cpp 2012-09-18 13:56:19 +0000 |
298 | @@ -438,7 +438,7 @@ |
299 | bool paint_blur = BackgroundEffectHelper::blur_type != BLUR_NONE; |
300 | nux::Geometry geo(content_geo); |
301 | |
302 | - int excess_border = (Settings::Instance().GetFormFactor() != FormFactor::NETBOOK || force_edges) ? EXCESS_BORDER : 0; |
303 | + int excess_border = (Settings::Instance().form_factor() != FormFactor::NETBOOK || force_edges) ? EXCESS_BORDER : 0; |
304 | |
305 | nux::Geometry larger_content_geo = content_geo; |
306 | larger_content_geo.OffsetSize(excess_border, excess_border); |
307 | @@ -578,7 +578,7 @@ |
308 | } |
309 | |
310 | |
311 | - if (Settings::Instance().GetFormFactor() != FormFactor::NETBOOK || force_edges) |
312 | + if (Settings::Instance().form_factor() != FormFactor::NETBOOK || force_edges) |
313 | { |
314 | // Paint the edges |
315 | { |
316 | @@ -835,7 +835,7 @@ |
317 | nux::Geometry geo = geometry; |
318 | bgs = 0; |
319 | |
320 | - int excess_border = (Settings::Instance().GetFormFactor() != FormFactor::NETBOOK) ? EXCESS_BORDER : 0; |
321 | + int excess_border = (Settings::Instance().form_factor() != FormFactor::NETBOOK) ? EXCESS_BORDER : 0; |
322 | |
323 | nux::Geometry larger_content_geo = content_geo; |
324 | larger_content_geo.OffsetSize(excess_border, excess_border); |
325 | |
326 | === modified file 'unity-shared/PanelStyle.cpp' |
327 | --- unity-shared/PanelStyle.cpp 2012-08-29 18:29:18 +0000 |
328 | +++ unity-shared/PanelStyle.cpp 2012-09-18 13:56:19 +0000 |
329 | @@ -73,12 +73,12 @@ |
330 | style_instance = this; |
331 | } |
332 | |
333 | - if (Settings::Instance().GetFormFactor() == FormFactor::TV) |
334 | + if (Settings::Instance().form_factor() == FormFactor::TV) |
335 | panel_height = 0; |
336 | |
337 | - Settings::Instance().changed.connect([this]() |
338 | + Settings::Instance().form_factor.changed.connect([this](FormFactor form_factor) |
339 | { |
340 | - if (Settings::Instance().GetFormFactor() == FormFactor::TV) |
341 | + if (form_factor == FormFactor::TV) |
342 | panel_height = 0; |
343 | }); |
344 | |
345 | |
346 | === modified file 'unity-shared/UnitySettings.cpp' |
347 | --- unity-shared/UnitySettings.cpp 2012-05-22 14:33:41 +0000 |
348 | +++ unity-shared/UnitySettings.cpp 2012-09-18 13:56:19 +0000 |
349 | @@ -1,6 +1,6 @@ |
350 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
351 | /* |
352 | -* Copyright (C) 2010, 2011 Canonical Ltd |
353 | +* Copyright (C) 2010, 2011, 2012 Canonical Ltd |
354 | * |
355 | * This program is free software: you can redistribute it and/or modify |
356 | * it under the terms of the GNU General Public License version 3 as |
357 | @@ -15,6 +15,7 @@ |
358 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
359 | * |
360 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
361 | +* Andrea Azzarone <andrea.azzarone@canonical.com> |
362 | */ |
363 | |
364 | #include <gdk/gdk.h> |
365 | @@ -32,81 +33,69 @@ |
366 | nux::logging::Logger logger("unity"); |
367 | |
368 | Settings* settings_instance = nullptr; |
369 | -const char* const FORM_FACTOR = "form-factor"; |
370 | + |
371 | +const std::string SETTINGS_NAME = "com.canonical.Unity"; |
372 | +const std::string FORM_FACTOR = "form-factor"; |
373 | } |
374 | |
375 | +// |
376 | +// Start private implementation |
377 | +// |
378 | class Settings::Impl |
379 | { |
380 | public: |
381 | - Impl(Settings* owner); |
382 | - ~Impl(); |
383 | - |
384 | - FormFactor GetFormFactor() const; |
385 | - void SetFormFactor(FormFactor factor); |
386 | - |
387 | -private: |
388 | - void Refresh(); |
389 | - static void Changed(GSettings* settings, gchar* key, Impl* self); |
390 | - |
391 | -private: |
392 | - Settings* owner_; |
393 | - GSettings* settings_; |
394 | - FormFactor form_factor_; |
395 | + Impl(Settings* owner) |
396 | + : parent_(owner) |
397 | + , gsettings_(g_settings_new(SETTINGS_NAME.c_str())) |
398 | + , cached_form_factor_(FormFactor::DESKTOP) |
399 | + { |
400 | + CacheFormFactor(); |
401 | + |
402 | + form_factor_changed_.Connect(gsettings_, "changed::" + FORM_FACTOR, [this] (GSettings*, gchar*) { |
403 | + CacheFormFactor(); |
404 | + parent_->form_factor.changed.emit(cached_form_factor_); |
405 | + }); |
406 | + } |
407 | + |
408 | + void CacheFormFactor() |
409 | + { |
410 | + int raw_from_factor = g_settings_get_enum(gsettings_, FORM_FACTOR.c_str()); |
411 | + |
412 | + if (raw_from_factor == 0) //Automatic |
413 | + { |
414 | + auto uscreen = UScreen::GetDefault(); |
415 | + int primary_monitor = uscreen->GetMonitorWithMouse(); |
416 | + auto const& geo = uscreen->GetMonitorGeometry(primary_monitor); |
417 | + |
418 | + cached_form_factor_ = geo.height > 799 ? FormFactor::DESKTOP : FormFactor::NETBOOK; |
419 | + } |
420 | + else |
421 | + { |
422 | + cached_form_factor_ = static_cast<FormFactor>(raw_from_factor); |
423 | + } |
424 | + } |
425 | + |
426 | + FormFactor GetFormFactor() const |
427 | + { |
428 | + return cached_form_factor_; |
429 | + } |
430 | + |
431 | + bool SetFormFactor(FormFactor factor) |
432 | + { |
433 | + g_settings_set_enum(gsettings_, FORM_FACTOR.c_str(), static_cast<int>(factor)); |
434 | + return true; |
435 | + } |
436 | + |
437 | + Settings* parent_; |
438 | + glib::Object<GSettings> gsettings_; |
439 | + FormFactor cached_form_factor_; |
440 | + |
441 | + glib::Signal<void, GSettings*, gchar* > form_factor_changed_; |
442 | }; |
443 | |
444 | - |
445 | -Settings::Impl::Impl(Settings* owner) |
446 | - : owner_(owner) |
447 | - , settings_(nullptr) |
448 | - , form_factor_(FormFactor::DESKTOP) |
449 | -{ |
450 | - settings_ = g_settings_new("com.canonical.Unity"); |
451 | - g_signal_connect(settings_, "changed", |
452 | - (GCallback)(Impl::Changed), this); |
453 | - Refresh(); |
454 | -} |
455 | - |
456 | -Settings::Impl::~Impl() |
457 | -{ |
458 | - g_object_unref(settings_); |
459 | -} |
460 | - |
461 | -void Settings::Impl::Refresh() |
462 | -{ |
463 | - int raw_from_factor = g_settings_get_enum(settings_, FORM_FACTOR); |
464 | - |
465 | - if (raw_from_factor == 0) //Automatic |
466 | - { |
467 | - UScreen *uscreen = UScreen::GetDefault(); |
468 | - int primary_monitor = uscreen->GetMonitorWithMouse(); |
469 | - auto geo = uscreen->GetMonitorGeometry(primary_monitor); |
470 | - |
471 | - form_factor_ = geo.height > 799 ? FormFactor::DESKTOP : FormFactor::NETBOOK; |
472 | - } |
473 | - else |
474 | - { |
475 | - form_factor_ = static_cast<FormFactor>(raw_from_factor); |
476 | - } |
477 | - |
478 | - owner_->changed.emit(); |
479 | -} |
480 | - |
481 | -void Settings::Impl::Changed(GSettings* settings, char* key, Impl* self) |
482 | -{ |
483 | - self->Refresh(); |
484 | -} |
485 | - |
486 | -FormFactor Settings::Impl::GetFormFactor() const |
487 | -{ |
488 | - return form_factor_; |
489 | -} |
490 | - |
491 | -void Settings::Impl::SetFormFactor(FormFactor factor) |
492 | -{ |
493 | - form_factor_ = factor; |
494 | - g_settings_set_enum(settings_, FORM_FACTOR, static_cast<int>(factor)); |
495 | - owner_->changed.emit(); |
496 | -} |
497 | +// |
498 | +// End private implementation |
499 | +// |
500 | |
501 | Settings::Settings() |
502 | : is_standalone(false) |
503 | @@ -118,13 +107,15 @@ |
504 | } |
505 | else |
506 | { |
507 | + form_factor.SetGetterFunction(sigc::mem_fun(*pimpl, &Impl::GetFormFactor)); |
508 | + form_factor.SetSetterFunction(sigc::mem_fun(*pimpl, &Impl::SetFormFactor)); |
509 | + |
510 | settings_instance = this; |
511 | } |
512 | } |
513 | |
514 | Settings::~Settings() |
515 | { |
516 | - delete pimpl; |
517 | if (settings_instance == this) |
518 | settings_instance = nullptr; |
519 | } |
520 | @@ -139,15 +130,5 @@ |
521 | return *settings_instance; |
522 | } |
523 | |
524 | -FormFactor Settings::GetFormFactor() const |
525 | -{ |
526 | - return pimpl->GetFormFactor(); |
527 | -} |
528 | - |
529 | -void Settings::SetFormFactor(FormFactor factor) |
530 | -{ |
531 | - pimpl->SetFormFactor(factor); |
532 | -} |
533 | - |
534 | |
535 | } // namespace unity |
536 | |
537 | === modified file 'unity-shared/UnitySettings.h' |
538 | --- unity-shared/UnitySettings.h 2012-05-22 14:33:41 +0000 |
539 | +++ unity-shared/UnitySettings.h 2012-09-18 13:56:19 +0000 |
540 | @@ -1,6 +1,6 @@ |
541 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
542 | /* |
543 | -* Copyright (C) 2010, 2011 Canonical Ltd |
544 | +* Copyright (C) 2010, 2011, 2012 Canonical Ltd |
545 | * |
546 | * This program is free software: you can redistribute it and/or modify |
547 | * it under the terms of the GNU General Public License version 3 as |
548 | @@ -15,11 +15,13 @@ |
549 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
550 | * |
551 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
552 | +* Andrea Azzarone <andrea.azzarone@canonical.com> |
553 | */ |
554 | |
555 | -#ifndef UNITY_SETTINGS_H |
556 | -#define UNITY_SETTINGS_H |
557 | +#ifndef UNITYSHELL_SETTINGS_H |
558 | +#define UNITYSHELL_SETTINGS_H |
559 | |
560 | +#include <memory> |
561 | #include <sigc++/signal.h> |
562 | #include <Nux/Nux.h> |
563 | |
564 | @@ -29,7 +31,7 @@ |
565 | enum class FormFactor |
566 | { |
567 | DESKTOP = 1, |
568 | - NETBOOK = 2, |
569 | + NETBOOK, |
570 | TV |
571 | }; |
572 | |
573 | @@ -41,18 +43,14 @@ |
574 | |
575 | static Settings& Instance(); |
576 | |
577 | - // NOTE: could potentially refactor this into a nux::Property |
578 | - FormFactor GetFormFactor() const; |
579 | - void SetFormFactor(FormFactor factor); |
580 | - |
581 | + nux::RWProperty<FormFactor> form_factor; |
582 | nux::Property<bool> is_standalone; |
583 | - sigc::signal<void> changed; |
584 | |
585 | private: |
586 | class Impl; |
587 | - Impl* pimpl; |
588 | + std::unique_ptr<Impl> pimpl; |
589 | }; |
590 | |
591 | } |
592 | |
593 | -#endif // UNITY_SETTINGS_H |
594 | +#endif |
595 | |
596 | === modified file 'unity-standalone/StandaloneUnity.cpp' |
597 | --- unity-standalone/StandaloneUnity.cpp 2012-09-11 13:57:19 +0000 |
598 | +++ unity-standalone/StandaloneUnity.cpp 2012-09-18 13:56:19 +0000 |
599 | @@ -160,7 +160,7 @@ |
600 | // The instances for the pseudo-singletons. |
601 | Settings settings; |
602 | settings.is_standalone = true; |
603 | - if (force_tv) Settings::Instance().SetFormFactor(FormFactor::TV); |
604 | + if (force_tv) Settings::Instance().form_factor(FormFactor::TV); |
605 | |
606 | PluginAdapter::Initialize(NULL); |
607 | dash::Style dash_style; |
fix works for me.