Merge lp:~3v1n0/unity/scale-factor-binding 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: 3738
Proposed branch: lp:~3v1n0/unity/scale-factor-binding
Merge into: lp:unity
Prerequisite: lp:~3v1n0/unity/dash-hidpi-cleanup
Diff against target: 2446 lines (+366/-381)
78 files modified
com.canonical.Unity.gschema.xml (+30/-0)
dash/DashController.cpp (+1/-1)
dash/DashController.h (+2/-1)
dash/ResultRendererHorizontalTile.cpp (+3/-7)
dash/ResultRendererTile.cpp (+4/-7)
dash/ResultView.cpp (+13/-0)
dash/ResultView.h (+1/-0)
debian/unity.migrations (+1/-0)
launcher/ApplicationLauncherIcon.cpp (+20/-5)
launcher/QuicklistMenuItem.cpp (+3/-14)
panel/PanelIndicatorEntryView.cpp (+1/-0)
plugins/unityshell/src/unityshell.cpp (+4/-5)
tests/data/external.gschema.xml (+15/-0)
tests/mock-application.h (+0/-2)
tests/test_action_link.cpp (+2/-1)
tests/test_bfb_launcher_icon.cpp (+0/-3)
tests/test_dash_controller.cpp (+0/-2)
tests/test_dashview.cpp (+0/-6)
tests/test_desktop_launcher_icon.cpp (+0/-2)
tests/test_device_launcher_section.cpp (+0/-3)
tests/test_error_preview.cpp (+0/-2)
tests/test_expo_launcher_icon.cpp (+0/-3)
tests/test_favorite_store_gsettings.cpp (+0/-9)
tests/test_filter_widgets.cpp (+0/-2)
tests/test_gnome_session_manager.cpp (+0/-4)
tests/test_gsettings_scopes.cpp (+0/-1)
tests/test_hud_button.cpp (+0/-2)
tests/test_hud_controller.cpp (+0/-2)
tests/test_hud_launcher_icon.cpp (+0/-2)
tests/test_hud_view.cpp (+0/-2)
tests/test_launcher.cpp (+0/-2)
tests/test_launcher_controller.cpp (+0/-2)
tests/test_launcher_icon.cpp (+0/-2)
tests/test_launcher_minimize_speed.cpp (+3/-11)
tests/test_launcher_tooltip.cpp (+0/-2)
tests/test_lockscreen_controller.cpp (+0/-2)
tests/test_main.cpp (+2/-1)
tests/test_panel_controller.cpp (+0/-2)
tests/test_panel_indicator_entry_dropdown_view.cpp (+0/-2)
tests/test_panel_indicators_view.cpp (+0/-2)
tests/test_panel_menu_view.cpp (+0/-2)
tests/test_panel_style.cpp (+1/-11)
tests/test_panel_view.cpp (+0/-2)
tests/test_previews_application.cpp (+0/-2)
tests/test_previews_generic.cpp (+0/-2)
tests/test_previews_movie.cpp (+0/-2)
tests/test_previews_music.cpp (+0/-2)
tests/test_previews_music_payment.cpp (+0/-2)
tests/test_previews_payment.cpp (+0/-2)
tests/test_previews_social.cpp (+0/-2)
tests/test_quicklist_manager.cpp (+0/-2)
tests/test_quicklist_view.cpp (+0/-2)
tests/test_result_renderer.cpp (+0/-2)
tests/test_scope_bar.cpp (+0/-2)
tests/test_scope_view.cpp (+0/-2)
tests/test_searchbar.cpp (+0/-2)
tests/test_session_controller.cpp (+0/-2)
tests/test_session_view.cpp (+0/-2)
tests/test_shortcut_controller.cpp (+0/-2)
tests/test_shortcut_view.cpp (+0/-2)
tests/test_single_monitor_launcher_icon.cpp (+0/-2)
tests/test_spread_filter.cpp (+0/-2)
tests/test_switcher_controller.h (+0/-4)
tests/test_switcher_view.cpp (+0/-2)
tests/test_text_input.cpp (+0/-2)
tests/test_unity_settings.cpp (+30/-36)
tests/test_unity_window_view.cpp (+0/-2)
tests/test_volume_launcher_icon.cpp (+0/-2)
tests/test_window_buttons.cpp (+0/-3)
tools/migration-scripts/02_unity_setup_text_scale_factor (+39/-0)
unity-shared/DashStyle.cpp (+17/-48)
unity-shared/DecorationStyle.cpp (+9/-9)
unity-shared/DecorationStyle.h (+1/-0)
unity-shared/IconLoader.cpp (+5/-12)
unity-shared/StaticCairoText.cpp (+9/-34)
unity-shared/UScreen.cpp (+2/-2)
unity-shared/UnitySettings.cpp (+147/-56)
unity-shared/UnitySettings.h (+1/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/scale-factor-binding
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
Eleni Maria Stea (community) Approve
Review via email: mp+212076@code.launchpad.net

Commit message

UnitySettings: apply the unity scaling factor to global system settings

We basically use the integer part of our scaling factor as the Gdk scaling factor,
while we apply the point scaling to the Gdk text-scaling-factor.
In this way the readable items will match our scaling.

Description of the change

Applying the scaling factors system-wide. To make this possible we needed to introduce some our "custom" settings to make all things to scale correctly both in unity and outside:

Inside com.canonical.Unity.Interface:
 - text-scale-factor: defines the extra text-scaling factor that can be used
   (for a11y reasons, for example). This is what is controlled by UCC.
 - cursor-scale-factor: custom scaling factor for the mouse cursor (to override
   auto computation, based on UI scaling)
 - app-scale-factor-monitor: the name of the monitor that should be used as
   "reference" for global scaling.
 - app-fallback-to-maximum-scale-factor: toggle the fallback to use the maximum
   scale value if the "reference" monitor is not available

The reason for having our own text-scaling factor is that we use the Gdk global value for scaling up applications, and thus we need to have our value for both scaling the text in unity and to know if the user has overridden it.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Eleni Maria Stea (hikiko) wrote :

+1! Very good job, it works well for me :)

review: Approve
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Looks good to me.

