Merge lp:~3v1n0/unity/use-scaling-ubuntu-schemas-settings into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 4260
Proposed branch: lp:~3v1n0/unity/use-scaling-ubuntu-schemas-settings
Merge into: lp:unity
Diff against target: 527 lines (+126/-159)
11 files modified
debian/control (+2/-1)
debian/unity.migrations (+1/-0)
tests/data/external.gschema.xml (+13/-0)
tests/test_em_converter.cpp (+7/-19)
tests/test_raw_pixel.cpp (+1/-2)
tools/migration-scripts/02_unity_setup_text_scale_factor (+3/-7)
tools/migration-scripts/04_unity_update_software_center_desktop_file (+7/-6)
tools/migration-scripts/05_unity_use_ubuntu_scaling_settings_schemas (+66/-0)
unity-shared/EMConverter.cpp (+8/-63)
unity-shared/EMConverter.h (+1/-16)
unity-shared/UnitySettings.cpp (+17/-45)
To merge this branch: bzr merge lp:~3v1n0/unity/use-scaling-ubuntu-schemas-settings
Reviewer Review Type Date Requested Status
Didier Roche-Tolomelli Needs Fixing
Andrea Azzarone (community) Approve
Review via email: mp+331667@code.launchpad.net

Commit message

UnitySettings: use the ubuntu-schemas path for scaling settings

Also remove unused parts of EMConverter

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

+1

review: Approve
Revision history for this message
Andrea Azzarone (azzar1) wrote :

text-scaling is not correctly migrated doing an upgrade from Z to A using this ppa. But this improves the current behavior so +1 for me.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

