Merge lp:~azzar1/unity/fix-1044681 into lp:unity

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
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
Omer Akram (om26er) wrote :

fix works for me.

review: Approve (functional)
Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/1334/console reported an error when processing this lp:~andyrock/unity/fix-1044681 branch.
Not merging it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'dash/DashController.cpp'
--- dash/DashController.cpp 2012-09-17 10:00:38 +0000
+++ dash/DashController.cpp 2012-09-18 13:56:19 +0000
@@ -74,9 +74,9 @@
7474
75 SetupWindow();75 SetupWindow();
7676
77 Settings::Instance().changed.connect([&]()77 Settings::Instance().form_factor.changed.connect([this](FormFactor)
78 {78 {
79 if (window_ && view_)79 if (window_ && view_ && visible_)
80 {80 {
81 window_->PushToFront();81 window_->PushToFront();
82 window_->SetInputFocus();82 window_->SetInputFocus();
8383
=== modified file 'dash/DashView.cpp'
--- dash/DashView.cpp 2012-09-18 09:05:50 +0000
+++ dash/DashView.cpp 2012-09-18 13:56:19 +0000
@@ -98,7 +98,10 @@
98 SetupViews();98 SetupViews();
99 SetupUBusConnections();99 SetupUBusConnections();
100100
101 Settings::Instance().changed.connect(sigc::mem_fun(this, &DashView::Relayout));101 Settings::Instance().form_factor.changed.connect([this](FormFactor) {
102 Relayout();
103 });
104
102 lenses_.lens_added.connect(sigc::mem_fun(this, &DashView::OnLensAdded));105 lenses_.lens_added.connect(sigc::mem_fun(this, &DashView::OnLensAdded));
103 mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown));106 mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown));
104 preview_state_machine_.PreviewActivated.connect(sigc::mem_fun(this, &DashView::BuildPreview));107 preview_state_machine_.PreviewActivated.connect(sigc::mem_fun(this, &DashView::BuildPreview));
@@ -337,7 +340,6 @@
337 content_geo_ = geo;340 content_geo_ = geo;
338 }341 }
339342
340
341 // kinda hacky, but it makes sure the content isn't so big that it throws343 // kinda hacky, but it makes sure the content isn't so big that it throws
342 // the bottom of the dash off the screen344 // the bottom of the dash off the screen
343 // not hugely happy with this, so FIXME345 // not hugely happy with this, so FIXME
@@ -422,7 +424,7 @@
422 dash::Style& style = dash::Style::Instance();424 dash::Style& style = dash::Style::Instance();
423 nux::Geometry geo(content_geo_);425 nux::Geometry geo(content_geo_);
424426
425 if (Settings::Instance().GetFormFactor() == FormFactor::DESKTOP)427 if (Settings::Instance().form_factor() == FormFactor::DESKTOP)
426 {428 {
427 geo.width += style.GetDashRightTileWidth();429 geo.width += style.GetDashRightTileWidth();
428 geo.height += style.GetDashBottomTileHeight();430 geo.height += style.GetDashBottomTileHeight();
@@ -854,11 +856,11 @@
854856
855 std::string form_factor("unknown");857 std::string form_factor("unknown");
856858
857 if (Settings::Instance().GetFormFactor() == FormFactor::NETBOOK)859 if (Settings::Instance().form_factor() == FormFactor::NETBOOK)
858 form_factor = "netbook";860 form_factor = "netbook";
859 else if (Settings::Instance().GetFormFactor() == FormFactor::DESKTOP)861 else if (Settings::Instance().form_factor() == FormFactor::DESKTOP)
860 form_factor = "desktop";862 form_factor = "desktop";
861 else if (Settings::Instance().GetFormFactor() == FormFactor::TV)863 else if (Settings::Instance().form_factor() == FormFactor::TV)
862 form_factor = "tv";864 form_factor = "tv";
863865
864 unity::variant::BuilderWrapper wrapper(builder);866 unity::variant::BuilderWrapper wrapper(builder);
865867
=== modified file 'panel/WindowButtons.cpp'
--- panel/WindowButtons.cpp 2012-07-06 22:36:27 +0000
+++ panel/WindowButtons.cpp 2012-09-18 13:56:19 +0000
@@ -395,7 +395,7 @@
395395
396 ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &WindowButtons::OnOverlayShown));396 ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &WindowButtons::OnOverlayShown));
397 ubus_manager_.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &WindowButtons::OnOverlayHidden));397 ubus_manager_.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &WindowButtons::OnOverlayHidden));
398 Settings::Instance().changed.connect(sigc::mem_fun(this, &WindowButtons::OnDashSettingsUpdated));398 Settings::Instance().form_factor.changed.connect(sigc::mem_fun(this, &WindowButtons::OnDashSettingsUpdated));
399}399}
400400
401nux::Area* WindowButtons::FindAreaUnderMouse(const nux::Point& mouse, nux::NuxEventType event_type)401nux::Area* WindowButtons::FindAreaUnderMouse(const nux::Point& mouse, nux::NuxEventType event_type)
@@ -470,7 +470,7 @@
470470
471 if (win_button->IsOverlayOpen())471 if (win_button->IsOverlayOpen())
472 {472 {
473 Settings::Instance().SetFormFactor(FormFactor::DESKTOP);473 Settings::Instance().form_factor = FormFactor::DESKTOP;
474 }474 }
475 else475 else
476 {476 {
@@ -494,7 +494,7 @@
494494
495 if (win_button->IsOverlayOpen())495 if (win_button->IsOverlayOpen())
496 {496 {
497 Settings::Instance().SetFormFactor(FormFactor::NETBOOK);497 Settings::Instance().form_factor = FormFactor::NETBOOK;
498 }498 }
499499
500 maximize_clicked.emit();500 maximize_clicked.emit();
@@ -550,7 +550,7 @@
550 if (restore_button && maximize_button)550 if (restore_button && maximize_button)
551 {551 {
552 Settings &dash_settings = Settings::Instance();552 Settings &dash_settings = Settings::Instance();
553 bool maximizable = (dash_settings.GetFormFactor() == FormFactor::DESKTOP);553 bool maximizable = (dash_settings.form_factor() == FormFactor::DESKTOP);
554554
555 restore_button->SetEnabled(can_maximise);555 restore_button->SetEnabled(can_maximise);
556 maximize_button->SetEnabled(can_maximise);556 maximize_button->SetEnabled(can_maximise);
@@ -645,7 +645,7 @@
645 }645 }
646}646}
647647
648void WindowButtons::OnDashSettingsUpdated()648void WindowButtons::OnDashSettingsUpdated(FormFactor form_factor)
649{649{
650 WindowButton* maximize_button = nullptr;650 WindowButton* maximize_button = nullptr;
651 WindowButton* restore_button = nullptr;651 WindowButton* restore_button = nullptr;
@@ -672,8 +672,7 @@
672672
673 if (restore_button && restore_button->IsOverlayOpen() && maximize_button)673 if (restore_button && restore_button->IsOverlayOpen() && maximize_button)
674 {674 {
675 Settings &dash_settings = Settings::Instance();675 bool maximizable = (form_factor == FormFactor::DESKTOP);
676 bool maximizable = (dash_settings.GetFormFactor() == FormFactor::DESKTOP);
677676
678 if (maximizable != maximize_button->IsVisible())677 if (maximizable != maximize_button->IsVisible())
679 {678 {
680679
=== modified file 'panel/WindowButtons.h'
--- panel/WindowButtons.h 2012-05-06 23:48:38 +0000
+++ panel/WindowButtons.h 2012-09-18 13:56:19 +0000
@@ -26,6 +26,7 @@
2626
27#include "unity-shared/UBusWrapper.h"27#include "unity-shared/UBusWrapper.h"
28#include "unity-shared/Introspectable.h"28#include "unity-shared/Introspectable.h"
29#include "unity-shared/UnitySettings.h"
2930
30namespace unity31namespace unity
31{32{
@@ -70,7 +71,7 @@
70 void OnMaximizeClicked(nux::Button *button);71 void OnMaximizeClicked(nux::Button *button);
71 void OnOverlayShown(GVariant* data);72 void OnOverlayShown(GVariant* data);
72 void OnOverlayHidden(GVariant* data);73 void OnOverlayHidden(GVariant* data);
73 void OnDashSettingsUpdated();74 void OnDashSettingsUpdated(FormFactor form_factor);
7475
75 int monitor_;76 int monitor_;
76 double opacity_;77 double opacity_;
7778
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2012-09-17 14:07:30 +0000
+++ tests/CMakeLists.txt 2012-09-18 13:56:19 +0000
@@ -231,6 +231,7 @@
231 test_texture_cache.cpp231 test_texture_cache.cpp
232 test_thumbnail_generator.cpp232 test_thumbnail_generator.cpp
233 test_launcher_minimize_speed.cpp233 test_launcher_minimize_speed.cpp
234 test_unity_settings.cpp
234 test_volume_imp.cpp235 test_volume_imp.cpp
235 test_volume_launcher_icon.cpp236 test_volume_launcher_icon.cpp
236 gmockmount.c237 gmockmount.c
237238
=== added file 'tests/test_unity_settings.cpp'
--- tests/test_unity_settings.cpp 1970-01-01 00:00:00 +0000
+++ tests/test_unity_settings.cpp 2012-09-18 13:56:19 +0000
@@ -0,0 +1,110 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * version 3 along with this program. If not, see
15 * <http://www.gnu.org/licenses/>
16 *
17 * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
18 *
19 */
20
21#include <gio/gio.h>
22#include <gtest/gtest.h>
23
24#include "test_utils.h"
25#include "unity-shared/UnitySettings.h"
26
27#include <UnityCore/GLibWrapper.h>
28
29namespace
30{
31
32class TestUnitySettings : public testing::Test
33{
34public:
35 unity::glib::Object<GSettings> gsettings;
36 std::unique_ptr<unity::Settings> unity_settings;
37
38 void SetUp()
39 {
40 g_setenv("GSETTINGS_BACKEND", "memory", TRUE);
41
42 gsettings = g_settings_new("com.canonical.Unity");
43 g_settings_set_enum(gsettings, "form-factor", static_cast<int>(unity::FormFactor::DESKTOP));
44
45 unity_settings.reset(new unity::Settings);
46 }
47
48 void TearDown()
49 {
50 g_setenv("GSETTINGS_BACKEND", "", TRUE);
51 }
52};
53
54TEST_F(TestUnitySettings, SetFormFactor)
55{
56 unity_settings->form_factor = unity::FormFactor::NETBOOK;
57
58 int raw_form_factor = g_settings_get_enum(gsettings, "form-factor");
59 EXPECT_EQ(raw_form_factor, static_cast<int>(unity::FormFactor::NETBOOK));
60}
61
62TEST_F(TestUnitySettings, GetFormFactor)
63{
64 EXPECT_EQ(unity_settings->form_factor(), unity::FormFactor::DESKTOP);
65
66 g_settings_set_enum(gsettings, "form-factor", static_cast<int>(unity::FormFactor::NETBOOK));
67 EXPECT_EQ(unity_settings->form_factor(), unity::FormFactor::NETBOOK);
68}
69
70TEST_F(TestUnitySettings, FormFactorChangedSignal_Extern)
71{
72 bool signal_received = false;
73 unity::FormFactor new_form_factor;
74 unity_settings->form_factor.changed.connect([&](unity::FormFactor form_factor) {
75 signal_received = true;
76 new_form_factor = form_factor;
77 });
78
79 g_settings_set_enum(gsettings, "form-factor", static_cast<int>(unity::FormFactor::NETBOOK));
80 Utils::WaitUntil(signal_received);
81 EXPECT_EQ(new_form_factor, unity::FormFactor::NETBOOK);
82}
83
84TEST_F(TestUnitySettings, FormFactorChangedSignal_Extern_OtherKeys)
85{
86 bool signal_received = false;
87 unity_settings->form_factor.changed.connect([&](unity::FormFactor form_factor) {
88 signal_received = true;
89 });
90
91 g_settings_set_int(gsettings, "minimize-count", 0);
92 Utils::WaitForTimeout(1);
93 EXPECT_FALSE(signal_received);
94}
95
96TEST_F(TestUnitySettings, FormFactorChangedSignal_Inter)
97{
98 bool signal_received = false;
99 unity::FormFactor new_form_factor;
100 unity_settings->form_factor.changed.connect([&](unity::FormFactor form_factor) {
101 signal_received = true;
102 new_form_factor = form_factor;
103 });
104
105 unity_settings->form_factor = unity::FormFactor::NETBOOK;
106 Utils::WaitUntil(signal_received);
107 EXPECT_EQ(new_form_factor, unity::FormFactor::NETBOOK);
108}
109
110}
0111
=== modified file 'unity-shared/DashStyle.cpp'
--- unity-shared/DashStyle.cpp 2012-09-16 23:45:17 +0000
+++ unity-shared/DashStyle.cpp 2012-09-18 13:56:19 +0000
@@ -427,14 +427,14 @@
427 style_instance = this;427 style_instance = this;
428 }428 }
429429
430 auto formfactor_lambda = [this] () 430 auto formfactor_lambda = [this] (FormFactor)
431 {431 {
432 FormFactor formfactor = Settings::Instance().GetFormFactor();432 FormFactor formfactor = Settings::Instance().form_factor();
433 always_maximised = (formfactor == FormFactor::NETBOOK || formfactor == FormFactor::TV); 433 always_maximised = (formfactor == FormFactor::NETBOOK || formfactor == FormFactor::TV);
434 };434 };
435435
436 Settings::Instance().changed.connect(formfactor_lambda);436 Settings::Instance().form_factor.changed.connect(formfactor_lambda);
437 formfactor_lambda();437 formfactor_lambda(FormFactor());
438}438}
439439
440Style::~Style ()440Style::~Style ()
441441
=== modified file 'unity-shared/OverlayRenderer.cpp'
--- unity-shared/OverlayRenderer.cpp 2012-09-14 10:26:33 +0000
+++ unity-shared/OverlayRenderer.cpp 2012-09-18 13:56:19 +0000
@@ -438,7 +438,7 @@
438 bool paint_blur = BackgroundEffectHelper::blur_type != BLUR_NONE;438 bool paint_blur = BackgroundEffectHelper::blur_type != BLUR_NONE;
439 nux::Geometry geo(content_geo);439 nux::Geometry geo(content_geo);
440440
441 int excess_border = (Settings::Instance().GetFormFactor() != FormFactor::NETBOOK || force_edges) ? EXCESS_BORDER : 0;441 int excess_border = (Settings::Instance().form_factor() != FormFactor::NETBOOK || force_edges) ? EXCESS_BORDER : 0;
442442
443 nux::Geometry larger_content_geo = content_geo;443 nux::Geometry larger_content_geo = content_geo;
444 larger_content_geo.OffsetSize(excess_border, excess_border);444 larger_content_geo.OffsetSize(excess_border, excess_border);
@@ -578,7 +578,7 @@
578 }578 }
579579
580580
581 if (Settings::Instance().GetFormFactor() != FormFactor::NETBOOK || force_edges)581 if (Settings::Instance().form_factor() != FormFactor::NETBOOK || force_edges)
582 {582 {
583 // Paint the edges583 // Paint the edges
584 {584 {
@@ -835,7 +835,7 @@
835 nux::Geometry geo = geometry;835 nux::Geometry geo = geometry;
836 bgs = 0;836 bgs = 0;
837837
838 int excess_border = (Settings::Instance().GetFormFactor() != FormFactor::NETBOOK) ? EXCESS_BORDER : 0;838 int excess_border = (Settings::Instance().form_factor() != FormFactor::NETBOOK) ? EXCESS_BORDER : 0;
839839
840 nux::Geometry larger_content_geo = content_geo;840 nux::Geometry larger_content_geo = content_geo;
841 larger_content_geo.OffsetSize(excess_border, excess_border);841 larger_content_geo.OffsetSize(excess_border, excess_border);
842842
=== modified file 'unity-shared/PanelStyle.cpp'
--- unity-shared/PanelStyle.cpp 2012-08-29 18:29:18 +0000
+++ unity-shared/PanelStyle.cpp 2012-09-18 13:56:19 +0000
@@ -73,12 +73,12 @@
73 style_instance = this;73 style_instance = this;
74 }74 }
7575
76 if (Settings::Instance().GetFormFactor() == FormFactor::TV)76 if (Settings::Instance().form_factor() == FormFactor::TV)
77 panel_height = 0;77 panel_height = 0;
78 78
79 Settings::Instance().changed.connect([this]() 79 Settings::Instance().form_factor.changed.connect([this](FormFactor form_factor)
80 {80 {
81 if (Settings::Instance().GetFormFactor() == FormFactor::TV)81 if (form_factor == FormFactor::TV)
82 panel_height = 0;82 panel_height = 0;
83 });83 });
8484
8585
=== modified file 'unity-shared/UnitySettings.cpp'
--- unity-shared/UnitySettings.cpp 2012-05-22 14:33:41 +0000
+++ unity-shared/UnitySettings.cpp 2012-09-18 13:56:19 +0000
@@ -1,6 +1,6 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*2/*
3* Copyright (C) 2010, 2011 Canonical Ltd3* Copyright (C) 2010, 2011, 2012 Canonical Ltd
4*4*
5* This program is free software: you can redistribute it and/or modify5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License version 3 as6* it under the terms of the GNU General Public License version 3 as
@@ -15,6 +15,7 @@
15* along with this program. If not, see <http://www.gnu.org/licenses/>.15* along with this program. If not, see <http://www.gnu.org/licenses/>.
16*16*
17* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>17* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
18* Andrea Azzarone <andrea.azzarone@canonical.com>
18*/19*/
1920
20#include <gdk/gdk.h>21#include <gdk/gdk.h>
@@ -32,81 +33,69 @@
32nux::logging::Logger logger("unity");33nux::logging::Logger logger("unity");
3334
34Settings* settings_instance = nullptr;35Settings* settings_instance = nullptr;
35const char* const FORM_FACTOR = "form-factor";36
37const std::string SETTINGS_NAME = "com.canonical.Unity";
38const std::string FORM_FACTOR = "form-factor";
36}39}
3740
41//
42// Start private implementation
43//
38class Settings::Impl44class Settings::Impl
39{45{
40public:46public:
41 Impl(Settings* owner);47 Impl(Settings* owner)
42 ~Impl();48 : parent_(owner)
4349 , gsettings_(g_settings_new(SETTINGS_NAME.c_str()))
44 FormFactor GetFormFactor() const;50 , cached_form_factor_(FormFactor::DESKTOP)
45 void SetFormFactor(FormFactor factor);51 {
4652 CacheFormFactor();
47private:53
48 void Refresh();54 form_factor_changed_.Connect(gsettings_, "changed::" + FORM_FACTOR, [this] (GSettings*, gchar*) {
49 static void Changed(GSettings* settings, gchar* key, Impl* self);55 CacheFormFactor();
5056 parent_->form_factor.changed.emit(cached_form_factor_);
51private:57 });
52 Settings* owner_;58 }
53 GSettings* settings_;59
54 FormFactor form_factor_;60 void CacheFormFactor()
61 {
62 int raw_from_factor = g_settings_get_enum(gsettings_, FORM_FACTOR.c_str());
63
64 if (raw_from_factor == 0) //Automatic
65 {
66 auto uscreen = UScreen::GetDefault();
67 int primary_monitor = uscreen->GetMonitorWithMouse();
68 auto const& geo = uscreen->GetMonitorGeometry(primary_monitor);
69
70 cached_form_factor_ = geo.height > 799 ? FormFactor::DESKTOP : FormFactor::NETBOOK;
71 }
72 else
73 {
74 cached_form_factor_ = static_cast<FormFactor>(raw_from_factor);
75 }
76 }
77
78 FormFactor GetFormFactor() const
79 {
80 return cached_form_factor_;
81 }
82
83 bool SetFormFactor(FormFactor factor)
84 {
85 g_settings_set_enum(gsettings_, FORM_FACTOR.c_str(), static_cast<int>(factor));
86 return true;
87 }
88
89 Settings* parent_;
90 glib::Object<GSettings> gsettings_;
91 FormFactor cached_form_factor_;
92
93 glib::Signal<void, GSettings*, gchar* > form_factor_changed_;
55};94};
5695
5796//
58Settings::Impl::Impl(Settings* owner)97// End private implementation
59 : owner_(owner)98//
60 , settings_(nullptr)
61 , form_factor_(FormFactor::DESKTOP)
62{
63 settings_ = g_settings_new("com.canonical.Unity");
64 g_signal_connect(settings_, "changed",
65 (GCallback)(Impl::Changed), this);
66 Refresh();
67}
68
69Settings::Impl::~Impl()
70{
71 g_object_unref(settings_);
72}
73
74void Settings::Impl::Refresh()
75{
76 int raw_from_factor = g_settings_get_enum(settings_, FORM_FACTOR);
77
78 if (raw_from_factor == 0) //Automatic
79 {
80 UScreen *uscreen = UScreen::GetDefault();
81 int primary_monitor = uscreen->GetMonitorWithMouse();
82 auto geo = uscreen->GetMonitorGeometry(primary_monitor);
83
84 form_factor_ = geo.height > 799 ? FormFactor::DESKTOP : FormFactor::NETBOOK;
85 }
86 else
87 {
88 form_factor_ = static_cast<FormFactor>(raw_from_factor);
89 }
90
91 owner_->changed.emit();
92}
93
94void Settings::Impl::Changed(GSettings* settings, char* key, Impl* self)
95{
96 self->Refresh();
97}
98
99FormFactor Settings::Impl::GetFormFactor() const
100{
101 return form_factor_;
102}
103
104void Settings::Impl::SetFormFactor(FormFactor factor)
105{
106 form_factor_ = factor;
107 g_settings_set_enum(settings_, FORM_FACTOR, static_cast<int>(factor));
108 owner_->changed.emit();
109}
11099
111Settings::Settings()100Settings::Settings()
112 : is_standalone(false)101 : is_standalone(false)
@@ -118,13 +107,15 @@
118 }107 }
119 else108 else
120 {109 {
110 form_factor.SetGetterFunction(sigc::mem_fun(*pimpl, &Impl::GetFormFactor));
111 form_factor.SetSetterFunction(sigc::mem_fun(*pimpl, &Impl::SetFormFactor));
112
121 settings_instance = this;113 settings_instance = this;
122 }114 }
123}115}
124116
125Settings::~Settings()117Settings::~Settings()
126{118{
127 delete pimpl;
128 if (settings_instance == this)119 if (settings_instance == this)
129 settings_instance = nullptr;120 settings_instance = nullptr;
130}121}
@@ -139,15 +130,5 @@
139 return *settings_instance;130 return *settings_instance;
140}131}
141132
142FormFactor Settings::GetFormFactor() const
143{
144 return pimpl->GetFormFactor();
145}
146
147void Settings::SetFormFactor(FormFactor factor)
148{
149 pimpl->SetFormFactor(factor);
150}
151
152133
153} // namespace unity134} // namespace unity
154135
=== modified file 'unity-shared/UnitySettings.h'
--- unity-shared/UnitySettings.h 2012-05-22 14:33:41 +0000
+++ unity-shared/UnitySettings.h 2012-09-18 13:56:19 +0000
@@ -1,6 +1,6 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*2/*
3* Copyright (C) 2010, 2011 Canonical Ltd3* Copyright (C) 2010, 2011, 2012 Canonical Ltd
4*4*
5* This program is free software: you can redistribute it and/or modify5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License version 3 as6* it under the terms of the GNU General Public License version 3 as
@@ -15,11 +15,13 @@
15* along with this program. If not, see <http://www.gnu.org/licenses/>.15* along with this program. If not, see <http://www.gnu.org/licenses/>.
16*16*
17* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>17* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
18* Andrea Azzarone <andrea.azzarone@canonical.com>
18*/19*/
1920
20#ifndef UNITY_SETTINGS_H21#ifndef UNITYSHELL_SETTINGS_H
21#define UNITY_SETTINGS_H22#define UNITYSHELL_SETTINGS_H
2223
24#include <memory>
23#include <sigc++/signal.h>25#include <sigc++/signal.h>
24#include <Nux/Nux.h>26#include <Nux/Nux.h>
2527
@@ -29,7 +31,7 @@
29enum class FormFactor31enum class FormFactor
30{32{
31 DESKTOP = 1,33 DESKTOP = 1,
32 NETBOOK = 2,34 NETBOOK,
33 TV35 TV
34};36};
3537
@@ -41,18 +43,14 @@
4143
42 static Settings& Instance();44 static Settings& Instance();
4345
44 // NOTE: could potentially refactor this into a nux::Property46 nux::RWProperty<FormFactor> form_factor;
45 FormFactor GetFormFactor() const;
46 void SetFormFactor(FormFactor factor);
47
48 nux::Property<bool> is_standalone;47 nux::Property<bool> is_standalone;
49 sigc::signal<void> changed;
5048
51private:49private:
52 class Impl;50 class Impl;
53 Impl* pimpl;51 std::unique_ptr<Impl> pimpl;
54};52};
5553
56}54}
5755
58#endif // UNITY_SETTINGS_H56#endif
5957
=== modified file 'unity-standalone/StandaloneUnity.cpp'
--- unity-standalone/StandaloneUnity.cpp 2012-09-11 13:57:19 +0000
+++ unity-standalone/StandaloneUnity.cpp 2012-09-18 13:56:19 +0000
@@ -160,7 +160,7 @@
160 // The instances for the pseudo-singletons.160 // The instances for the pseudo-singletons.
161 Settings settings;161 Settings settings;
162 settings.is_standalone = true;162 settings.is_standalone = true;
163 if (force_tv) Settings::Instance().SetFormFactor(FormFactor::TV);163 if (force_tv) Settings::Instance().form_factor(FormFactor::TV);
164 164
165 PluginAdapter::Initialize(NULL);165 PluginAdapter::Initialize(NULL);
166 dash::Style dash_style;166 dash::Style dash_style;