review: Approve
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Wait, we need to default false on scaling toolkit text...

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Nevermind, I guess it is correct

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'com.canonical.Unity.gschema.xml'
2--- com.canonical.Unity.gschema.xml 2014-02-18 18:01:22 +0000
3+++ com.canonical.Unity.gschema.xml 2014-03-21 23:09:12 +0000
4@@ -54,6 +54,36 @@
5 unity top panel</description>
6 </key>
7 </schema>
8+ <schema path="/com/canonical/unity/interface/" id="com.canonical.Unity.Interface" gettext-domain="unity">
9+ <key type="d" name="text-scale-factor">
10+ <default>1.0</default>
11+ <range min="0.5" max="3.0"/>
12+ <summary>Font scaling for unity and applications.</summary>
13+ <description>This value defines the global font scaling used by both
14+ unity and applications. It will match the current system font scaling.</description>
15+ </key>
16+ <key type="d" name="cursor-scale-factor">
17+ <default>1.0</default>
18+ <range min="0.5" max="3.0"/>
19+ <summary>Mouse cursor scaling.</summary>
20+ <description>This value defines the global mouse cursor scaling used by both
21+ unity and applications. Changing this value allows to use a custom scaling
22+ for the mouse cursor.</description>
23+ </key>
24+ <key type="s" name="app-scale-factor-monitor">
25+ <default>''</default>
26+ <summary>The name of the monitor that controls the global app scaling factor.</summary>
27+ <description>This value defines the monitor that unity will use (if found) as reference
28+ for scaling all the applications.</description>
29+ </key>
30+ <key type="b" name="app-fallback-to-maximum-scale-factor">
31+ <default>true</default>
32+ <summary>Use the maximum per-monitor scale-factor as application scale factor if no target monitor is found.</summary>
33+ <description>When this is enabled, the applications scale factor will match
34+ the scale factor of the monitor with the greater value, in case the monitor
35+ defined in 'app-scale-factor-monitor' is not provided or available.</description>
36+ </key>
37+ </schema>
38 <schema path="/com/canonical/unity/launcher/" id="com.canonical.Unity.Launcher" gettext-domain="unity">
39 <key type="as" name="favorites">
40 <default>[
41
42=== modified file 'dash/DashController.cpp'
43--- dash/DashController.cpp 2014-03-03 23:19:56 +0000
44+++ dash/DashController.cpp 2014-03-21 23:09:12 +0000
45@@ -92,7 +92,7 @@
46 SetupWindow();
47 UScreen::GetDefault()->changed.connect([this] (int, std::vector<nux::Geometry> const&) { Relayout(true); });
48
49- Settings::Instance().form_factor.changed.connect([this](FormFactor)
50+ form_factor_changed_ = Settings::Instance().form_factor.changed.connect([this] (FormFactor)
51 {
52 if (window_ && view_ && visible_)
53 {
54
55=== modified file 'dash/DashController.h'
56--- dash/DashController.h 2014-03-03 23:19:56 +0000
57+++ dash/DashController.h 2014-03-21 23:09:12 +0000
58@@ -68,7 +68,7 @@
59 bool IsCommandLensOpen() const;
60 nux::Geometry GetInputWindowGeometry();
61 nux::ObjectPtr<DashView> const& Dash() const;
62-
63+
64 int Monitor() const;
65
66 protected:
67@@ -108,6 +108,7 @@
68 bool need_show_;
69
70 connection::Wrapper screen_ungrabbed_slot_;
71+ connection::Wrapper form_factor_changed_;
72 glib::DBusServer dbus_server_;
73 glib::TimeoutSeconds ensure_timeout_;
74 nux::animation::AnimateValue<double> timeline_animator_;
75
76=== modified file 'dash/ResultRendererHorizontalTile.cpp'
77--- dash/ResultRendererHorizontalTile.cpp 2014-03-21 23:09:11 +0000
78+++ dash/ResultRendererHorizontalTile.cpp 2014-03-21 23:09:12 +0000
79@@ -30,6 +30,7 @@
80 #include "unity-shared/CairoTexture.h"
81 #include "unity-shared/TextureCache.h"
82 #include "unity-shared/RawPixel.h"
83+#include "unity-shared/UnitySettings.h"
84 #include <NuxGraphics/GdkGraphics.h>
85
86
87@@ -313,9 +314,6 @@
88 PangoFontDescription* desc = NULL;
89 PangoContext* pango_context = NULL;
90 GdkScreen* screen = gdk_screen_get_default(); // not ref'ed
91- int dpi = -1;
92-
93- g_object_get(gtk_settings_get_default(), "gtk-xft-dpi", &dpi, NULL);
94
95 cairo_set_font_options(cr, gdk_screen_get_font_options(screen));
96 layout = pango_cairo_create_layout(cr);
97@@ -338,10 +336,8 @@
98 pango_layout_set_markup(layout, final_text.str().c_str(), -1);
99
100 pango_context = pango_layout_get_context(layout); // is not ref'ed
101- pango_cairo_context_set_font_options(pango_context,
102- gdk_screen_get_font_options(screen));
103- pango_cairo_context_set_resolution(pango_context,
104- dpi == -1 ? 96.0f : dpi/(float) PANGO_SCALE);
105+ pango_cairo_context_set_font_options(pango_context, gdk_screen_get_font_options(screen));
106+ pango_cairo_context_set_resolution(pango_context, 96.0 * Settings::Instance().font_scaling());
107 pango_layout_context_changed(layout);
108
109 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
110
111=== modified file 'dash/ResultRendererTile.cpp'
112--- dash/ResultRendererTile.cpp 2014-03-21 23:09:11 +0000
113+++ dash/ResultRendererTile.cpp 2014-03-21 23:09:12 +0000
114@@ -32,6 +32,7 @@
115 #include "unity-shared/DashStyle.h"
116 #include "unity-shared/TextureCache.h"
117 #include "unity-shared/RawPixel.h"
118+#include "unity-shared/UnitySettings.h"
119
120 namespace unity
121 {
122@@ -48,7 +49,7 @@
123 char const REPLACEMENT_CHAR = '?';
124 float const CORNER_HIGHTLIGHT_RADIUS = 2.0f;
125
126-void RenderTexture(nux::GraphicsEngine& GfxContext,
127+void RenderTexture(nux::GraphicsEngine& GfxContext,
128 int x,
129 int y,
130 int width,
131@@ -485,10 +486,8 @@
132 PangoContext* pango_context = NULL;
133 GdkScreen* screen = gdk_screen_get_default(); // not ref'ed
134 glib::String font;
135- int dpi = -1;
136
137 g_object_get(gtk_settings_get_default(), "gtk-font-name", &font, NULL);
138- g_object_get(gtk_settings_get_default(), "gtk-xft-dpi", &dpi, NULL);
139
140 cairo_set_font_options(cr, gdk_screen_get_font_options(screen));
141 layout = pango_cairo_create_layout(cr);
142@@ -513,10 +512,8 @@
143 g_free (escaped_text);
144
145 pango_context = pango_layout_get_context(layout); // is not ref'ed
146- pango_cairo_context_set_font_options(pango_context,
147- gdk_screen_get_font_options(screen));
148- pango_cairo_context_set_resolution(pango_context,
149- dpi == -1 ? 96.0f : dpi/(float) PANGO_SCALE);
150+ pango_cairo_context_set_font_options(pango_context, gdk_screen_get_font_options(screen));
151+ pango_cairo_context_set_resolution(pango_context, 96.0 * Settings::Instance().font_scaling());
152 pango_layout_context_changed(layout);
153
154 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
155
156=== modified file 'dash/ResultView.cpp'
157--- dash/ResultView.cpp 2014-03-21 23:09:11 +0000
158+++ dash/ResultView.cpp 2014-03-21 23:09:12 +0000
159@@ -27,6 +27,7 @@
160
161 #include "unity-shared/IntrospectableWrappers.h"
162 #include "unity-shared/GraphicsUtils.h"
163+#include "unity-shared/UnitySettings.h"
164
165 namespace unity
166 {
167@@ -60,6 +61,7 @@
168 NeedRedraw();
169 });
170
171+ Settings::Instance().font_scaling.changed.connect(sigc::mem_fun(this, &ResultView::UpdateFontScale));
172 enable_texture_render.changed.connect(sigc::mem_fun(this, &ResultView::OnEnableRenderToTexture));
173 scale.changed.connect(sigc::mem_fun(this, &ResultView::UpdateScale));
174 }
175@@ -93,6 +95,17 @@
176 }
177 }
178
179+void ResultView::UpdateFontScale(double scale)
180+{
181+ if (renderer_)
182+ {
183+ for (auto const& result : *result_model_)
184+ renderer_->ReloadResult(result);
185+
186+ QueueDraw();
187+ }
188+}
189+
190 void ResultView::SetModelRenderer(ResultRenderer* renderer)
191 {
192 if (renderer_ != NULL)
193
194=== modified file 'dash/ResultView.h'
195--- dash/ResultView.h 2014-03-21 23:09:11 +0000
196+++ dash/ResultView.h 2014-03-21 23:09:12 +0000
197@@ -127,6 +127,7 @@
198 void OnRowAdded(DeeModel* model, DeeModelIter* iter);
199 void OnRowRemoved(DeeModel* model, DeeModelIter* iter);
200 void UpdateScale(double scale);
201+ void UpdateFontScale(double scale);
202
203 Result cached_result_;
204 connection::Manager result_connections_;
205
206=== modified file 'debian/unity.migrations'
207--- debian/unity.migrations 2012-07-19 10:22:37 +0000
208+++ debian/unity.migrations 2014-03-21 23:09:12 +0000
209@@ -1,1 +1,2 @@
210 tools/migration-scripts/01_unity_change_dconf_path
211+tools/migration-scripts/02_unity_setup_text_scale_factor
212
213=== modified file 'launcher/ApplicationLauncherIcon.cpp'
214--- launcher/ApplicationLauncherIcon.cpp 2014-03-17 20:58:25 +0000
215+++ launcher/ApplicationLauncherIcon.cpp 2014-03-21 23:09:12 +0000
216@@ -393,19 +393,34 @@
217 {
218 if (scaleWasActive) // #5 above
219 {
220- Focus(arg);
221+ if (minimize_window_on_click())
222+ {
223+ for (auto const& win : GetWindows(WindowFilter::ON_CURRENT_DESKTOP))
224+ wm.Minimize(win->window_id());
225+ }
226+ else
227+ {
228+ Focus(arg);
229+ }
230 }
231 else // #2 above
232 {
233 if (arg.source != ActionArg::Source::SWITCHER)
234 {
235- WindowList windows = GetWindows(WindowFilter::ON_CURRENT_DESKTOP);
236+ bool minimized = false;
237
238- if (windows.size() == 1 && minimize_window_on_click)
239+ if (minimize_window_on_click)
240 {
241- wm.Minimize(windows[0]->window_id());
242+ WindowList const& windows = GetWindows(WindowFilter::ON_CURRENT_DESKTOP);
243+
244+ if (windows.size() == 1)
245+ {
246+ wm.Minimize(windows[0]->window_id());
247+ minimized = true;
248+ }
249 }
250- else
251+
252+ if (!minimized)
253 {
254 Spread(true, 0, false);
255 }
256
257=== modified file 'launcher/QuicklistMenuItem.cpp'
258--- launcher/QuicklistMenuItem.cpp 2014-02-26 07:08:37 +0000
259+++ launcher/QuicklistMenuItem.cpp 2014-03-21 23:09:12 +0000
260@@ -22,6 +22,7 @@
261 #include <gtk/gtk.h>
262 #include "unity-shared/UBusWrapper.h"
263 #include "unity-shared/UBusMessages.h"
264+#include "unity-shared/UnitySettings.h"
265
266 #include "QuicklistMenuItem.h"
267
268@@ -320,21 +321,9 @@
269
270 PangoContext* pangoCtx = pango_layout_get_context(layout); // is not ref'ed
271 pango_cairo_context_set_font_options(pangoCtx, gdk_screen_get_font_options(screen));
272-
273- int dpi = 0;
274- g_object_get(settings, "gtk-xft-dpi", &dpi, nullptr);
275-
276- if (dpi == -1)
277- {
278- // use some default DPI-value
279- pango_cairo_context_set_resolution(pangoCtx, 96.0f);
280- }
281- else
282- {
283- pango_cairo_context_set_resolution(pangoCtx, static_cast<float>(dpi) / static_cast<float>(PANGO_SCALE));
284- }
285-
286+ pango_cairo_context_set_resolution(pangoCtx, 96.0 * Settings::Instance().font_scaling());
287 pango_layout_context_changed(layout);
288+
289 PangoRectangle log_rect = {0, 0, 0, 0};
290 pango_layout_get_extents(layout, nullptr, &log_rect);
291
292
293=== modified file 'panel/PanelIndicatorEntryView.cpp'
294--- panel/PanelIndicatorEntryView.cpp 2014-03-06 09:31:24 +0000
295+++ panel/PanelIndicatorEntryView.cpp 2014-03-21 23:09:12 +0000
296@@ -469,6 +469,7 @@
297 std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font.c_str()), pango_font_description_free);
298 pango_context_set_font_description(context, desc.get());
299 pango_context_set_language(context, gtk_get_default_language());
300+ pango_cairo_context_set_resolution(context, 96.0 * Settings::Instance().font_scaling());
301
302 label.erase(std::remove(label.begin(), label.end(), '_'), label.end());
303 layout = pango_layout_new(context);
304
305=== modified file 'plugins/unityshell/src/unityshell.cpp'
306--- plugins/unityshell/src/unityshell.cpp 2014-03-20 23:51:34 +0000
307+++ plugins/unityshell/src/unityshell.cpp 2014-03-21 23:09:12 +0000
308@@ -2855,8 +2855,7 @@
309 {
310 if ((window->type() != CompWindowTypePopupMenuMask ||
311 !uScreen->lockscreen_controller_->HasOpenMenu()) &&
312- window->resName() != "onboard" &&
313- !window->minimized())
314+ !window->minimized() && window->resName() != "onboard")
315 {
316 // For some reasons PAINT_WINDOW_NO_CORE_INSTANCE_MASK doesn't work here
317 // (well, it works too much, as it applies to menus too), so we need
318@@ -3736,9 +3735,9 @@
319
320 launcher_controller_->ClearTooltips();
321
322- auto& adapter = PluginAdapter::Default();
323- if (adapter.IsScaleActive())
324- adapter.TerminateScale();
325+ auto& wm = WindowManager::Default();
326+ if (wm.IsScaleActive())
327+ wm.TerminateScale();
328
329 RaiseOSK();
330 }
331
332=== modified file 'tests/data/external.gschema.xml'
333--- tests/data/external.gschema.xml 2014-03-06 21:37:11 +0000
334+++ tests/data/external.gschema.xml 2014-03-21 23:09:12 +0000
335@@ -53,6 +53,21 @@
336 </key>
337 </schema>
338
339+ <schema id="org.gnome.desktop.interface" path="/org/gnome/desktop/interface/">
340+ <key type="u" name="scaling-factor">
341+ <default>1</default>
342+ </key>
343+ <key type="d" name="text-scaling-factor">
344+ <default>1.0</default>
345+ </key>
346+ <key type="s" name="font-name">
347+ <default>'Ubuntu 11'</default>
348+ </key>
349+ <key type="i" name="cursor-size">
350+ <default>24</default>
351+ </key>
352+ </schema>
353+
354 <schema id="com.canonical.unity-greeter" path="/com/canonical/unity-greeter/">
355 <key type="s" name="logo">
356 <default>'/usr/share/unity-greeter/logo.png'</default>
357
358=== modified file 'tests/mock-application.h'
359--- tests/mock-application.h 2014-02-18 01:20:01 +0000
360+++ tests/mock-application.h 2014-03-21 23:09:12 +0000
361@@ -27,7 +27,6 @@
362
363 #include "unity-shared/ApplicationManager.h"
364 #include "unity-shared/WindowManager.h"
365-#include "unity-shared/UnitySettings.h"
366
367 using namespace testing;
368
369@@ -379,7 +378,6 @@
370 unity_app_->actions_log_.clear();
371 }
372
373- unity::Settings settings;
374 MockApplication::Ptr unity_app_;
375 };
376
377
378=== modified file 'tests/test_action_link.cpp'
379--- tests/test_action_link.cpp 2013-01-22 16:01:18 +0000
380+++ tests/test_action_link.cpp 2014-03-21 23:09:12 +0000
381@@ -22,7 +22,7 @@
382 #include <gmock/gmock.h>
383 #include <gtest/gtest.h>
384
385-#include <unity-shared/StaticCairoText.h>
386+#include "unity-shared/StaticCairoText.h"
387
388 #include "dash/previews/ActionLink.cpp"
389 #include "test_utils.h"
390@@ -75,6 +75,7 @@
391 {
392 action_link = new ActionLinkMock("action_id", "display_name");
393 }
394+
395 nux::ObjectPtr<ActionLinkMock> action_link;
396 };
397
398
399=== modified file 'tests/test_bfb_launcher_icon.cpp'
400--- tests/test_bfb_launcher_icon.cpp 2014-02-18 01:20:01 +0000
401+++ tests/test_bfb_launcher_icon.cpp 2014-03-21 23:09:12 +0000
402@@ -19,8 +19,6 @@
403
404 #include <gmock/gmock.h>
405
406-#include "unity-shared/UnitySettings.h"
407-
408 #include "BFBLauncherIcon.h"
409
410 using namespace unity;
411@@ -39,7 +37,6 @@
412
413 struct TestBFBLauncherIcon : testing::Test
414 {
415- unity::Settings settings;
416 MockBFBLauncherIcon bfb;
417 };
418
419
420=== modified file 'tests/test_dash_controller.cpp'
421--- tests/test_dash_controller.cpp 2013-10-14 16:45:07 +0000
422+++ tests/test_dash_controller.cpp 2014-03-21 23:09:12 +0000
423@@ -20,7 +20,6 @@
424 #include "mock-base-window.h"
425 #include "unity-shared/DashStyle.h"
426 #include "unity-shared/PanelStyle.h"
427-#include "unity-shared/UnitySettings.h"
428 #include "unity-shared/WindowManager.h"
429 #include "test_utils.h"
430
431@@ -46,7 +45,6 @@
432 nux::animation::AnimationController animation_controller;
433
434 // required to create hidden secret global variables
435- Settings unity_settings_;
436 dash::Style dash_style_;
437 panel::Style panel_style_;
438
439
440=== modified file 'tests/test_dashview.cpp'
441--- tests/test_dashview.cpp 2013-11-06 11:21:43 +0000
442+++ tests/test_dashview.cpp 2014-03-21 23:09:12 +0000
443@@ -32,10 +32,8 @@
444 #include "dash/ApplicationStarter.h"
445 #include "unity-shared/DashStyle.h"
446 #include "unity-shared/PanelStyle.h"
447-#include "unity-shared/UnitySettings.h"
448
449 #include "test_mock_scope.h"
450-#include "test_utils.h"
451
452 using namespace unity;
453 using namespace unity::dash;
454@@ -70,9 +68,6 @@
455 {}
456 virtual ~TestDashView() {}
457
458- virtual void SetUp() { Utils::init_gsettings_test_environment(); }
459- virtual void TearDown() { Utils::reset_gsettings_test_environment(); }
460-
461 class MockDashView : public DashView
462 {
463 public:
464@@ -86,7 +81,6 @@
465 };
466
467 protected:
468- Settings unity_settings_;
469 dash::Style dash_style_;
470 panel::Style panel_style_;
471 MockApplicationStarter::Ptr application_starter_;
472
473=== modified file 'tests/test_desktop_launcher_icon.cpp'
474--- tests/test_desktop_launcher_icon.cpp 2014-02-18 01:20:01 +0000
475+++ tests/test_desktop_launcher_icon.cpp 2014-03-21 23:09:12 +0000
476@@ -19,7 +19,6 @@
477
478 #include <gmock/gmock.h>
479
480-#include "unity-shared/UnitySettings.h"
481 #include "unity-shared/WindowManager.h"
482 #include "launcher/DesktopLauncherIcon.h"
483
484@@ -31,7 +30,6 @@
485
486 struct TestDesktopLauncherIcon : testing::Test
487 {
488- unity::Settings settings;
489 DesktopLauncherIcon icon;
490 };
491
492
493=== modified file 'tests/test_device_launcher_section.cpp'
494--- tests/test_device_launcher_section.cpp 2014-02-18 01:20:01 +0000
495+++ tests/test_device_launcher_section.cpp 2014-03-21 23:09:12 +0000
496@@ -22,8 +22,6 @@
497
498 #include <gmock/gmock.h>
499
500-#include "unity-shared/UnitySettings.h"
501-
502 #include "DevicesSettings.h"
503 #include "test_mock_devices.h"
504 #include "test_utils.h"
505@@ -60,7 +58,6 @@
506 , section_(monitor_, devices_settings_, notifications_)
507 {}
508
509- unity::Settings settings_;
510 MockVolumeMonitorWrapper::Ptr monitor_;
511 DevicesSettings::Ptr devices_settings_;
512 DeviceNotificationDisplay::Ptr notifications_;
513
514=== modified file 'tests/test_error_preview.cpp'
515--- tests/test_error_preview.cpp 2013-03-21 16:33:03 +0000
516+++ tests/test_error_preview.cpp 2014-03-21 23:09:12 +0000
517@@ -28,7 +28,6 @@
518 #include <unity-shared/DashStyle.h>
519 #include <unity-shared/PreviewStyle.h>
520 #include <unity-shared/ThumbnailGenerator.h>
521-#include "unity-shared/UnitySettings.h"
522
523 #include <unity-protocol.h>
524 #include "dash/previews/ErrorPreview.h"
525@@ -100,7 +99,6 @@
526 UnityProtocolPreviewPaymentType preview_type;
527
528 // needed for styles
529- unity::Settings settings;
530 dash::Style dash_style;
531 };
532
533
534=== modified file 'tests/test_expo_launcher_icon.cpp'
535--- tests/test_expo_launcher_icon.cpp 2014-02-18 01:20:01 +0000
536+++ tests/test_expo_launcher_icon.cpp 2014-03-21 23:09:12 +0000
537@@ -23,8 +23,6 @@
538 #include "launcher/ExpoLauncherIcon.h"
539 #include "test_standalone_wm.h"
540
541-#include "unity-shared/UnitySettings.h"
542-
543 using namespace unity;
544 using namespace unity::launcher;
545
546@@ -33,7 +31,6 @@
547
548 struct TestExpoLauncherIcon : testing::Test
549 {
550- unity::Settings settings;
551 ExpoLauncherIcon icon;
552 testwrapper::StandaloneWM wm;
553 };
554
555=== modified file 'tests/test_favorite_store_gsettings.cpp'
556--- tests/test_favorite_store_gsettings.cpp 2013-11-06 11:21:43 +0000
557+++ tests/test_favorite_store_gsettings.cpp 2014-03-21 23:09:12 +0000
558@@ -23,7 +23,6 @@
559 #include <gmock/gmock.h>
560 #include <glib.h>
561
562-#include "test_utils.h"
563 #include "FavoriteStore.h"
564 #include "FavoriteStoreGSettings.h"
565
566@@ -77,20 +76,12 @@
567
568 virtual void SetUp()
569 {
570- // set the data directory so gsettings can find the schema
571- Utils::init_gsettings_test_environment();
572-
573 favorite_store.reset(new internal::FavoriteStoreGSettings());
574
575 // Setting the test values
576 gsettings_client = g_settings_new(SETTINGS_NAME);
577 g_settings_set_strv(gsettings_client, SETTINGS_KEY, base_store_favs);
578 }
579-
580- virtual void TearDown()
581- {
582- Utils::reset_gsettings_test_environment();
583- }
584 };
585
586 TEST_F(TestFavoriteStoreGSettings, TestAllocation)
587
588=== modified file 'tests/test_filter_widgets.cpp'
589--- tests/test_filter_widgets.cpp 2012-12-20 10:42:49 +0000
590+++ tests/test_filter_widgets.cpp 2014-03-21 23:09:12 +0000
591@@ -24,7 +24,6 @@
592 #include <gtest/gtest.h>
593 #include "test_filter_multirange.h"
594 #include "unity-shared/DashStyle.h"
595-#include "unity-shared/UnitySettings.h"
596
597 #include <Nux/Nux.h>
598 #include <NuxGraphics/Events.h>
599@@ -113,7 +112,6 @@
600 FALSE);
601 }
602
603- Settings unity_settings_;
604 dash::Style dash_style_;
605
606 glib::Object<DeeModel> model_;
607
608=== modified file 'tests/test_gnome_session_manager.cpp'
609--- tests/test_gnome_session_manager.cpp 2014-03-10 19:38:01 +0000
610+++ tests/test_gnome_session_manager.cpp 2014-03-21 23:09:12 +0000
611@@ -134,8 +134,6 @@
612 {
613 static void SetUpTestCase()
614 {
615- Utils::init_gsettings_test_environment();
616-
617 can_shutdown_ = (g_random_int() % 2) ? true : false;
618 can_suspend_ = (g_random_int() % 2) ? true : false;
619 can_hibernate_ = (g_random_int() % 2) ? true : false;
620@@ -246,8 +244,6 @@
621
622 static void TearDownTestCase()
623 {
624- Utils::reset_gsettings_test_environment();
625-
626 bool cancelled = false;
627 bool closed = false;
628 shell_proxy_->Connect("Canceled", [&cancelled] (GVariant*) { cancelled = true; });
629
630=== modified file 'tests/test_gsettings_scopes.cpp'
631--- tests/test_gsettings_scopes.cpp 2013-11-06 11:21:43 +0000
632+++ tests/test_gsettings_scopes.cpp 2014-03-21 23:09:12 +0000
633@@ -52,7 +52,6 @@
634 public:
635 TestGSettingsScopes():scope_added(0),scope_removed(0),scopes_reordered(0)
636 {}
637- virtual ~TestGSettingsScopes() {}
638
639 virtual void SetUp() { Utils::init_gsettings_test_environment(); }
640 virtual void TearDown() { Utils::reset_gsettings_test_environment(); }
641
642=== modified file 'tests/test_hud_button.cpp'
643--- tests/test_hud_button.cpp 2012-12-14 12:14:34 +0000
644+++ tests/test_hud_button.cpp 2014-03-21 23:09:12 +0000
645@@ -28,7 +28,6 @@
646 #include "hud/HudButton.h"
647 #include "unity-shared/DashStyle.h"
648 #include "unity-shared/StaticCairoText.h"
649-#include "unity-shared/UnitySettings.h"
650
651 using namespace unity;
652
653@@ -37,7 +36,6 @@
654
655 TEST(TestHudButton, TestLabelOpacity)
656 {
657- Settings unity_settings;
658 dash::Style dash_style;
659 nux::ObjectPtr<hud::HudButton> button(new hud::HudButton());
660 nux::Layout* layout = button->GetLayout();
661
662=== modified file 'tests/test_hud_controller.cpp'
663--- tests/test_hud_controller.cpp 2013-11-14 00:17:19 +0000
664+++ tests/test_hud_controller.cpp 2014-03-21 23:09:12 +0000
665@@ -27,7 +27,6 @@
666 #include "mock-base-window.h"
667 #include "unity-shared/DashStyle.h"
668 #include "unity-shared/PanelStyle.h"
669-#include "unity-shared/UnitySettings.h"
670 #include "unity-shared/WindowManager.h"
671 #include "test_utils.h"
672 using namespace unity;
673@@ -74,7 +73,6 @@
674
675 protected:
676 // required to create hidden secret global variables
677- Settings unity_settings_;
678 dash::Style dash_style_;
679 panel::Style panel_style_;
680
681
682=== modified file 'tests/test_hud_launcher_icon.cpp'
683--- tests/test_hud_launcher_icon.cpp 2014-02-18 01:20:01 +0000
684+++ tests/test_hud_launcher_icon.cpp 2014-03-21 23:09:12 +0000
685@@ -21,7 +21,6 @@
686
687 #include "HudLauncherIcon.h"
688
689-#include "unity-shared/UnitySettings.h"
690
691 using namespace unity;
692 using namespace unity::launcher;
693@@ -39,7 +38,6 @@
694
695 struct TestHudLauncherIcon : testing::Test
696 {
697- unity::Settings settings;
698 MockHudLauncherIcon hud;
699 };
700
701
702=== modified file 'tests/test_hud_view.cpp'
703--- tests/test_hud_view.cpp 2013-02-21 10:47:14 +0000
704+++ tests/test_hud_view.cpp 2014-03-21 23:09:12 +0000
705@@ -31,7 +31,6 @@
706 #include "hud/HudView.h"
707 #include "unity-shared/DashStyle.h"
708 #include "unity-shared/PanelStyle.h"
709-#include "unity-shared/UnitySettings.h"
710
711 using namespace unity;
712
713@@ -40,7 +39,6 @@
714
715 TEST(TestHudView, TestSetQueries)
716 {
717- Settings unity_settings;
718 dash::Style dash_style;
719 panel::Style panel_style;
720 nux::ObjectPtr<hud::View> view(new hud::View());
721
722=== modified file 'tests/test_launcher.cpp'
723--- tests/test_launcher.cpp 2014-02-26 02:23:26 +0000
724+++ tests/test_launcher.cpp 2014-03-21 23:09:12 +0000
725@@ -29,7 +29,6 @@
726 #include "launcher/MockLauncherIcon.h"
727 #include "launcher/Launcher.h"
728 #include "unity-shared/PanelStyle.h"
729-#include "unity-shared/UnitySettings.h"
730 #include "unity-shared/IconRenderer.h"
731 #include "unity-shared/UBusMessages.h"
732 #include "test_standalone_wm.h"
733@@ -187,7 +186,6 @@
734 return icons;
735 }
736
737- Settings settings;
738 panel::Style panel_style;
739 MockUScreen uscreen;
740 testwrapper::StandaloneWM WM;
741
742=== modified file 'tests/test_launcher_controller.cpp'
743--- tests/test_launcher_controller.cpp 2014-03-05 20:21:53 +0000
744+++ tests/test_launcher_controller.cpp 2014-03-21 23:09:12 +0000
745@@ -33,7 +33,6 @@
746 #include "VolumeLauncherIcon.h"
747 #include "SoftwareCenterLauncherIcon.h"
748 #include "PanelStyle.h"
749-#include "UnitySettings.h"
750 #include "UBusMessages.h"
751 #include "logger_helper.h"
752 #include "test_utils.h"
753@@ -279,7 +278,6 @@
754
755 std::shared_ptr<helper::CaptureLogOutput> logger_output_;
756 MockUScreen uscreen;
757- Settings settings;
758 panel::Style panel_style;
759 MockFavoriteStore favorite_store;
760 MockXdndManager::Ptr xdnd_manager_;
761
762=== modified file 'tests/test_launcher_icon.cpp'
763--- tests/test_launcher_icon.cpp 2013-10-21 23:37:54 +0000
764+++ tests/test_launcher_icon.cpp 2014-03-21 23:09:12 +0000
765@@ -21,7 +21,6 @@
766 #include <Nux/NuxTimerTickSource.h>
767
768 #include "LauncherIcon.h"
769-#include "UnitySettings.h"
770
771 using namespace unity;
772 using namespace unity::launcher;
773@@ -71,7 +70,6 @@
774 nux::NuxTimerTickSource tick_source_;
775 nux::animation::AnimationController animation_controller;
776 unsigned animations_tick_;
777- unity::Settings settings;
778 MockLauncherIcon icon;
779 };
780
781
782=== modified file 'tests/test_launcher_minimize_speed.cpp'
783--- tests/test_launcher_minimize_speed.cpp 2013-07-09 04:29:25 +0000
784+++ tests/test_launcher_minimize_speed.cpp 2014-03-21 23:09:12 +0000
785@@ -22,7 +22,6 @@
786
787 #include <gio/gio.h>
788 #include <gtest/gtest.h>
789-#include "test_utils.h"
790
791 #include "plugins/unityshell/src/WindowMinimizeSpeedController.h"
792
793@@ -36,19 +35,12 @@
794 {
795 public:
796 glib::Object<GSettings> mSettings;
797- WindowMinimizeSpeedController* mController;
798-
799+ std::shared_ptr<WindowMinimizeSpeedController> mController;
800+
801 /* override */ void SetUp()
802 {
803- Utils::init_gsettings_test_environment();
804 mSettings = g_settings_new("com.canonical.Unity");
805- mController = new WindowMinimizeSpeedController();
806- }
807-
808- /* override */ void TearDown()
809- {
810- Utils::reset_gsettings_test_environment();
811- delete mController;
812+ mController = std::make_shared<WindowMinimizeSpeedController>();
813 }
814 };
815
816
817=== modified file 'tests/test_launcher_tooltip.cpp'
818--- tests/test_launcher_tooltip.cpp 2014-02-14 04:45:29 +0000
819+++ tests/test_launcher_tooltip.cpp 2014-03-21 23:09:12 +0000
820@@ -25,7 +25,6 @@
821 #include "unity-shared/StaticCairoText.h"
822 #include "launcher/Tooltip.h"
823
824-#include <unity-shared/UnitySettings.h>
825 #include "test_utils.h"
826
827 namespace unity
828@@ -73,7 +72,6 @@
829 protected:
830 TestTooltip() : Test()
831 {
832- Settings settings;
833 tooltip = new TooltipMock();
834 }
835
836
837=== modified file 'tests/test_lockscreen_controller.cpp'
838--- tests/test_lockscreen_controller.cpp 2014-03-18 23:49:29 +0000
839+++ tests/test_lockscreen_controller.cpp 2014-03-21 23:09:12 +0000
840@@ -30,7 +30,6 @@
841 #include "lockscreen/LockScreenSettings.h"
842 #include "unity-shared/PanelStyle.h"
843 #include "unity-shared/UScreen.h"
844-#include "unity-shared/UnitySettings.h"
845 #include "test_mock_session_manager.h"
846 #include "test_uscreen_mock.h"
847 #include "test_utils.h"
848@@ -109,7 +108,6 @@
849 nux::animation::AnimationController animation_controller;
850
851 MockUScreen uscreen;
852- unity::Settings unity_settings;
853 unity::panel::Style panel_style;
854 unity::lockscreen::Settings lockscreen_settings;
855 static glib::DBusServer::Ptr lightdm_;
856
857=== modified file 'tests/test_main.cpp'
858--- tests/test_main.cpp 2014-01-30 19:46:36 +0000
859+++ tests/test_main.cpp 2014-03-21 23:09:12 +0000
860@@ -7,7 +7,7 @@
861
862 #include "logger_helper.h"
863 #include "test_utils.h"
864-
865+#include "UnitySettings.h"
866
867 int main(int argc, char** argv)
868 {
869@@ -22,6 +22,7 @@
870
871 gtk_init(&argc, &argv);
872 setlocale(LC_ALL, "C");
873+ unity::Settings settings;
874
875 nux::NuxInitialize(0);
876 std::unique_ptr<nux::WindowThread> win_thread(nux::CreateNuxWindow("Tests",
877
878=== modified file 'tests/test_panel_controller.cpp'
879--- tests/test_panel_controller.cpp 2014-02-27 23:09:32 +0000
880+++ tests/test_panel_controller.cpp 2014-03-21 23:09:12 +0000
881@@ -22,7 +22,6 @@
882 #include "PanelController.h"
883 #include "PanelStyle.h"
884 #include "PanelView.h"
885-#include "UnitySettings.h"
886 #include "mock_menu_manager.h"
887 #include "test_uscreen_mock.h"
888 #include "launcher/LauncherOptions.h"
889@@ -43,7 +42,6 @@
890 }
891
892 MockUScreen uscreen;
893- Settings settings;
894 Style panel_style;
895 menu::MockManager::Ptr menus;
896 ui::EdgeBarrierController::Ptr edge_barriers;
897
898=== modified file 'tests/test_panel_indicator_entry_dropdown_view.cpp'
899--- tests/test_panel_indicator_entry_dropdown_view.cpp 2014-02-18 17:55:54 +0000
900+++ tests/test_panel_indicator_entry_dropdown_view.cpp 2014-03-21 23:09:12 +0000
901@@ -23,7 +23,6 @@
902 #include <Nux/Nux.h>
903 #include "PanelIndicatorEntryDropdownView.h"
904 #include "PanelStyle.h"
905-#include "UnitySettings.h"
906
907 #include "mock_indicators.h"
908 #include "test_standalone_wm.h"
909@@ -67,7 +66,6 @@
910 return PanelIndicatorEntryView::Ptr(new PanelIndicatorEntryView(entry));
911 }
912
913- Settings settings_;
914 Style style_;
915 MockIndicators::Ptr indicators_;
916 PanelIndicatorEntryDropdownView dropdown;
917
918=== modified file 'tests/test_panel_indicators_view.cpp'
919--- tests/test_panel_indicators_view.cpp 2014-01-30 15:14:36 +0000
920+++ tests/test_panel_indicators_view.cpp 2014-03-21 23:09:12 +0000
921@@ -24,7 +24,6 @@
922 #include <Nux/HLayout.h>
923 #include "PanelIndicatorsView.h"
924 #include "PanelStyle.h"
925-#include "UnitySettings.h"
926 #include "mock_indicators.h"
927
928 namespace unity
929@@ -52,7 +51,6 @@
930
931 struct TestPanelIndicatorsView : testing::Test
932 {
933- Settings settings_;
934 Style style_;
935 testing::NiceMock<MockPanelIndicatorsView> indicators;
936 };
937
938=== modified file 'tests/test_panel_menu_view.cpp'
939--- tests/test_panel_menu_view.cpp 2014-02-18 19:37:55 +0000
940+++ tests/test_panel_menu_view.cpp 2014-03-21 23:09:12 +0000
941@@ -21,7 +21,6 @@
942 #include <Nux/Nux.h>
943 #include "PanelMenuView.h"
944 #include "PanelStyle.h"
945-#include "UnitySettings.h"
946 #include "UBusMessages.h"
947 #include "mock_menu_manager.h"
948 #include "test_standalone_wm.h"
949@@ -78,7 +77,6 @@
950 // The order is important, i.e. menu_view needs
951 // panel::Style that needs Settings
952 MockUScreen uscreen;
953- Settings settings;
954 panel::Style panelStyle;
955 testwrapper::StandaloneWM WM;
956 testing::NiceMock<MockPanelMenuView> menu_view;
957
958=== modified file 'tests/test_panel_style.cpp'
959--- tests/test_panel_style.cpp 2014-02-28 05:48:21 +0000
960+++ tests/test_panel_style.cpp 2014-03-21 23:09:12 +0000
961@@ -25,8 +25,6 @@
962
963 #include <Nux/Nux.h>
964 #include "unity-shared/PanelStyle.h"
965-#include "unity-shared/UnitySettings.h"
966-#include "test_utils.h"
967
968 #include "MultiMonitor.h"
969
970@@ -42,23 +40,15 @@
971 {
972 public:
973 glib::Object<GSettings> gsettings;
974- Settings unity_settings;
975 std::unique_ptr<panel::Style> panel_style_instance;
976
977 /* override */ void SetUp()
978 {
979- Utils::init_gsettings_test_environment();
980-
981 gsettings = g_settings_new("org.gnome.desktop.wm.preferences");
982 g_settings_set_string(gsettings, "titlebar-font", TITLEBAR_FONT.c_str());
983
984 panel_style_instance.reset(new panel::Style());
985 }
986-
987- /* override */ void TearDown()
988- {
989- Utils::reset_gsettings_test_environment();
990- }
991 };
992
993 TEST_F(TestPanelStyle, TestGetFontDescription)
994@@ -80,7 +70,7 @@
995 sleep(1);
996
997 ASSERT_TRUE(signal_received);
998- ASSERT_EQ(panel_style_instance->GetFontDescription(panel::PanelItem::TITLE), "Ubuntu Italic 11");
999+ ASSERT_EQ(panel_style_instance->GetFontDescription(panel::PanelItem::TITLE), "Ubuntu Italic 11");
1000
1001 g_settings_set_string(gsettings, "titlebar-font", old_font);
1002 g_free (old_font);
1003
1004=== modified file 'tests/test_panel_view.cpp'
1005--- tests/test_panel_view.cpp 2014-02-17 14:09:15 +0000
1006+++ tests/test_panel_view.cpp 2014-03-21 23:09:12 +0000
1007@@ -25,7 +25,6 @@
1008 #include "unity-shared/PanelStyle.h"
1009 #include "unity-shared/UBusMessages.h"
1010 #include "unity-shared/UBusWrapper.h"
1011-#include "unity-shared/UnitySettings.h"
1012
1013 #include "mock_menu_manager.h"
1014 #include "test_standalone_wm.h"
1015@@ -39,7 +38,6 @@
1016 class TestPanelView : public testing::Test
1017 {
1018 public:
1019- Settings unity_settings_;
1020 Style panel_style_;
1021 UBusManager ubus_manager_;
1022 nux::ObjectPtr<MockableBaseWindow> window_;
1023
1024=== modified file 'tests/test_previews_application.cpp'
1025--- tests/test_previews_application.cpp 2013-01-24 03:17:58 +0000
1026+++ tests/test_previews_application.cpp 2014-03-21 23:09:12 +0000
1027@@ -27,7 +27,6 @@
1028 #include <unity-shared/DashStyle.h>
1029 #include <unity-shared/PreviewStyle.h>
1030 #include <unity-shared/ThumbnailGenerator.h>
1031-#include "unity-shared/UnitySettings.h"
1032
1033 #include <unity-protocol.h>
1034 #include "UnityCore/ApplicationPreview.h"
1035@@ -99,7 +98,6 @@
1036 nux::ObjectPtr<nux::BaseWindow> parent_window_;
1037 dash::Preview::Ptr preview_model_;
1038
1039- unity::Settings settings;
1040 previews::Style panel_style;
1041 dash::Style dash_style;
1042 ThumbnailGenerator thumbnail_generator;
1043
1044=== modified file 'tests/test_previews_generic.cpp'
1045--- tests/test_previews_generic.cpp 2013-01-24 03:17:58 +0000
1046+++ tests/test_previews_generic.cpp 2014-03-21 23:09:12 +0000
1047@@ -27,7 +27,6 @@
1048 #include <unity-shared/DashStyle.h>
1049 #include <unity-shared/PreviewStyle.h>
1050 #include <unity-shared/ThumbnailGenerator.h>
1051-#include "unity-shared/UnitySettings.h"
1052
1053 #include <unity-protocol.h>
1054 #include "UnityCore/GenericPreview.h"
1055@@ -86,7 +85,6 @@
1056 nux::ObjectPtr<nux::BaseWindow> parent_window_;
1057 dash::Preview::Ptr preview_model_;
1058
1059- unity::Settings settings;
1060 previews::Style panel_style;
1061 dash::Style dash_style;
1062 ThumbnailGenerator thumbnail_generator;
1063
1064=== modified file 'tests/test_previews_movie.cpp'
1065--- tests/test_previews_movie.cpp 2013-05-13 12:23:50 +0000
1066+++ tests/test_previews_movie.cpp 2014-03-21 23:09:12 +0000
1067@@ -27,7 +27,6 @@
1068 #include <unity-shared/DashStyle.h>
1069 #include <unity-shared/PreviewStyle.h>
1070 #include <unity-shared/ThumbnailGenerator.h>
1071-#include "unity-shared/UnitySettings.h"
1072
1073 #include <unity-protocol.h>
1074 #include "UnityCore/MoviePreview.h"
1075@@ -94,7 +93,6 @@
1076 nux::ObjectPtr<nux::BaseWindow> parent_window_;
1077 dash::Preview::Ptr preview_model_;
1078
1079- unity::Settings settings;
1080 previews::Style panel_style;
1081 dash::Style dash_style;
1082 ThumbnailGenerator thumbnail_generator;
1083
1084=== modified file 'tests/test_previews_music.cpp'
1085--- tests/test_previews_music.cpp 2013-02-27 15:17:55 +0000
1086+++ tests/test_previews_music.cpp 2014-03-21 23:09:12 +0000
1087@@ -27,7 +27,6 @@
1088 #include <unity-shared/DashStyle.h>
1089 #include <unity-shared/PreviewStyle.h>
1090 #include <unity-shared/ThumbnailGenerator.h>
1091-#include "unity-shared/UnitySettings.h"
1092
1093 #include <unity-protocol.h>
1094 #include "UnityCore/MusicPreview.h"
1095@@ -89,7 +88,6 @@
1096 nux::ObjectPtr<nux::BaseWindow> parent_window_;
1097 dash::Preview::Ptr preview_model_;
1098
1099- unity::Settings settings;
1100 previews::Style panel_style;
1101 dash::Style dash_style;
1102 ThumbnailGenerator thumbnail_generator;
1103
1104=== modified file 'tests/test_previews_music_payment.cpp'
1105--- tests/test_previews_music_payment.cpp 2013-03-20 12:11:01 +0000
1106+++ tests/test_previews_music_payment.cpp 2014-03-21 23:09:12 +0000
1107@@ -27,7 +27,6 @@
1108 #include <unity-shared/DashStyle.h>
1109 #include <unity-shared/PreviewStyle.h>
1110 #include <unity-shared/ThumbnailGenerator.h>
1111-#include "unity-shared/UnitySettings.h"
1112
1113 #include <unity-protocol.h>
1114 #include "dash/previews/MusicPaymentPreview.h"
1115@@ -125,7 +124,6 @@
1116 UnityProtocolPreviewPaymentType preview_type;
1117
1118 // needed for styles
1119- unity::Settings settings;
1120 dash::Style dash_style;
1121
1122 };
1123
1124=== modified file 'tests/test_previews_payment.cpp'
1125--- tests/test_previews_payment.cpp 2013-03-20 12:11:01 +0000
1126+++ tests/test_previews_payment.cpp 2014-03-21 23:09:12 +0000
1127@@ -28,7 +28,6 @@
1128 #include <unity-shared/PreviewStyle.h>
1129 #include <unity-shared/ThumbnailGenerator.h>
1130 #include <unity-shared/CoverArt.h>
1131-#include "unity-shared/UnitySettings.h"
1132
1133 #include <unity-protocol.h>
1134 #include "dash/previews/PaymentPreview.h"
1135@@ -146,7 +145,6 @@
1136 dash::Preview::Ptr preview_model;
1137
1138 // needed for styles
1139- unity::Settings settings;
1140 dash::Style dash_style;
1141
1142 };
1143
1144=== modified file 'tests/test_previews_social.cpp'
1145--- tests/test_previews_social.cpp 2013-01-24 03:17:58 +0000
1146+++ tests/test_previews_social.cpp 2014-03-21 23:09:12 +0000
1147@@ -27,7 +27,6 @@
1148 #include <unity-shared/DashStyle.h>
1149 #include <unity-shared/PreviewStyle.h>
1150 #include <unity-shared/ThumbnailGenerator.h>
1151-#include "unity-shared/UnitySettings.h"
1152
1153 #include <unity-protocol.h>
1154 #include "UnityCore/SocialPreview.h"
1155@@ -84,7 +83,6 @@
1156 nux::ObjectPtr<nux::BaseWindow> parent_window_;
1157 dash::Preview::Ptr preview_model_;
1158
1159- unity::Settings settings;
1160 previews::Style panel_style;
1161 dash::Style dash_style;
1162 ThumbnailGenerator thumbnail_generator;
1163
1164=== modified file 'tests/test_quicklist_manager.cpp'
1165--- tests/test_quicklist_manager.cpp 2013-02-12 20:59:12 +0000
1166+++ tests/test_quicklist_manager.cpp 2014-03-21 23:09:12 +0000
1167@@ -24,7 +24,6 @@
1168
1169 #include "launcher/QuicklistManager.h"
1170 #include "launcher/QuicklistView.h"
1171-#include "unity-shared/UnitySettings.h"
1172
1173 namespace {
1174
1175@@ -44,7 +43,6 @@
1176
1177 TEST(TestQuicklistManager, RegisterQuicklist)
1178 {
1179- unity::Settings unity_settings;
1180 nux::ObjectWeakPtr<unity::QuicklistView> ptr;
1181
1182 {
1183
1184=== modified file 'tests/test_quicklist_view.cpp'
1185--- tests/test_quicklist_view.cpp 2012-10-17 21:36:24 +0000
1186+++ tests/test_quicklist_view.cpp 2014-03-21 23:09:12 +0000
1187@@ -26,7 +26,6 @@
1188 #include "QuicklistMenuItemLabel.h"
1189 #include "QuicklistMenuItemRadio.h"
1190 #include "QuicklistMenuItemSeparator.h"
1191-#include "unity-shared/UnitySettings.h"
1192
1193 using namespace unity;
1194 using namespace testing;
1195@@ -76,7 +75,6 @@
1196 }
1197 }
1198
1199- unity::Settings unity_settings;
1200 nux::ObjectPtr<QuicklistView> quicklist;
1201 };
1202
1203
1204=== modified file 'tests/test_result_renderer.cpp'
1205--- tests/test_result_renderer.cpp 2013-07-22 17:11:47 +0000
1206+++ tests/test_result_renderer.cpp 2014-03-21 23:09:12 +0000
1207@@ -23,7 +23,6 @@
1208 #include <glib-object.h>
1209
1210 #include "unity-shared/DashStyle.h"
1211-#include "unity-shared/UnitySettings.h"
1212 #include "UnityCore/GTKWrapper.h"
1213 #include "UnityCore/Result.h"
1214 #include "dash/ResultRendererTile.h"
1215@@ -72,7 +71,6 @@
1216 public:
1217 TestResultRenderer() {}
1218
1219- unity::Settings settings;
1220 dash::Style style;
1221 };
1222
1223
1224=== modified file 'tests/test_scope_bar.cpp'
1225--- tests/test_scope_bar.cpp 2013-05-01 00:18:50 +0000
1226+++ tests/test_scope_bar.cpp 2014-03-21 23:09:12 +0000
1227@@ -22,7 +22,6 @@
1228 #include <dash/ScopeBar.h>
1229
1230 #include "unity-shared/DashStyle.h"
1231-#include "unity-shared/UnitySettings.h"
1232 #include "test_mock_scope.h"
1233
1234 namespace unity
1235@@ -42,7 +41,6 @@
1236 EXPECT_EQ(scope_bar.icons_.size(), size);
1237 }
1238
1239- unity::Settings settings;
1240 dash::Style style;
1241 };
1242
1243
1244=== modified file 'tests/test_scope_view.cpp'
1245--- tests/test_scope_view.cpp 2013-07-09 17:51:37 +0000
1246+++ tests/test_scope_view.cpp 2014-03-21 23:09:12 +0000
1247@@ -22,7 +22,6 @@
1248 #include <dash/ScopeView.h>
1249 #include <dash/PlacesGroup.h>
1250 #include <unity-shared/DashStyle.h>
1251-#include <unity-shared/UnitySettings.h>
1252 #include <UnityCore/Category.h>
1253
1254 #include "MockCategories.h"
1255@@ -77,7 +76,6 @@
1256 , scope_view_(new FakeScopeView(scope_))
1257 {}
1258
1259- unity::Settings settings;
1260 dash::Style style;
1261 MockScopeData::Ptr scope_data_;
1262 MockScope::Ptr scope_;
1263
1264=== modified file 'tests/test_searchbar.cpp'
1265--- tests/test_searchbar.cpp 2013-01-18 17:31:00 +0000
1266+++ tests/test_searchbar.cpp 2014-03-21 23:09:12 +0000
1267@@ -21,7 +21,6 @@
1268 #include <gmock/gmock.h>
1269 #include <unity-shared/SearchBarSpinner.h>
1270 #include <unity-shared/DashStyle.h>
1271-#include <unity-shared/UnitySettings.h>
1272 #include "test_utils.h"
1273
1274 using namespace unity;
1275@@ -34,7 +33,6 @@
1276 public:
1277 TestSearchBar() {}
1278
1279- unity::Settings settings;
1280 dash::Style style;
1281 };
1282
1283
1284=== modified file 'tests/test_session_controller.cpp'
1285--- tests/test_session_controller.cpp 2013-09-25 00:48:03 +0000
1286+++ tests/test_session_controller.cpp 2014-03-21 23:09:12 +0000
1287@@ -24,7 +24,6 @@
1288 #include "SessionController.h"
1289 #include "UBusMessages.h"
1290 #include "UBusWrapper.h"
1291-#include "UnitySettings.h"
1292 #include "WindowManager.h"
1293 #include "test_utils.h"
1294
1295@@ -55,7 +54,6 @@
1296
1297 nux::NuxTimerTickSource tick_source;
1298 nux::animation::AnimationController animation_controller;
1299- unity::Settings settings;
1300 MockManager::Ptr manager ;
1301 ControllerWrap controller;
1302 };
1303
1304=== modified file 'tests/test_session_view.cpp'
1305--- tests/test_session_view.cpp 2013-11-16 11:44:23 +0000
1306+++ tests/test_session_view.cpp 2014-03-21 23:09:12 +0000
1307@@ -21,7 +21,6 @@
1308 #include "test_mock_session_manager.h"
1309 #include "SessionButton.h"
1310 #include "SessionView.h"
1311-#include "UnitySettings.h"
1312
1313 namespace unity
1314 {
1315@@ -91,7 +90,6 @@
1316 nux::GetWindowCompositor().SetKeyFocusArea(nullptr);
1317 }
1318
1319- unity::Settings settings;
1320 MockManager::Ptr manager;
1321 ViewWrap view;
1322 };
1323
1324=== modified file 'tests/test_shortcut_controller.cpp'
1325--- tests/test_shortcut_controller.cpp 2014-03-10 23:44:54 +0000
1326+++ tests/test_shortcut_controller.cpp 2014-03-21 23:09:12 +0000
1327@@ -23,7 +23,6 @@
1328
1329 #include "shortcuts/BaseWindowRaiser.h"
1330 #include "shortcuts/ShortcutController.h"
1331-#include "unity-shared/UnitySettings.h"
1332 #include "WindowManager.h"
1333 #include "UBusMessages.h"
1334 using namespace unity;
1335@@ -89,7 +88,6 @@
1336 }
1337
1338 MockUScreen uscreen;
1339- Settings unity_settings;
1340 MockBaseWindowRaiser::Ptr base_window_raiser_;
1341 AbstractModeller::Ptr modeller_;
1342 NiceMock<MockShortcutController> controller_;
1343
1344=== modified file 'tests/test_shortcut_view.cpp'
1345--- tests/test_shortcut_view.cpp 2013-11-16 11:44:23 +0000
1346+++ tests/test_shortcut_view.cpp 2014-03-21 23:09:12 +0000
1347@@ -23,7 +23,6 @@
1348 #include "ShortcutView.h"
1349 #include "ShortcutModel.h"
1350 #include "MockShortcutHint.h"
1351-#include "UnitySettings.h"
1352 #include "LineSeparator.h"
1353
1354 namespace unity
1355@@ -54,7 +53,6 @@
1356 return std::make_shared<Model>(hints);
1357 }
1358
1359- Settings settings;
1360 MockShortcutView view;
1361 };
1362
1363
1364=== modified file 'tests/test_single_monitor_launcher_icon.cpp'
1365--- tests/test_single_monitor_launcher_icon.cpp 2014-02-18 01:20:01 +0000
1366+++ tests/test_single_monitor_launcher_icon.cpp 2014-03-21 23:09:12 +0000
1367@@ -20,7 +20,6 @@
1368 #include <gtest/gtest.h>
1369
1370 #include "SingleMonitorLauncherIcon.h"
1371-#include "unity-shared/UnitySettings.h"
1372
1373 using namespace unity;
1374 using namespace launcher;
1375@@ -30,7 +29,6 @@
1376
1377 struct TestSingleMonitorLauncherIconMock : testing::Test
1378 {
1379- unity::Settings settings;
1380 };
1381
1382 TEST_F(TestSingleMonitorLauncherIconMock, Construction)
1383
1384=== modified file 'tests/test_spread_filter.cpp'
1385--- tests/test_spread_filter.cpp 2014-02-17 21:41:32 +0000
1386+++ tests/test_spread_filter.cpp 2014-03-21 23:09:12 +0000
1387@@ -23,7 +23,6 @@
1388 #include <NuxCore/AnimationController.h>
1389
1390 #include "SpreadFilter.h"
1391-#include "UnitySettings.h"
1392 #include "DashStyle.h"
1393 #include "test_utils.h"
1394
1395@@ -64,7 +63,6 @@
1396 tick_source.tick(big_tick_);
1397 }
1398
1399- Settings settings_;
1400 dash::Style style_;
1401 nux::NuxTimerTickSource tick_source;
1402 nux::animation::AnimationController animation_controller;
1403
1404=== modified file 'tests/test_switcher_controller.h'
1405--- tests/test_switcher_controller.h 2013-10-14 17:36:51 +0000
1406+++ tests/test_switcher_controller.h 2014-03-21 23:09:12 +0000
1407@@ -31,7 +31,6 @@
1408 #include "SwitcherController.h"
1409 #include "SwitcherView.h"
1410 #include "TimeUtil.h"
1411-#include "unity-shared/UnitySettings.h"
1412 #include "mock-base-window.h"
1413 #include "test_standalone_wm.h"
1414
1415@@ -92,9 +91,6 @@
1416 protected:
1417 TestSwitcherController();
1418
1419- // required to create hidden secret global variables before test objects
1420- unity::Settings unity_settings_;
1421-
1422 unity::testwrapper::StandaloneWM WM;
1423 nux::animation::TickSource tick_source_;
1424 nux::animation::AnimationController animation_controller_;
1425
1426=== modified file 'tests/test_switcher_view.cpp'
1427--- tests/test_switcher_view.cpp 2013-11-19 18:33:11 +0000
1428+++ tests/test_switcher_view.cpp 2014-03-21 23:09:12 +0000
1429@@ -25,7 +25,6 @@
1430 #include "MockLauncherIcon.h"
1431 #include "test_standalone_wm.h"
1432 #include "unity-shared/IconRenderer.h"
1433-#include "unity-shared/UnitySettings.h"
1434
1435 namespace unity
1436 {
1437@@ -93,7 +92,6 @@
1438 }
1439
1440 testwrapper::StandaloneWM WM;
1441- unity::Settings settings;
1442 testing::NiceMock<MockSwitcherView> switcher;
1443 };
1444
1445
1446=== modified file 'tests/test_text_input.cpp'
1447--- tests/test_text_input.cpp 2014-03-06 02:26:23 +0000
1448+++ tests/test_text_input.cpp 2014-03-21 23:09:12 +0000
1449@@ -24,7 +24,6 @@
1450
1451 #include "unity-shared/DashStyle.h"
1452 #include "unity-shared/TextInput.h"
1453-#include "unity-shared/UnitySettings.h"
1454 #include "test_utils.h"
1455
1456 using namespace nux;
1457@@ -55,7 +54,6 @@
1458 pango_entry = entry->GetPangoEntry();
1459 }
1460
1461- unity::Settings unity_settings_;
1462 dash::Style dash_style_;
1463 nux::ObjectPtr<TextInputMock> entry;
1464 StaticCairoText* hint;
1465
1466=== modified file 'tests/test_unity_settings.cpp'
1467--- tests/test_unity_settings.cpp 2013-07-09 04:29:25 +0000
1468+++ tests/test_unity_settings.cpp 2014-03-21 23:09:12 +0000
1469@@ -19,34 +19,46 @@
1470 */
1471
1472 #include <gio/gio.h>
1473-#include <gtest/gtest.h>
1474+#include <gmock/gmock.h>
1475
1476+#include "UnitySettings.h"
1477 #include "test_utils.h"
1478-#include "unity-shared/UnitySettings.h"
1479
1480+#include <NuxCore/Logger.h>
1481 #include <UnityCore/GLibWrapper.h>
1482
1483 namespace
1484 {
1485-
1486-class TestUnitySettings : public testing::Test
1487-{
1488-public:
1489+struct SigReceiver : sigc::trackable
1490+{
1491+ typedef testing::NiceMock<SigReceiver> Nice;
1492+
1493+ SigReceiver(std::shared_ptr<unity::Settings> const& settings)
1494+ {
1495+ settings->form_factor.changed.connect(sigc::mem_fun(this, &SigReceiver::FormFactorChanged));
1496+ }
1497+
1498+ MOCK_CONST_METHOD1(FormFactorChanged, void(unity::FormFactor));
1499+};
1500+
1501+struct TestUnitySettings : testing::Test
1502+{
1503 unity::glib::Object<GSettings> gsettings;
1504- std::unique_ptr<unity::Settings> unity_settings;
1505+ std::shared_ptr<unity::Settings> unity_settings;
1506+ SigReceiver::Nice sig_receiver;
1507
1508- void SetUp()
1509+ TestUnitySettings()
1510+ : gsettings(g_settings_new("com.canonical.Unity"))
1511+ , unity_settings(std::make_shared<unity::Settings>())
1512+ , sig_receiver(unity_settings)
1513 {
1514- Utils::init_gsettings_test_environment();
1515- gsettings = g_settings_new("com.canonical.Unity");
1516 g_settings_set_enum(gsettings, "form-factor", static_cast<int>(unity::FormFactor::DESKTOP));
1517-
1518- unity_settings.reset(new unity::Settings);
1519 }
1520
1521- void TearDown()
1522+ ~TestUnitySettings()
1523 {
1524- Utils::reset_gsettings_test_environment();
1525+ sig_receiver.notify_callbacks();
1526+ g_settings_reset(gsettings, "form-factor");
1527 }
1528 };
1529
1530@@ -60,7 +72,7 @@
1531
1532 TEST_F(TestUnitySettings, GetFormFactor)
1533 {
1534- EXPECT_EQ(unity_settings->form_factor(), unity::FormFactor::DESKTOP);
1535+ ASSERT_NE(unity_settings->form_factor(), unity::FormFactor::NETBOOK);
1536
1537 g_settings_set_enum(gsettings, "form-factor", static_cast<int>(unity::FormFactor::NETBOOK));
1538 EXPECT_EQ(unity_settings->form_factor(), unity::FormFactor::NETBOOK);
1539@@ -68,42 +80,24 @@
1540
1541 TEST_F(TestUnitySettings, FormFactorChangedSignal_Extern)
1542 {
1543- bool signal_received = false;
1544- unity::FormFactor new_form_factor;
1545- unity_settings->form_factor.changed.connect([&](unity::FormFactor form_factor) {
1546- signal_received = true;
1547- new_form_factor = form_factor;
1548- });
1549+ EXPECT_CALL(sig_receiver, FormFactorChanged(unity::FormFactor::NETBOOK));
1550
1551 g_settings_set_enum(gsettings, "form-factor", static_cast<int>(unity::FormFactor::NETBOOK));
1552- Utils::WaitUntilMSec(signal_received);
1553- EXPECT_EQ(new_form_factor, unity::FormFactor::NETBOOK);
1554 }
1555
1556 TEST_F(TestUnitySettings, FormFactorChangedSignal_Extern_OtherKeys)
1557 {
1558- bool signal_received = false;
1559- unity_settings->form_factor.changed.connect([&](unity::FormFactor form_factor) {
1560- signal_received = true;
1561- });
1562+ EXPECT_CALL(sig_receiver, FormFactorChanged(testing::_)).Times(0);
1563
1564 g_settings_set_int(gsettings, "minimize-count", 0);
1565 Utils::WaitForTimeoutMSec(100);
1566- EXPECT_FALSE(signal_received);
1567 }
1568
1569 TEST_F(TestUnitySettings, FormFactorChangedSignal_Inter)
1570 {
1571- bool signal_received = false;
1572- unity::FormFactor new_form_factor;
1573- unity_settings->form_factor.changed.connect([&](unity::FormFactor form_factor) {
1574- signal_received = true;
1575- new_form_factor = form_factor;
1576- });
1577+ EXPECT_CALL(sig_receiver, FormFactorChanged(unity::FormFactor::NETBOOK));
1578
1579 unity_settings->form_factor = unity::FormFactor::NETBOOK;
1580- Utils::WaitUntilMSec(signal_received);
1581- EXPECT_EQ(new_form_factor, unity::FormFactor::NETBOOK);
1582 }
1583
1584 }
1585
1586=== modified file 'tests/test_unity_window_view.cpp'
1587--- tests/test_unity_window_view.cpp 2013-11-16 11:44:23 +0000
1588+++ tests/test_unity_window_view.cpp 2014-03-21 23:09:12 +0000
1589@@ -19,7 +19,6 @@
1590
1591 #include <gmock/gmock.h>
1592 #include "UnityWindowView.h"
1593-#include "UnitySettings.h"
1594 #include "WindowManager.h"
1595 #include <Nux/VLayout.h>
1596
1597@@ -51,7 +50,6 @@
1598 nux::Geometry background_geo_;
1599 };
1600
1601- Settings settings;
1602 testing::NiceMock<MockUnityWindowView> view;
1603 };
1604
1605
1606=== modified file 'tests/test_volume_launcher_icon.cpp'
1607--- tests/test_volume_launcher_icon.cpp 2014-02-18 01:20:01 +0000
1608+++ tests/test_volume_launcher_icon.cpp 2014-03-21 23:09:12 +0000
1609@@ -20,7 +20,6 @@
1610 #include <gmock/gmock.h>
1611 using namespace testing;
1612
1613-#include "unity-shared/UnitySettings.h"
1614
1615 #include "DevicesSettings.h"
1616 #include "VolumeLauncherIcon.h"
1617@@ -78,7 +77,6 @@
1618 return *menuitem;
1619 }
1620
1621- unity::Settings u_settings_;
1622 MockVolume::Ptr volume_;
1623 MockDevicesSettings::Ptr settings_;
1624 MockDeviceNotificationDisplay::Ptr notifications_;
1625
1626=== modified file 'tests/test_window_buttons.cpp'
1627--- tests/test_window_buttons.cpp 2013-10-14 17:36:51 +0000
1628+++ tests/test_window_buttons.cpp 2014-03-21 23:09:12 +0000
1629@@ -23,7 +23,6 @@
1630 #include <Nux/Nux.h>
1631 #include "PanelStyle.h"
1632 #include "test_standalone_wm.h"
1633-#include "UnitySettings.h"
1634 #include "unity-shared/WindowButtons.h"
1635 #include "unity-shared/WindowButtonPriv.h"
1636
1637@@ -60,7 +59,6 @@
1638 MOCK_METHOD0(QueueDraw, void());
1639 };
1640
1641- Settings settings;
1642 panel::Style panel_style;
1643 testing::NiceMock<MockWindowButtons> wbuttons;
1644 testwrapper::StandaloneWM wm;
1645@@ -163,7 +161,6 @@
1646 MOCK_METHOD0(QueueDraw, void());
1647 };
1648
1649- Settings settings;
1650 panel::Style panel_style;
1651 testing::NiceMock<MockWindowButton> button;
1652 };
1653
1654=== added file 'tools/migration-scripts/02_unity_setup_text_scale_factor'
1655--- tools/migration-scripts/02_unity_setup_text_scale_factor 1970-01-01 00:00:00 +0000
1656+++ tools/migration-scripts/02_unity_setup_text_scale_factor 2014-03-21 23:09:12 +0000
1657@@ -0,0 +1,39 @@
1658+#!/usr/bin/python
1659+# -*- coding: utf-8 -*-
1660+# Copyright (C) 2014 Canonical
1661+#
1662+# Authors:
1663+# Marco Trevisan <marco.trevisan@canonical.com>
1664+#
1665+# This program is free software; you can redistribute it and/or modify it under
1666+# the terms of the GNU General Public License as published by the Free Software
1667+# Foundation; version 3.
1668+#
1669+# This program is distributed in the hope that it will be useful, but WITHOUTa
1670+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1671+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1672+# details.
1673+#
1674+# You should have received a copy of the GNU General Public License along with
1675+# this program; if not, write to the Free Software Foundation, Inc.,
1676+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1677+
1678+from gi.repository import Gio
1679+import os,sys
1680+
1681+GNOME_UI_SETTINGS = "org.gnome.desktop.interface";
1682+GNOME_UI_SETTINGS_PATH = "/org/gnome/desktop/interface/"
1683+GNOME_TEXT_SCALE_FACTOR = "text-scaling-factor";
1684+
1685+if GNOME_UI_SETTINGS not in Gio.Settings.list_schemas():
1686+ print("No gnome desktop interface schemas found, no migration needed")
1687+ sys.exit(0)
1688+
1689+ui_settings = Gio.Settings(schema=GNOME_UI_SETTINGS, path=GNOME_UI_SETTINGS_PATH)
1690+text_scale_factor = ui_settings.get_double(GNOME_TEXT_SCALE_FACTOR)
1691+
1692+# gsettings doesn't work directly, the key is somewhat reverted. Work one level under then: dconf!
1693+# ui_settings.set_int(GNOME_TEXT_SCALE_FACTOR, text_scale_factor)
1694+from subprocess import Popen, PIPE, STDOUT
1695+p = Popen(("dconf load "+GNOME_UI_SETTINGS_PATH).split(), stdout=PIPE, stdin=PIPE, stderr=STDOUT)
1696+p.communicate(input="[/]\n"+GNOME_TEXT_SCALE_FACTOR+"={}".format(text_scale_factor).encode('utf-8'))
1697
1698=== modified file 'unity-shared/DashStyle.cpp'
1699--- unity-shared/DashStyle.cpp 2013-08-15 22:30:55 +0000
1700+++ unity-shared/DashStyle.cpp 2014-03-21 23:09:12 +0000
1701@@ -108,9 +108,8 @@
1702 } // anon namespace
1703
1704
1705-class Style::Impl
1706+struct Style::Impl : sigc::trackable
1707 {
1708-public:
1709 Impl(Style* owner);
1710 ~Impl();
1711
1712@@ -165,6 +164,7 @@
1713 nux::ButtonVisualState state);
1714
1715 void Refresh();
1716+ void UpdateFormFactor(FormFactor);
1717 void OnFontChanged(GtkSettings* object, GParamSpec* pspec);
1718
1719 // Members
1720@@ -293,11 +293,13 @@
1721 (gtk_settings_get_default(),
1722 "notify::gtk-font-name",
1723 sigc::mem_fun(this, &Impl::OnFontChanged)));
1724- signal_manager_.Add(new glib::Signal<void, GtkSettings*, GParamSpec*>
1725- (gtk_settings_get_default(),
1726- "notify::gtk-xft-dpi",
1727- sigc::mem_fun(this, &Impl::OnFontChanged)));
1728+
1729+ auto& settings = Settings::Instance();
1730+ settings.font_scaling.changed.connect(sigc::hide(sigc::mem_fun(this, &Impl::Refresh)));
1731+ settings.form_factor.changed.connect(sigc::mem_fun(this, &Impl::UpdateFormFactor));
1732+
1733 Refresh();
1734+ UpdateFormFactor(settings.form_factor());
1735
1736 // create fallback font-options
1737 default_font_options_ = cairo_font_options_create();
1738@@ -388,11 +390,7 @@
1739 cairo_t* cr = util_cg.GetInternalContext();
1740
1741 glib::String font_description;
1742- int dpi = 0;
1743- ::g_object_get(settings,
1744- "gtk-font-name", &font_description,
1745- "gtk-xft-dpi", &dpi,
1746- NULL);
1747+ ::g_object_get(settings, "gtk-font-name", &font_description, nullptr);
1748 PangoFontDescription* desc = ::pango_font_description_from_string(font_description);
1749 ::pango_font_description_set_weight(desc, PANGO_WEIGHT_NORMAL);
1750 ::pango_font_description_set_size(desc, 9 * PANGO_SCALE);
1751@@ -405,8 +403,7 @@
1752
1753 GdkScreen* screen = ::gdk_screen_get_default();
1754 ::pango_cairo_context_set_font_options(cxt, ::gdk_screen_get_font_options(screen));
1755- float pango_scale = PANGO_SCALE;
1756- ::pango_cairo_context_set_resolution(cxt, dpi / pango_scale);
1757+ ::pango_cairo_context_set_resolution(cxt, 96.0 * Settings::Instance().font_scaling());
1758 ::pango_layout_context_changed(layout);
1759
1760 PangoRectangle log_rect;
1761@@ -419,12 +416,15 @@
1762 pango_font_description_free(desc);
1763 }
1764
1765-
1766 void Style::Impl::OnFontChanged(GtkSettings* object, GParamSpec* pspec)
1767 {
1768 Refresh();
1769 }
1770
1771+void Style::Impl::UpdateFormFactor(FormFactor form_factor)
1772+{
1773+ owner_->always_maximised = (form_factor == FormFactor::NETBOOK || form_factor == FormFactor::TV);
1774+}
1775
1776 Style::Style()
1777 : always_maximised(false)
1778@@ -438,15 +438,6 @@
1779 {
1780 style_instance = this;
1781 }
1782-
1783- auto formfactor_lambda = [this] (FormFactor)
1784- {
1785- FormFactor formfactor = Settings::Instance().form_factor();
1786- always_maximised = (formfactor == FormFactor::NETBOOK || formfactor == FormFactor::TV);
1787- };
1788-
1789- Settings::Instance().form_factor.changed.connect(formfactor_lambda);
1790- formfactor_lambda(FormFactor());
1791 }
1792
1793 Style::~Style ()
1794@@ -1384,7 +1375,6 @@
1795 PangoFontDescription* desc = NULL;
1796 PangoContext* pangoCtx = NULL;
1797 PangoRectangle inkRect = {0, 0, 0, 0};
1798- int dpi = 0;
1799 char* fontName = NULL;
1800 GdkScreen* screen = gdk_screen_get_default(); // is not ref'ed
1801 GtkSettings* settings = gtk_settings_get_default();// is not ref'ed
1802@@ -1423,17 +1413,7 @@
1803 pango_cairo_context_set_font_options(pangoCtx,
1804 gdk_screen_get_font_options(screen));
1805
1806- g_object_get(settings, "gtk-xft-dpi", &dpi, NULL);
1807- if (dpi == -1)
1808- {
1809- // use some default DPI-value
1810- pango_cairo_context_set_resolution(pangoCtx, 96.0f);
1811- }
1812- else
1813- {
1814- pango_cairo_context_set_resolution(pangoCtx,
1815- (float) dpi / (float) PANGO_SCALE);
1816- }
1817+ pango_cairo_context_set_resolution(pangoCtx, 96.0 * Settings::Instance().font_scaling());
1818 pango_layout_context_changed(layout);
1819 pango_layout_get_extents(layout, &inkRect, NULL);
1820
1821@@ -1461,7 +1441,6 @@
1822 PangoLayout* layout = NULL;
1823 PangoFontDescription* desc = NULL;
1824 PangoContext* pangoCtx = NULL;
1825- int dpi = 0;
1826 GdkScreen* screen = gdk_screen_get_default(); // not ref'ed
1827 GtkSettings* settings = gtk_settings_get_default(); // not ref'ed
1828 gchar* fontName = NULL;
1829@@ -1480,7 +1459,7 @@
1830
1831 g_object_get(settings, "gtk-font-name", &fontName, NULL);
1832 if (!fontName)
1833- desc = pango_font_description_from_string("Sans 10");
1834+ desc = pango_font_description_from_string("Ubuntu 10");
1835 else
1836 desc = pango_font_description_from_string(fontName);
1837
1838@@ -1543,17 +1522,7 @@
1839 pango_cairo_context_set_font_options(pangoCtx,
1840 gdk_screen_get_font_options(screen));
1841
1842- g_object_get(settings, "gtk-xft-dpi", &dpi, NULL);
1843- if (dpi == -1)
1844- {
1845- // use some default DPI-value
1846- pango_cairo_context_set_resolution(pangoCtx, 96.0f);
1847- }
1848- else
1849- {
1850- pango_cairo_context_set_resolution(pangoCtx,
1851- (float) dpi / (float) PANGO_SCALE);
1852- }
1853+ pango_cairo_context_set_resolution(pangoCtx, 96.0 * Settings::Instance().font_scaling());
1854
1855 cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
1856 cairo_set_source_rgba(cr, color);
1857
1858=== modified file 'unity-shared/DecorationStyle.cpp'
1859--- unity-shared/DecorationStyle.cpp 2014-02-28 17:40:25 +0000
1860+++ unity-shared/DecorationStyle.cpp 2014-03-21 23:09:12 +0000
1861@@ -157,6 +157,7 @@
1862 parent_->integrated_menus = false;
1863 parent_->theme = glib::String(GetSettingValue<gchar*>("gtk-theme-name")).Str();
1864 parent_->font = glib::String(GetSettingValue<gchar*>("gtk-font-name")).Str();
1865+ parent_->font_scale = 1.0;
1866 SetTitleFont();
1867
1868 UpdateTitlePangoContext(parent_->title_font);
1869@@ -185,14 +186,12 @@
1870 LOG_INFO(logger) << "gtk-font-name changed to " << parent_->font();
1871 });
1872
1873- signals_.Add<void, GtkSettings*, GParamSpec*>(settings, "notify::gtk-xft-dpi", [this] (GtkSettings*, GParamSpec*) {
1874- title_pango_ctx_ = gdk_pango_context_get_for_screen(gdk_screen_get_default());
1875- menu_item_pango_ctx_ = gdk_pango_context_get_for_screen(gdk_screen_get_default());
1876+ parent_->font_scale.changed.connect([this] (bool scale) {
1877 UpdateTitlePangoContext(parent_->title_font);
1878 UpdateMenuItemPangoContext(parent_->font);
1879 gtk_style_context_invalidate(ctx_);
1880 parent_->theme.changed.emit(parent_->theme());
1881- LOG_INFO(logger) << "gtk-xft-dpi changed to " << GetSettingValue<int>("gtk-xft-dpi");
1882+ LOG_INFO(logger) << "font scale changed to " << scale;
1883 });
1884
1885 signals_.Add<void, GSettings*, gchar*>(settings_, "changed::" + FONT_KEY, [this] (GSettings*, gchar*) {
1886@@ -255,6 +254,7 @@
1887 std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font.c_str()), pango_font_description_free);
1888 pango_context_set_font_description(ctx, desc.get());
1889 pango_context_set_language(ctx, gtk_get_default_language());
1890+ pango_cairo_context_set_resolution(ctx, 96.0 * parent_->font_scale());
1891 }
1892
1893 void UpdateTitlePangoContext(std::string const& font)
1894@@ -508,9 +508,9 @@
1895
1896 nux::Size extents;
1897 pango_layout_get_pixel_size(layout, &extents.width, &extents.height);
1898- pango_layout_set_height(layout, (h > 0) ? h * PANGO_SCALE : -1);
1899+ pango_layout_set_height(layout, (h >= 0) ? h * PANGO_SCALE : -1);
1900
1901- if (extents.width > w)
1902+ if (w >= 0 && extents.width > w)
1903 {
1904 double out_pixels = extents.width - w;
1905 double fading_width = std::min<double>(title_fade_, out_pixels);
1906@@ -528,7 +528,7 @@
1907 }
1908 else
1909 {
1910- pango_layout_set_width(layout, w * PANGO_SCALE);
1911+ pango_layout_set_width(layout, (w >= 0) ? w * PANGO_SCALE : -1);
1912 gtk_render_layout(ctx_, cr, 0, 0, layout);
1913 }
1914
1915@@ -571,8 +571,8 @@
1916 pango_attr_list_unref(text_attribs);
1917 }
1918
1919- pango_layout_set_width(layout, w * PANGO_SCALE);
1920- pango_layout_set_height(layout, (h > 0) ? h * PANGO_SCALE : -1);
1921+ pango_layout_set_width(layout, (w >= 0) ? w * PANGO_SCALE : -1);
1922+ pango_layout_set_height(layout, (h >= 0) ? h * PANGO_SCALE : -1);
1923 gtk_render_layout(ctx_, cr, 0, 0, layout);
1924
1925 gtk_style_context_restore(ctx_);
1926
1927=== modified file 'unity-shared/DecorationStyle.h'
1928--- unity-shared/DecorationStyle.h 2014-02-28 17:30:20 +0000
1929+++ unity-shared/DecorationStyle.h 2014-03-21 23:09:12 +0000
1930@@ -99,6 +99,7 @@
1931 nux::Property<std::string> title_font;
1932 nux::Property<bool> integrated_menus;
1933 nux::Property<unsigned> grab_wait;
1934+ nux::Property<double> font_scale;
1935
1936 decoration::Border const& Border() const;
1937 decoration::Border const& InputBorder() const;
1938
1939=== modified file 'unity-shared/IconLoader.cpp'
1940--- unity-shared/IconLoader.cpp 2013-11-14 03:00:29 +0000
1941+++ unity-shared/IconLoader.cpp 2014-03-21 23:09:12 +0000
1942@@ -35,6 +35,7 @@
1943 #include <UnityCore/GTKWrapper.h>
1944
1945 #include "unity-shared/Timer.h"
1946+#include "unity-shared/UnitySettings.h"
1947
1948 namespace unity
1949 {
1950@@ -313,10 +314,8 @@
1951 PangoContext* pango_context = NULL;
1952 GdkScreen* screen = gdk_screen_get_default(); // not ref'ed
1953 glib::String font;
1954- int dpi = -1;
1955
1956 g_object_get(gtk_settings_get_default(), "gtk-font-name", &font, NULL);
1957- g_object_get(gtk_settings_get_default(), "gtk-xft-dpi", &dpi, NULL);
1958 cairo_set_font_options(cr, gdk_screen_get_font_options(screen));
1959 layout = pango_cairo_create_layout(cr);
1960 std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font), pango_font_description_free);
1961@@ -345,10 +344,8 @@
1962 pango_layout_set_markup(layout, escaped_text, -1);
1963
1964 pango_context = pango_layout_get_context(layout); // is not ref'ed
1965- pango_cairo_context_set_font_options(pango_context,
1966- gdk_screen_get_font_options(screen));
1967- pango_cairo_context_set_resolution(pango_context,
1968- dpi == -1 ? 96.0f : dpi/(float) PANGO_SCALE);
1969+ pango_cairo_context_set_font_options(pango_context, gdk_screen_get_font_options(screen));
1970+ pango_cairo_context_set_resolution(pango_context, 96.0 * Settings::Instance().font_scaling());
1971 pango_layout_context_changed(layout);
1972
1973 // find proper font size
1974@@ -923,11 +920,7 @@
1975 cairo_t* cr = util_cg.GetInternalContext();
1976
1977 glib::String font;
1978- int dpi = 0;
1979- g_object_get(settings,
1980- "gtk-font-name", &font,
1981- "gtk-xft-dpi", &dpi,
1982- NULL);
1983+ g_object_get(settings, "gtk-font-name", &font, nullptr);
1984 std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font), pango_font_description_free);
1985 pango_font_description_set_weight(desc.get(), PANGO_WEIGHT_BOLD);
1986 pango_font_description_set_size(desc.get(), FONT_SIZE * PANGO_SCALE);
1987@@ -939,7 +932,7 @@
1988 PangoContext* cxt = pango_layout_get_context(layout);
1989 GdkScreen* screen = gdk_screen_get_default();
1990 pango_cairo_context_set_font_options(cxt, gdk_screen_get_font_options(screen));
1991- pango_cairo_context_set_resolution(cxt, dpi / (double) PANGO_SCALE);
1992+ pango_cairo_context_set_resolution(cxt, 96.0 * Settings::Instance().font_scaling());
1993 pango_layout_context_changed(layout);
1994
1995 PangoRectangle log_rect;
1996
1997=== modified file 'unity-shared/StaticCairoText.cpp'
1998--- unity-shared/StaticCairoText.cpp 2014-02-25 04:59:37 +0000
1999+++ unity-shared/StaticCairoText.cpp 2014-03-21 23:09:12 +0000
2000@@ -36,12 +36,13 @@
2001 #include <UnityCore/GLibWrapper.h>
2002
2003 #include "CairoTexture.h"
2004+#include "UnitySettings.h"
2005
2006 using namespace nux;
2007
2008 namespace unity
2009 {
2010-struct StaticCairoText::Impl
2011+struct StaticCairoText::Impl : sigc::trackable
2012 {
2013 Impl(StaticCairoText* parent, std::string const& text);
2014 ~Impl();
2015@@ -128,8 +129,8 @@
2016 GtkSettings* settings = gtk_settings_get_default(); // not ref'ed
2017 g_signal_connect(settings, "notify::gtk-font-name",
2018 (GCallback)FontChanged, this);
2019- g_signal_connect(settings, "notify::gtk-xft-dpi",
2020- (GCallback)FontChanged, this);
2021+
2022+ Settings::Instance().font_scaling.changed.connect(sigc::hide(sigc::mem_fun(this, &Impl::OnFontChanged)));
2023 }
2024
2025 StaticCairoText::Impl::~Impl()
2026@@ -552,9 +553,7 @@
2027 PangoLayout* layout = NULL;
2028 PangoFontDescription* desc = NULL;
2029 PangoContext* pangoCtx = NULL;
2030- int dpi = 0;
2031 GdkScreen* screen = gdk_screen_get_default(); // is not ref'ed
2032- GtkSettings* settings = gtk_settings_get_default(); // is not ref'ed
2033
2034 if (!need_new_extent_cache_)
2035 {
2036@@ -581,19 +580,8 @@
2037 pango_layout_set_spacing(layout, line_spacing_ * PANGO_SCALE);
2038
2039 pangoCtx = pango_layout_get_context(layout); // is not ref'ed
2040- pango_cairo_context_set_font_options(pangoCtx,
2041- gdk_screen_get_font_options(screen));
2042- g_object_get(settings, "gtk-xft-dpi", &dpi, NULL);
2043- if (dpi == -1)
2044- {
2045- // use some default DPI-value
2046- pango_cairo_context_set_resolution(pangoCtx, 96.0f);
2047- }
2048- else
2049- {
2050- pango_cairo_context_set_resolution(pangoCtx,
2051- (float) dpi / (float) PANGO_SCALE);
2052- }
2053+ pango_cairo_context_set_font_options(pangoCtx, gdk_screen_get_font_options(screen));
2054+ pango_cairo_context_set_resolution(pangoCtx, 96.0 * Settings::Instance().font_scaling());
2055 pango_layout_context_changed(layout);
2056
2057 PangoRectangle ink_rect, logic_rect;
2058@@ -721,9 +709,7 @@
2059 PangoLayout* layout = NULL;
2060 PangoFontDescription* desc = NULL;
2061 PangoContext* pangoCtx = NULL;
2062- int dpi = 0;
2063 GdkScreen* screen = gdk_screen_get_default(); // not ref'ed
2064- GtkSettings* settings = gtk_settings_get_default(); // not ref'ed
2065
2066 std::string text = text_.substr(texture->start_index, texture->length);
2067
2068@@ -746,22 +732,11 @@
2069 SetAttributes(layout);
2070
2071 pangoCtx = pango_layout_get_context(layout); // is not ref'ed
2072- pango_cairo_context_set_font_options(pangoCtx,
2073- gdk_screen_get_font_options(screen));
2074- g_object_get(settings, "gtk-xft-dpi", &dpi, NULL);
2075- if (dpi == -1)
2076- {
2077- // use some default DPI-value
2078- pango_cairo_context_set_resolution(pangoCtx, 96.0f);
2079- }
2080- else
2081- {
2082- pango_cairo_context_set_resolution(pangoCtx,
2083- (float) dpi / (float) PANGO_SCALE);
2084- }
2085+ pango_cairo_context_set_font_options(pangoCtx, gdk_screen_get_font_options(screen));
2086+ pango_cairo_context_set_resolution(pangoCtx, 96.0 * Settings::Instance().font_scaling());
2087+ pango_layout_context_changed(layout);
2088
2089 Size result;
2090- pango_layout_context_changed(layout);
2091 pango_layout_get_pixel_size(layout, &result.width, &result.height);
2092
2093 if (std::ceil(result.width * scale_) > parent_->GetMaximumWidth())
2094
2095=== modified file 'unity-shared/UScreen.cpp'
2096--- unity-shared/UScreen.cpp 2014-03-19 13:22:07 +0000
2097+++ unity-shared/UScreen.cpp 2014-03-21 23:09:12 +0000
2098@@ -36,10 +36,10 @@
2099 size_changed_signal_.Connect(screen_, "size-changed", sigc::mem_fun(this, &UScreen::Changed));
2100 monitors_changed_signal_.Connect(screen_, "monitors-changed", sigc::mem_fun(this, &UScreen::Changed));
2101 proxy_.Connect("PrepareForSleep", [this] (GVariant* data) {
2102- bool val;
2103+ gboolean val;
2104 g_variant_get(data, "(b)", &val);
2105 if (!val)
2106- resuming.emit();
2107+ resuming.emit();
2108 });
2109
2110 Refresh();
2111
2112=== modified file 'unity-shared/UnitySettings.cpp'
2113--- unity-shared/UnitySettings.cpp 2014-02-28 16:56:19 +0000
2114+++ unity-shared/UnitySettings.cpp 2014-03-21 23:09:12 +0000
2115@@ -37,12 +37,26 @@
2116 const std::string SETTINGS_NAME = "com.canonical.Unity";
2117 const std::string FORM_FACTOR = "form-factor";
2118 const std::string DOUBLE_CLICK_ACTIVATE = "double-click-activate";
2119-const std::string SCALE_FACTOR = "scale-factor";
2120 const std::string LIM_KEY = "integrated-menus";
2121+
2122 const std::string LIM_SETTINGS = "com.canonical.Unity.IntegratedMenus";
2123 const std::string CLICK_MOVEMENT_THRESHOLD = "click-movement-threshold";
2124 const std::string DOUBLE_CLICK_WAIT = "double-click-wait";
2125-const std::string UI_SETTINGS = "com.ubuntu.user-interface";
2126+
2127+const std::string UI_SETTINGS = "com.canonical.Unity.Interface";
2128+const std::string TEXT_SCALE_FACTOR = "text-scale-factor";
2129+const std::string CURSOR_SCALE_FACTOR = "cursor-scale-factor";
2130+const std::string APP_SCALE_MONITOR = "app-scale-factor-monitor";
2131+const std::string APP_USE_MAX_SCALE = "app-fallback-to-maximum-scale-factor";
2132+
2133+const std::string UBUNTU_UI_SETTINGS = "com.ubuntu.user-interface";
2134+const std::string SCALE_FACTOR = "scale-factor";
2135+
2136+const std::string GNOME_UI_SETTINGS = "org.gnome.desktop.interface";
2137+const std::string GNOME_FONT_NAME = "font-name";
2138+const std::string GNOME_CURSOR_SIZE = "cursor-size";
2139+const std::string GNOME_SCALE_FACTOR = "scaling-factor";
2140+const std::string GNOME_TEXT_SCALE_FACTOR = "text-scaling-factor";
2141
2142 const int DEFAULT_LAUNCHER_WIDTH = 64;
2143 const double DEFAULT_DPI = 96.0f;
2144@@ -56,42 +70,85 @@
2145 public:
2146 Impl(Settings* owner)
2147 : parent_(owner)
2148- , gsettings_(g_settings_new(SETTINGS_NAME.c_str()))
2149- , ubuntu_settings_(g_settings_new(UI_SETTINGS.c_str()))
2150 , usettings_(g_settings_new(SETTINGS_NAME.c_str()))
2151 , lim_settings_(g_settings_new(LIM_SETTINGS.c_str()))
2152+ , ui_settings_(g_settings_new(UI_SETTINGS.c_str()))
2153+ , ubuntu_ui_settings_(g_settings_new(UBUNTU_UI_SETTINGS.c_str()))
2154+ , gnome_ui_settings_(g_settings_new(GNOME_UI_SETTINGS.c_str()))
2155 , launcher_widths_(monitors::MAX, DEFAULT_LAUNCHER_WIDTH)
2156 , cached_form_factor_(FormFactor::DESKTOP)
2157+ , cursor_scale_(1.0)
2158 , cached_double_click_activate_(true)
2159+ , changing_gnome_settings_(false)
2160 , lowGfx_(false)
2161 {
2162+ parent_->form_factor.SetGetterFunction(sigc::mem_fun(this, &Impl::GetFormFactor));
2163+ parent_->form_factor.SetSetterFunction(sigc::mem_fun(this, &Impl::SetFormFactor));
2164+ parent_->double_click_activate.SetGetterFunction(sigc::mem_fun(this, &Impl::GetDoubleClickActivate));
2165+
2166 for (unsigned i = 0; i < monitors::MAX; ++i)
2167- em_converters_.push_back(std::make_shared<EMConverter>());
2168+ em_converters_.emplace_back(std::make_shared<EMConverter>());
2169
2170 CacheFormFactor();
2171 CacheDoubleClickActivate();
2172- UpdateEMConverter();
2173+
2174+ // The order is important here, DPI is the last thing to be updated
2175 UpdateLimSetting();
2176+ UpdateTextScaleFactor();
2177+ UpdateCursorScaleFactor();
2178+ UpdateFontSize();
2179+ UpdateDPI();
2180
2181- UScreen::GetDefault()->changed.connect(sigc::hide(sigc::hide(sigc::mem_fun(this, &Impl::UpdateEMConverter))));
2182+ UScreen::GetDefault()->changed.connect(sigc::hide(sigc::hide(sigc::mem_fun(this, &Impl::UpdateDPI))));
2183
2184 signals_.Add<void, GSettings*, const gchar*>(usettings_, "changed::" + FORM_FACTOR, [this] (GSettings*, const gchar*) {
2185 CacheFormFactor();
2186- parent_->form_factor.changed.emit(cached_form_factor_);
2187 });
2188
2189 signals_.Add<void, GSettings*, const gchar*>(usettings_, "changed::" + DOUBLE_CLICK_ACTIVATE, [this] (GSettings*, const gchar*) {
2190 CacheDoubleClickActivate();
2191 parent_->double_click_activate.changed.emit(cached_double_click_activate_);
2192 });
2193- signals_.Add<void, GSettings*, const gchar*>(ubuntu_settings_, "changed::" + SCALE_FACTOR, [this] (GSettings*, const gchar* t) {
2194- UpdateEMConverter();
2195- });
2196
2197 signals_.Add<void, GSettings*, const gchar*>(usettings_, "changed::" + LIM_KEY, [this] (GSettings*, const gchar*) {
2198 UpdateLimSetting();
2199 });
2200
2201+ signals_.Add<void, GSettings*, const gchar*>(ubuntu_ui_settings_, "changed::" + SCALE_FACTOR, [this] (GSettings*, const gchar* t) {
2202+ UpdateDPI();
2203+ });
2204+
2205+ signals_.Add<void, GSettings*, const gchar*>(ui_settings_, "changed::" + TEXT_SCALE_FACTOR, [this] (GSettings*, const gchar* t) {
2206+ UpdateTextScaleFactor();
2207+ UpdateDPI();
2208+ });
2209+
2210+ signals_.Add<void, GSettings*, const gchar*>(ui_settings_, "changed::" + CURSOR_SCALE_FACTOR, [this] (GSettings*, const gchar* t) {
2211+ UpdateCursorScaleFactor();
2212+ UpdateDPI();
2213+ });
2214+
2215+ signals_.Add<void, GSettings*, const gchar*>(ui_settings_, "changed::" + APP_SCALE_MONITOR, [this] (GSettings*, const gchar* t) {
2216+ UpdateDPI();
2217+ });
2218+
2219+ signals_.Add<void, GSettings*, const gchar*>(ui_settings_, "changed::" + APP_USE_MAX_SCALE, [this] (GSettings*, const gchar* t) {
2220+ UpdateDPI();
2221+ });
2222+
2223+ signals_.Add<void, GSettings*, const gchar*>(gnome_ui_settings_, "changed::" + GNOME_FONT_NAME, [this] (GSettings*, const gchar* t) {
2224+ UpdateFontSize();
2225+ UpdateDPI();
2226+ });
2227+
2228+ signals_.Add<void, GSettings*, const gchar*>(gnome_ui_settings_, "changed::" + GNOME_TEXT_SCALE_FACTOR, [this] (GSettings*, const gchar* t) {
2229+ if (!changing_gnome_settings_)
2230+ {
2231+ double new_scale_factor = g_settings_get_double(gnome_ui_settings_, GNOME_TEXT_SCALE_FACTOR.c_str());
2232+ g_settings_set_double(ui_settings_, TEXT_SCALE_FACTOR.c_str(), new_scale_factor);
2233+ }
2234+ });
2235+
2236 signals_.Add<void, GSettings*, const gchar*>(lim_settings_, "changed", [this] (GSettings*, const gchar*) {
2237 UpdateLimSetting();
2238 });
2239@@ -100,6 +157,7 @@
2240 void CacheFormFactor()
2241 {
2242 int raw_from_factor = g_settings_get_enum(usettings_, FORM_FACTOR.c_str());
2243+ FormFactor new_form_factor;
2244
2245 if (raw_from_factor == 0) //Automatic
2246 {
2247@@ -107,11 +165,17 @@
2248 int primary_monitor = uscreen->GetMonitorWithMouse();
2249 auto const& geo = uscreen->GetMonitorGeometry(primary_monitor);
2250
2251- cached_form_factor_ = geo.height > 799 ? FormFactor::DESKTOP : FormFactor::NETBOOK;
2252+ new_form_factor = geo.height > 799 ? FormFactor::DESKTOP : FormFactor::NETBOOK;
2253 }
2254 else
2255 {
2256- cached_form_factor_ = static_cast<FormFactor>(raw_from_factor);
2257+ new_form_factor = static_cast<FormFactor>(raw_from_factor);
2258+ }
2259+
2260+ if (new_form_factor != cached_form_factor_)
2261+ {
2262+ cached_form_factor_ = new_form_factor;
2263+ parent_->form_factor.changed.emit(cached_form_factor_);
2264 }
2265 }
2266
2267@@ -135,7 +199,7 @@
2268 bool SetFormFactor(FormFactor factor)
2269 {
2270 g_settings_set_enum(usettings_, FORM_FACTOR.c_str(), static_cast<int>(factor));
2271- return true;
2272+ return false;
2273 }
2274
2275 bool GetDoubleClickActivate() const
2276@@ -148,30 +212,14 @@
2277 gint font_size;
2278 PangoFontDescription* desc;
2279
2280- desc = pango_font_description_from_string(decoration::Style::Get()->font().c_str());
2281+ glib::String font_name(g_settings_get_string(gnome_ui_settings_, GNOME_FONT_NAME.c_str()));
2282+ desc = pango_font_description_from_string(font_name);
2283 font_size = pango_font_description_get_size(desc);
2284 pango_font_description_free(desc);
2285
2286 return font_size / 1024;
2287 }
2288
2289- int GetDPI(glib::Variant const& dict, int monitor) const
2290- {
2291- auto* uscreen = UScreen::GetDefault();
2292-
2293- if (monitor < 0 || monitor >= uscreen->GetPluggedMonitorsNumber())
2294- return DEFAULT_DPI;
2295-
2296- auto const& monitor_name = UScreen::GetDefault()->GetMonitorName(monitor);
2297- double ui_scale = 1.0f;
2298- int value;
2299-
2300- if (g_variant_lookup(dict, monitor_name.c_str(), "i", &value))
2301- ui_scale = static_cast<double>(value)/8.0f;
2302-
2303- return (DEFAULT_DPI * ui_scale);
2304- }
2305-
2306 void UpdateFontSize()
2307 {
2308 int font_size = GetFontSize();
2309@@ -180,41 +228,91 @@
2310 em->SetFontSize(font_size);
2311 }
2312
2313+ void UpdateTextScaleFactor()
2314+ {
2315+ parent_->font_scaling = g_settings_get_double(ui_settings_, TEXT_SCALE_FACTOR.c_str());
2316+ decoration::Style::Get()->font_scale = parent_->font_scaling();
2317+ }
2318+
2319+ void UpdateCursorScaleFactor()
2320+ {
2321+ cursor_scale_ = g_settings_get_double(ui_settings_, CURSOR_SCALE_FACTOR.c_str());
2322+ }
2323+
2324 void UpdateDPI()
2325 {
2326+ auto* uscreen = UScreen::GetDefault();
2327+ double min_scale = 4.0;
2328+ double max_scale = 0.0;
2329+ bool any_changed = false;
2330+
2331 glib::Variant dict;
2332- g_settings_get(ubuntu_settings_, SCALE_FACTOR.c_str(), "@a{si}", &dict);
2333- bool any_changed = false;
2334-
2335- for (unsigned i = 0; i < em_converters_.size(); ++i)
2336+ g_settings_get(ubuntu_ui_settings_, SCALE_FACTOR.c_str(), "@a{si}", &dict);
2337+
2338+ glib::String app_target_monitor(g_settings_get_string(ui_settings_, APP_SCALE_MONITOR.c_str()));
2339+ double app_target_scale = 0;
2340+
2341+ for (unsigned monitor = 0; monitor < em_converters_.size(); ++monitor)
2342 {
2343- int dpi = GetDPI(dict, i);
2344-
2345- if (em_converters_[i]->SetDPI(dpi))
2346+ int dpi = DEFAULT_DPI;
2347+
2348+ if (monitor < uscreen->GetMonitors().size())
2349+ {
2350+ auto const& monitor_name = uscreen->GetMonitorName(monitor);
2351+ double ui_scale = 1.0f;
2352+ int value;
2353+
2354+ if (g_variant_lookup(dict, monitor_name.c_str(), "i", &value))
2355+ ui_scale = static_cast<double>(value)/8.0f;
2356+
2357+ if (app_target_monitor.Str() == monitor_name)
2358+ app_target_scale = ui_scale;
2359+
2360+ dpi = DEFAULT_DPI * ui_scale;
2361+ min_scale = std::min(min_scale, ui_scale);
2362+ max_scale = std::max(max_scale, ui_scale);
2363+ }
2364+
2365+ if (em_converters_[monitor]->SetDPI(dpi))
2366 any_changed = true;
2367 }
2368
2369+ if (app_target_scale == 0)
2370+ app_target_scale = (g_settings_get_boolean(ui_settings_, APP_USE_MAX_SCALE.c_str())) ? max_scale : min_scale;
2371+
2372+ UpdateAppsScaling(app_target_scale);
2373+
2374 if (any_changed)
2375 parent_->dpi_changed.emit();
2376 }
2377
2378- void UpdateEMConverter()
2379+ void UpdateAppsScaling(double scale)
2380 {
2381- UpdateFontSize();
2382- UpdateDPI();
2383+ changing_gnome_settings_ = true;
2384+ unsigned integer_scaling = std::max<unsigned>(1, scale);
2385+ double point_scaling = scale / static_cast<double>(integer_scaling);
2386+ double text_scale_factor = parent_->font_scaling() * point_scaling;
2387+ glib::Variant default_cursor_size(g_settings_get_default_value(gnome_ui_settings_, GNOME_CURSOR_SIZE.c_str()), glib::StealRef());
2388+ int cursor_size = std::round(default_cursor_size.GetInt32() * point_scaling * cursor_scale_);
2389+ g_settings_set_int(gnome_ui_settings_, GNOME_CURSOR_SIZE.c_str(), cursor_size);
2390+ g_settings_set_uint(gnome_ui_settings_, GNOME_SCALE_FACTOR.c_str(), integer_scaling);
2391+ g_settings_set_double(gnome_ui_settings_, GNOME_TEXT_SCALE_FACTOR.c_str(), text_scale_factor);
2392+ changing_gnome_settings_ = false;
2393 }
2394
2395 Settings* parent_;
2396- glib::Object<GSettings> gsettings_;
2397- glib::Object<GSettings> ubuntu_settings_;
2398 glib::Object<GSettings> usettings_;
2399 glib::Object<GSettings> lim_settings_;
2400- glib::Object<GSettings> gnome_settings_;
2401+ glib::Object<GSettings> ui_settings_;
2402+ glib::Object<GSettings> ubuntu_ui_settings_;
2403+ glib::Object<GSettings> gnome_ui_settings_;
2404 glib::SignalManager signals_;
2405 std::vector<EMConverter::Ptr> em_converters_;
2406 std::vector<int> launcher_widths_;
2407 FormFactor cached_form_factor_;
2408+ double cursor_scale_;
2409 bool cached_double_click_activate_;
2410+ bool changing_gnome_settings_;
2411 bool lowGfx_;
2412 };
2413
2414@@ -229,17 +327,10 @@
2415 if (settings_instance)
2416 {
2417 LOG_ERROR(logger) << "More than one unity::Settings created.";
2418- }
2419-
2420- else
2421- {
2422- form_factor.SetGetterFunction(sigc::mem_fun(*pimpl, &Impl::GetFormFactor));
2423- form_factor.SetSetterFunction(sigc::mem_fun(*pimpl, &Impl::SetFormFactor));
2424-
2425- double_click_activate.SetGetterFunction(sigc::mem_fun(*pimpl, &Impl::GetDoubleClickActivate));
2426-
2427- settings_instance = this;
2428- }
2429+ return;
2430+ }
2431+
2432+ settings_instance = this;
2433 }
2434
2435 Settings::~Settings()
2436
2437=== modified file 'unity-shared/UnitySettings.h'
2438--- unity-shared/UnitySettings.h 2014-02-25 22:10:53 +0000
2439+++ unity-shared/UnitySettings.h 2014-03-21 23:09:12 +0000
2440@@ -54,6 +54,7 @@
2441 nux::ROProperty<bool> double_click_activate;
2442 nux::Property<unsigned> lim_movement_thresold;
2443 nux::Property<unsigned> lim_double_click_wait;
2444+ nux::Property<double> font_scaling;
2445
2446 sigc::signal<void> dpi_changed;
2447