The change looks good to me code-wise, there are 2 things on this and other merge proposals to do:
- please file a bug to explain why we are migrating those values. This is so that the release team understands the bug fix and reference it in each package impacted.
- on this one, we have a migration script for the scaling factor. However, we have another migration script to reset the scaling factor for GNOME. It means that if we run the ubuntu session before switching to the unity one, we need to ensure about the order (and having the migration script moving the key before the Ubuntu one). Another way is to move the reset from the other script to that one, after you migrated the settings. Mind doing that change?

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2017-09-01 09:48:41 +0000
+++ debian/control 2017-10-04 18:50:31 +0000
@@ -12,7 +12,7 @@
12 dh-python,12 dh-python,
13 google-mock (>= 1.6.0+svn437),13 google-mock (>= 1.6.0+svn437),
14 gsettings-desktop-schemas-dev,14 gsettings-desktop-schemas-dev,
15 gsettings-ubuntu-schemas (>= 0.0.1+14.04.20140219),15 gsettings-ubuntu-schemas (>= 0.0.7+17.10.20170922),
16 intltool (>= 0.35.0),16 intltool (>= 0.35.0),
17 libappstream-glib-dev,17 libappstream-glib-dev,
18 libatk1.0-dev,18 libatk1.0-dev,
@@ -73,6 +73,7 @@
73 compiz-core, compiz-core-abiversion-${coreabiversion},73 compiz-core, compiz-core-abiversion-${coreabiversion},
74 libnux-abiversion-${nuxabiversion},74 libnux-abiversion-${nuxabiversion},
75 compiz-plugins-default,75 compiz-plugins-default,
76 gsettings-ubuntu-schemas (>= 0.0.7+17.10.20170922),
76 libglib2.0-bin,77 libglib2.0-bin,
77 nux-tools,78 nux-tools,
78 python3-gi,79 python3-gi,
7980
=== modified file 'debian/unity.migrations'
--- debian/unity.migrations 2016-02-22 20:34:21 +0000
+++ debian/unity.migrations 2017-10-04 18:50:31 +0000
@@ -2,3 +2,4 @@
2tools/migration-scripts/02_unity_setup_text_scale_factor2tools/migration-scripts/02_unity_setup_text_scale_factor
3tools/migration-scripts/03_unity_first_run_stamp_move3tools/migration-scripts/03_unity_first_run_stamp_move
4tools/migration-scripts/04_unity_update_software_center_desktop_file4tools/migration-scripts/04_unity_update_software_center_desktop_file
5tools/migration-scripts/05_unity_use_ubuntu_scaling_settings_schemas
5\ No newline at end of file6\ No newline at end of file
67
=== modified file 'tests/data/external.gschema.xml'
--- tests/data/external.gschema.xml 2017-07-17 16:47:39 +0000
+++ tests/data/external.gschema.xml 2017-10-04 18:50:31 +0000
@@ -74,6 +74,19 @@
74 </key>74 </key>
75 </schema>75 </schema>
7676
77 <schema path="/com/ubuntu/user-interface/desktop/" id="com.ubuntu.user-interface.desktop">
78 <key type="u" name="scaling-factor">
79 <default>0</default>
80 </key>
81 <key type="d" name="text-scaling-factor">
82 <range min="0.5" max="3.0"/>
83 <default>1.0</default>
84 </key>
85 <key type="i" name="cursor-size">
86 <default>24</default>
87 </key>
88 </schema>
89
77 <schema id="com.canonical.unity-greeter" path="/com/canonical/unity-greeter/">90 <schema id="com.canonical.unity-greeter" path="/com/canonical/unity-greeter/">
78 <key type="s" name="logo">91 <key type="s" name="logo">
79 <default>'/usr/share/unity-greeter/logo.png'</default>92 <default>'/usr/share/unity-greeter/logo.png'</default>
8093
=== modified file 'tests/test_em_converter.cpp'
--- tests/test_em_converter.cpp 2014-02-07 23:45:27 +0000
+++ tests/test_em_converter.cpp 2017-10-04 18:50:31 +0000
@@ -26,34 +26,19 @@
26{26{
2727
28int const PIXEL_SIZE = 24;28int const PIXEL_SIZE = 24;
29int const FONT_SIZE = 13;
30double const DPI = 96.0;29double const DPI = 96.0;
3130
32class TestEMConverter : public Test31class TestEMConverter : public Test
33{32{
34public:33public:
35 TestEMConverter()34 TestEMConverter()
36 : em_converter(FONT_SIZE, DPI)35 : em_converter(DPI)
37 {36 {
38 }37 }
3938
40 EMConverter em_converter;39 EMConverter em_converter;
41};40};
4241
43TEST_F(TestEMConverter, TestCtor)
44{
45 EXPECT_EQ(FONT_SIZE, em_converter.GetFontSize());
46 EXPECT_EQ(DPI, em_converter.GetDPI());
47}
48
49TEST_F(TestEMConverter, TestSetFontSize)
50{
51 int const font_size = 15;
52
53 em_converter.SetFontSize(font_size);
54 EXPECT_EQ(font_size, em_converter.GetFontSize());
55}
56
57TEST_F(TestEMConverter, TestSetDPI)42TEST_F(TestEMConverter, TestSetDPI)
58{43{
59 int const dpi = 120.0;44 int const dpi = 120.0;
@@ -79,10 +64,13 @@
79 EXPECT_FLOAT_EQ(em_converter.DPIScale(), 2.0);64 EXPECT_FLOAT_EQ(em_converter.DPIScale(), 2.0);
80}65}
8166
82TEST_F(TestEMConverter, TestPtToPx)67TEST_F(TestEMConverter, TestConvertPixelScaled)
83{68{
84 int pt = 12;69 for (double scale : std::vector<double>({1.0, 1.25, 1.5, 1.75, 2}))
85 EXPECT_EQ(em_converter.PtToPx(pt), 16);70 {
71 em_converter.SetDPI(DPI * scale);
72 EXPECT_EQ(std::round(PIXEL_SIZE * scale), em_converter.CP(PIXEL_SIZE));
73 }
86}74}
8775
88} // namespace unity76} // namespace unity
8977
=== modified file 'tests/test_raw_pixel.cpp'
--- tests/test_raw_pixel.cpp 2014-02-26 00:01:21 +0000
+++ tests/test_raw_pixel.cpp 2017-10-04 18:50:31 +0000
@@ -25,14 +25,13 @@
25namespace unity25namespace unity
26{26{
2727
28int const FONT_SIZE = 13;
29double const DPI = 96.0;28double const DPI = 96.0;
3029
31class TestRawPixel : public Test30class TestRawPixel : public Test
32{31{
33public:32public:
34 TestRawPixel()33 TestRawPixel()
35 : cv(std::make_shared<EMConverter>(FONT_SIZE, DPI))34 : cv(std::make_shared<EMConverter>(DPI))
36 , p_i(10_em)35 , p_i(10_em)
37 , p_f(10.0_em)36 , p_f(10.0_em)
38 {37 {
3938
=== modified file 'tools/migration-scripts/02_unity_setup_text_scale_factor'
--- tools/migration-scripts/02_unity_setup_text_scale_factor 2016-02-22 20:34:21 +0000
+++ tools/migration-scripts/02_unity_setup_text_scale_factor 2017-10-04 18:50:31 +0000
@@ -1,6 +1,6 @@
1#!/usr/bin/python31#!/usr/bin/python3
2# -*- coding: utf-8 -*-2# -*- coding: utf-8 -*-
3# Copyright (C) 2014-2015 Canonical3# Copyright (C) 2014-2017 Canonical
4#4#
5# Authors:5# Authors:
6# Marco Trevisan <marco.trevisan@canonical.com>6# Marco Trevisan <marco.trevisan@canonical.com>
@@ -25,7 +25,6 @@
25GNOME_TEXT_SCALE_FACTOR = "text-scaling-factor";25GNOME_TEXT_SCALE_FACTOR = "text-scaling-factor";
2626
27UNITY_UI_SETTINGS = "com.canonical.Unity.Interface";27UNITY_UI_SETTINGS = "com.canonical.Unity.Interface";
28UNITY_UI_SETTINGS_PATH = "/com/canonical/unity/interface/"
29UNITY_TEXT_SCALE_FACTOR = "text-scale-factor";28UNITY_TEXT_SCALE_FACTOR = "text-scale-factor";
3029
31gnome_ui_schema = Gio.SettingsSchemaSource.get_default().lookup(GNOME_UI_SETTINGS, recursive=False)30gnome_ui_schema = Gio.SettingsSchemaSource.get_default().lookup(GNOME_UI_SETTINGS, recursive=False)
@@ -35,8 +34,5 @@
3534
36text_scale_factor = Gio.Settings(settings_schema=gnome_ui_schema).get_double(GNOME_TEXT_SCALE_FACTOR)35text_scale_factor = Gio.Settings(settings_schema=gnome_ui_schema).get_double(GNOME_TEXT_SCALE_FACTOR)
3736
38# gsettings doesn't work directly, the key is somewhat reverted. Work one level under then: dconf!37Gio.Settings.new(UNITY_UI_SETTINGS).set_double(UNITY_TEXT_SCALE_FACTOR, text_scale_factor)
39# Gio.Settings(schema=UNITY_UI_SETTINGS).set_int(UNITY_TEXT_SCALE_FACTOR, text_scale_factor)38Gio.Settings.sync()
40from subprocess import Popen, PIPE, STDOUT
41p = Popen(("dconf load "+UNITY_UI_SETTINGS_PATH).split(), stdout=PIPE, stdin=PIPE, stderr=STDOUT)
42p.communicate(input=bytes("[/]\n"+UNITY_TEXT_SCALE_FACTOR+"={}".format(text_scale_factor), 'utf-8'))
4339
=== modified file 'tools/migration-scripts/04_unity_update_software_center_desktop_file' (properties changed: -x to +x)
--- tools/migration-scripts/04_unity_update_software_center_desktop_file 2016-02-22 20:50:18 +0000
+++ tools/migration-scripts/04_unity_update_software_center_desktop_file 2017-10-04 18:50:31 +0000
@@ -21,16 +21,17 @@
21from gi.repository import Gio21from gi.repository import Gio
2222
23UNITY_LAUNCHER_SETTINGS = "com.canonical.Unity.Launcher";23UNITY_LAUNCHER_SETTINGS = "com.canonical.Unity.Launcher";
24UNITY_LAUNCHER_SETTINGS_PATH = "/com/canonical/unity/launcher/"
25UNITY_LAUNCER_FAVORITES = "favorites";24UNITY_LAUNCER_FAVORITES = "favorites";
2625
27favorites = Gio.Settings(schema=UNITY_LAUNCHER_SETTINGS).get_strv(UNITY_LAUNCER_FAVORITES)26launcher_settings = Gio.Settings.new(UNITY_LAUNCHER_SETTINGS)
27favorites = launcher_settings.get_strv(UNITY_LAUNCER_FAVORITES)
28replaced = False
2829
29for i in range(len(favorites)):30for i in range(len(favorites)):
30 if 'ubuntu-software-center.desktop' in favorites[i]:31 if 'ubuntu-software-center.desktop' in favorites[i]:
31 favorites[i] = favorites[i].replace('ubuntu-software-center', 'org.gnome.Software')32 favorites[i] = favorites[i].replace('ubuntu-software-center', 'org.gnome.Software')
33 replaced = True
3234
33# gsettings doesn't work directly, the key is somewhat reverted. Work one level under then: dconf!35if replaced:
34from subprocess import Popen, PIPE, STDOUT36 launcher_settings.set_strv(UNITY_LAUNCER_FAVORITES, favorites)
35p = Popen(("dconf load "+UNITY_LAUNCHER_SETTINGS_PATH).split(), stdout=PIPE, stdin=PIPE, stderr=STDOUT)37 Gio.Settings.sync()
36p.communicate(input=bytes("[/]\n"+UNITY_LAUNCER_FAVORITES+"={}".format(favorites), 'utf-8'))
3738
=== added file 'tools/migration-scripts/05_unity_use_ubuntu_scaling_settings_schemas'
--- tools/migration-scripts/05_unity_use_ubuntu_scaling_settings_schemas 1970-01-01 00:00:00 +0000
+++ tools/migration-scripts/05_unity_use_ubuntu_scaling_settings_schemas 2017-10-04 18:50:31 +0000
@@ -0,0 +1,66 @@
1#!/usr/bin/python3
2# -*- coding: utf-8 -*-
3# Copyright (C) 2014-2017 Canonical
4#
5# Authors:
6# Marco Trevisan <marco.trevisan@canonical.com>
7#
8# This program is free software; you can redistribute it and/or modify it under
9# the terms of the GNU General Public License as published by the Free Software
10# Foundation; version 3.
11#
12# This program is distributed in the hope that it will be useful, but WITHOUTa
13# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15# details.
16#
17# You should have received a copy of the GNU General Public License along with
18# this program; if not, write to the Free Software Foundation, Inc.,
19# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
21from gi.repository import Gio
22import os,sys
23
24GNOME_UI_SETTINGS = "org.gnome.desktop.interface";
25UBUNTU_UI_SETTINGS = "com.ubuntu.user-interface.desktop";
26UNITY_UI_SETTINGS = "com.canonical.Unity.Interface";
27
28KEYS_TO_TRANSLATE = { "text-scaling-factor": "text-scale-factor" }
29KEYS_TO_MIGRATE = [ "cursor-size", "scaling-factor", "text-scaling-factor" ]
30
31gnome_ui_schema = Gio.SettingsSchemaSource.get_default().lookup(GNOME_UI_SETTINGS, recursive=False)
32if not gnome_ui_schema:
33 print("No gnome desktop interface schemas found, no migration needed")
34 sys.exit(0)
35
36ubuntu_ui_schema = Gio.SettingsSchemaSource.get_default().lookup(UBUNTU_UI_SETTINGS, recursive=False)
37if not ubuntu_ui_schema:
38 print("No ubuntu desktop interface schemas found, no migration needed")
39 sys.exit(0)
40
41gnome_settings = Gio.Settings(settings_schema=gnome_ui_schema)
42ubuntu_settings = Gio.Settings(settings_schema=ubuntu_ui_schema)
43
44for key in KEYS_TO_MIGRATE:
45 gnome_value = gnome_settings.get_value(key)
46 ubuntu_value = ubuntu_settings.get_value(key)
47
48 # We reset the gnome values first
49 if gnome_settings.is_writable(key):
50 if key in KEYS_TO_TRANSLATE.keys():
51 unity_value = Gio.Settings.new(UNITY_UI_SETTINGS).get_value(KEYS_TO_TRANSLATE[key])
52 if unity_value != gnome_value:
53 gnome_settings.set_value(key, unity_value)
54 else:
55 gnome_settings.reset(key)
56 else:
57 print("Can't reset or migrate key '{} {}': in read only.".format(GNOME_UI_SETTINGS, key))
58
59 # Then we migrate the settings, so that u-s-d proxy won't interfere
60 if ubuntu_settings.is_writable(key):
61 if ubuntu_value != gnome_value:
62 ubuntu_settings.set_value(key, gnome_value)
63 else:
64 print("Can't migrate key '{} {}': in read only.".format(UBUNTU_UI_SETTINGS, key))
65
66Gio.Settings.sync()
067
=== modified file 'unity-shared/EMConverter.cpp'
--- unity-shared/EMConverter.cpp 2014-05-08 03:19:39 +0000
+++ unity-shared/EMConverter.cpp 2017-10-04 18:50:31 +0000
@@ -23,86 +23,31 @@
23namespace unity23namespace unity
24{24{
2525
26double const BASE_DPI = 96.0;26namespace
27double const DEFAULT_PPE = 10.0;27{
28double const PIXELS_PER_INCH = 72.0;28const double BASE_DPI = 96.0;
2929}
30EMConverter::EMConverter(int font_size, double dpi)30
31 : pixels_per_em_(DEFAULT_PPE)31EMConverter::EMConverter(double dpi)
32 , base_pixels_per_em_(DEFAULT_PPE)32 : dpi_(dpi)
33 , dpi_(dpi)33{}
34 , font_size_(font_size)
35{
36 UpdatePixelsPerEM();
37 UpdateBasePixelsPerEM();
38}
39
40double EMConverter::PtToPx(int pt)
41{
42 return pt * dpi_ / PIXELS_PER_INCH;
43}
44
45void EMConverter::UpdatePixelsPerEM()
46{
47 pixels_per_em_ = font_size_ * dpi_ / PIXELS_PER_INCH;
48
49 if (pixels_per_em_ == 0)
50 pixels_per_em_ = DEFAULT_PPE;
51}
52
53void EMConverter::UpdateBasePixelsPerEM()
54{
55 base_pixels_per_em_ = font_size_ * BASE_DPI / PIXELS_PER_INCH;
56
57 if (base_pixels_per_em_ == 0)
58 base_pixels_per_em_ = DEFAULT_PPE;
59}
60
61bool EMConverter::SetFontSize(int font_size)
62{
63 if (font_size != font_size_)
64 {
65 font_size_ = font_size;
66 UpdatePixelsPerEM();
67 UpdateBasePixelsPerEM();
68 return true;
69 }
70
71 return false;
72}
7334
74bool EMConverter::SetDPI(double dpi)35bool EMConverter::SetDPI(double dpi)
75{36{
76 if (dpi != dpi_)37 if (dpi != dpi_)
77 {38 {
78 dpi_ = dpi;39 dpi_ = dpi;
79 UpdatePixelsPerEM();
80 return true;40 return true;
81 }41 }
8242
83 return false;43 return false;
84}44}
8545
86int EMConverter::GetFontSize() const
87{
88 return font_size_;
89}
90
91double EMConverter::GetDPI() const46double EMConverter::GetDPI() const
92{47{
93 return dpi_;48 return dpi_;
94}49}
9550
96double EMConverter::EMToPixels(double em) const
97{
98 return (em * pixels_per_em_);
99}
100
101double EMConverter::PixelsToBaseEM(int pixels) const
102{
103 return (pixels / base_pixels_per_em_);
104}
105
106double EMConverter::CP(int pixels) const51double EMConverter::CP(int pixels) const
107{52{
108 return std::round(pixels * DPIScale());53 return std::round(pixels * DPIScale());
10954
=== modified file 'unity-shared/EMConverter.h'
--- unity-shared/EMConverter.h 2014-02-27 04:54:19 +0000
+++ unity-shared/EMConverter.h 2017-10-04 18:50:31 +0000
@@ -30,31 +30,16 @@
30public:30public:
31 typedef std::shared_ptr<EMConverter> Ptr;31 typedef std::shared_ptr<EMConverter> Ptr;
3232
33 EMConverter(int font_size = 0, double dpi = 96.0);33 EMConverter(double dpi = 96.0);
3434
35 bool SetFontSize(int font_size);
36 bool SetDPI(double dpi);35 bool SetDPI(double dpi);
37
38 int GetFontSize() const;
39 double GetDPI() const;36 double GetDPI() const;
4037
41 double CP(int pixels) const;38 double CP(int pixels) const;
42 double DPIScale() const;39 double DPIScale() const;
4340
44 double PtToPx(int pt);
45
46private:41private:
47 void UpdatePixelsPerEM();
48 void UpdateBasePixelsPerEM();
49
50 double EMToPixels(double em) const;
51 double PixelsToBaseEM(int pixels) const;
52
53 double pixels_per_em_;
54 double base_pixels_per_em_;
55
56 double dpi_;42 double dpi_;
57 int font_size_;
58};43};
5944
60} // namespace unity45} // namespace unity
6146
=== modified file 'unity-shared/UnitySettings.cpp'
--- unity-shared/UnitySettings.cpp 2017-07-17 10:33:25 +0000
+++ unity-shared/UnitySettings.cpp 2017-10-04 18:50:31 +0000
@@ -62,13 +62,12 @@
62const std::string COMPIZ_PROFILE = "current-profile";62const std::string COMPIZ_PROFILE = "current-profile";
6363
64const std::string UBUNTU_UI_SETTINGS = "com.ubuntu.user-interface";64const std::string UBUNTU_UI_SETTINGS = "com.ubuntu.user-interface";
65const std::string UBUNTU_DESKTOP_UI_SETTINGS = "com.ubuntu.user-interface.desktop";
65const std::string SCALE_FACTOR = "scale-factor";66const std::string SCALE_FACTOR = "scale-factor";
6667
67const std::string GNOME_UI_SETTINGS = "org.gnome.desktop.interface";68const std::string DESKTOP_CURSOR_SIZE = "cursor-size";
68const std::string GNOME_FONT_NAME = "font-name";69const std::string DESKTOP_SCALE_FACTOR = "scaling-factor";
69const std::string GNOME_CURSOR_SIZE = "cursor-size";70const std::string DESKTOP_TEXT_SCALE_FACTOR = "text-scaling-factor";
70const std::string GNOME_SCALE_FACTOR = "scaling-factor";
71const std::string GNOME_TEXT_SCALE_FACTOR = "text-scaling-factor";
7271
73const std::string REMOTE_CONTENT_SETTINGS = "com.canonical.Unity.Lenses";72const std::string REMOTE_CONTENT_SETTINGS = "com.canonical.Unity.Lenses";
74const std::string REMOTE_CONTENT_KEY = "remote-content-search";73const std::string REMOTE_CONTENT_KEY = "remote-content-search";
@@ -84,7 +83,7 @@
8483
85const int DEFAULT_LAUNCHER_SIZE = 64;84const int DEFAULT_LAUNCHER_SIZE = 64;
86const int MINIMUM_DESKTOP_HEIGHT = 800;85const int MINIMUM_DESKTOP_HEIGHT = 800;
87const int GNOME_SETTINGS_CHANGED_WAIT_SECONDS = 1;86const int DESKTOP_SETTINGS_CHANGED_WAIT_SECONDS = 1;
88const double DEFAULT_DPI = 96.0f;87const double DEFAULT_DPI = 96.0f;
89const double DPI_SCALING_LIMIT = 140.0f;88const double DPI_SCALING_LIMIT = 140.0f;
90const int DPI_SCALING_STEP = 8;89const int DPI_SCALING_STEP = 8;
@@ -105,7 +104,7 @@
105 , gestures_settings_(g_settings_new(GESTURES_SETTINGS.c_str()))104 , gestures_settings_(g_settings_new(GESTURES_SETTINGS.c_str()))
106 , ui_settings_(g_settings_new(UI_SETTINGS.c_str()))105 , ui_settings_(g_settings_new(UI_SETTINGS.c_str()))
107 , ubuntu_ui_settings_(g_settings_new(UBUNTU_UI_SETTINGS.c_str()))106 , ubuntu_ui_settings_(g_settings_new(UBUNTU_UI_SETTINGS.c_str()))
108 , gnome_ui_settings_(g_settings_new(GNOME_UI_SETTINGS.c_str()))107 , desktop_ui_settings_(g_settings_new(UBUNTU_DESKTOP_UI_SETTINGS.c_str()))
109 , remote_content_settings_(g_settings_new(REMOTE_CONTENT_SETTINGS.c_str()))108 , remote_content_settings_(g_settings_new(REMOTE_CONTENT_SETTINGS.c_str()))
110 , launcher_sizes_(monitors::MAX, DEFAULT_LAUNCHER_SIZE)109 , launcher_sizes_(monitors::MAX, DEFAULT_LAUNCHER_SIZE)
111 , cached_launcher_position_(LauncherPosition::LEFT)110 , cached_launcher_position_(LauncherPosition::LEFT)
@@ -174,13 +173,8 @@
174 UpdateDPI();173 UpdateDPI();
175 });174 });
176175
177 signals_.Add<void, GSettings*, const gchar*>(gnome_ui_settings_, "changed::" + GNOME_FONT_NAME, [this] (GSettings*, const gchar* t) {176 signals_.Add<void, GSettings*, const gchar*>(desktop_ui_settings_, "changed::" + DESKTOP_TEXT_SCALE_FACTOR, [this] (GSettings*, const gchar* t) {
178 UpdateFontSize();177 double new_scale_factor = g_settings_get_double(desktop_ui_settings_, DESKTOP_TEXT_SCALE_FACTOR.c_str());
179 UpdateDPI();
180 });
181
182 signals_.Add<void, GSettings*, const gchar*>(gnome_ui_settings_, "changed::" + GNOME_TEXT_SCALE_FACTOR, [this] (GSettings*, const gchar* t) {
183 double new_scale_factor = g_settings_get_double(gnome_ui_settings_, GNOME_TEXT_SCALE_FACTOR.c_str());
184 g_settings_set_double(ui_settings_, TEXT_SCALE_FACTOR.c_str(), new_scale_factor);178 g_settings_set_double(ui_settings_, TEXT_SCALE_FACTOR.c_str(), new_scale_factor);
185 });179 });
186180
@@ -203,7 +197,6 @@
203 UpdateGesturesSetting();197 UpdateGesturesSetting();
204 UpdateTextScaleFactor();198 UpdateTextScaleFactor();
205 UpdateCursorScaleFactor();199 UpdateCursorScaleFactor();
206 UpdateFontSize();
207 UpdateDPI();200 UpdateDPI();
208201
209 CacheFormFactor();202 CacheFormFactor();
@@ -365,27 +358,6 @@
365 return g_settings_get_boolean(usettings_, PAM_CHECK_ACCOUNT_TYPE.c_str());358 return g_settings_get_boolean(usettings_, PAM_CHECK_ACCOUNT_TYPE.c_str());
366 }359 }
367360
368 int GetFontSize() const
369 {
370 gint font_size;
371 PangoFontDescription* desc;
372
373 glib::String font_name(g_settings_get_string(gnome_ui_settings_, GNOME_FONT_NAME.c_str()));
374 desc = pango_font_description_from_string(font_name);
375 font_size = pango_font_description_get_size(desc);
376 pango_font_description_free(desc);
377
378 return font_size / 1024;
379 }
380
381 void UpdateFontSize()
382 {
383 int font_size = GetFontSize();
384
385 for (auto const& em : em_converters_)
386 em->SetFontSize(font_size);
387 }
388
389 void UpdateTextScaleFactor()361 void UpdateTextScaleFactor()
390 {362 {
391 parent_->font_scaling = g_settings_get_double(ui_settings_, TEXT_SCALE_FACTOR.c_str());363 parent_->font_scaling = g_settings_get_double(ui_settings_, TEXT_SCALE_FACTOR.c_str());
@@ -505,18 +477,18 @@
505477
506 void UpdateAppsScaling(double scale)478 void UpdateAppsScaling(double scale)
507 {479 {
508 signals_.Block(gnome_ui_settings_);480 signals_.Block(desktop_ui_settings_);
509 unsigned integer_scaling = std::max<unsigned>(1, std::lround(scale));481 unsigned integer_scaling = std::max<unsigned>(1, std::lround(scale));
510 double point_scaling = scale / static_cast<double>(integer_scaling);482 double point_scaling = scale / static_cast<double>(integer_scaling);
511 double text_scale_factor = parent_->font_scaling() * point_scaling;483 double text_scale_factor = parent_->font_scaling() * point_scaling;
512 glib::Variant default_cursor_size(g_settings_get_default_value(gnome_ui_settings_, GNOME_CURSOR_SIZE.c_str()), glib::StealRef());484 glib::Variant default_cursor_size(g_settings_get_default_value(desktop_ui_settings_, DESKTOP_CURSOR_SIZE.c_str()), glib::StealRef());
513 int cursor_size = std::round(default_cursor_size.GetInt32() * point_scaling * cursor_scale_);485 int cursor_size = std::round(default_cursor_size.GetInt32() * point_scaling * cursor_scale_);
514 g_settings_set_int(gnome_ui_settings_, GNOME_CURSOR_SIZE.c_str(), cursor_size);486 g_settings_set_int(desktop_ui_settings_, DESKTOP_CURSOR_SIZE.c_str(), cursor_size);
515 g_settings_set_uint(gnome_ui_settings_, GNOME_SCALE_FACTOR.c_str(), integer_scaling);487 g_settings_set_uint(desktop_ui_settings_, DESKTOP_SCALE_FACTOR.c_str(), integer_scaling);
516 g_settings_set_double(gnome_ui_settings_, GNOME_TEXT_SCALE_FACTOR.c_str(), text_scale_factor);488 g_settings_set_double(desktop_ui_settings_, DESKTOP_TEXT_SCALE_FACTOR.c_str(), text_scale_factor);
517489
518 changing_gnome_settings_timeout_.reset(new glib::TimeoutSeconds(GNOME_SETTINGS_CHANGED_WAIT_SECONDS, [this] {490 changing_desktop_settings_timeout_.reset(new glib::TimeoutSeconds(DESKTOP_SETTINGS_CHANGED_WAIT_SECONDS, [this] {
519 signals_.Unblock(gnome_ui_settings_);491 signals_.Unblock(desktop_ui_settings_);
520 return false;492 return false;
521 }, glib::Source::Priority::LOW));493 }, glib::Source::Priority::LOW));
522 }494 }
@@ -546,9 +518,9 @@
546 glib::Object<GSettings> gestures_settings_;518 glib::Object<GSettings> gestures_settings_;
547 glib::Object<GSettings> ui_settings_;519 glib::Object<GSettings> ui_settings_;
548 glib::Object<GSettings> ubuntu_ui_settings_;520 glib::Object<GSettings> ubuntu_ui_settings_;
549 glib::Object<GSettings> gnome_ui_settings_;521 glib::Object<GSettings> desktop_ui_settings_;
550 glib::Object<GSettings> remote_content_settings_;522 glib::Object<GSettings> remote_content_settings_;
551 glib::Source::UniquePtr changing_gnome_settings_timeout_;523 glib::Source::UniquePtr changing_desktop_settings_timeout_;
552 glib::SignalManager signals_;524 glib::SignalManager signals_;
553 std::vector<EMConverter::Ptr> em_converters_;525 std::vector<EMConverter::Ptr> em_converters_;
554 std::vector<int> launcher_sizes_;526 std::vector<int> launcher_sizes_;