Merge lp:~charlesk/indicator-display/lp-1378078-use-rotation-lock-key into lp:indicator-display/14.10

Proposed by Charles Kerr on 2014-10-06
Status: Merged
Approved by: Ted Gould on 2014-10-06
Approved revision: 13
Merged at revision: 9
Proposed branch: lp:~charlesk/indicator-display/lp-1378078-use-rotation-lock-key
Merge into: lp:indicator-display/14.10
Diff against target: 240 lines (+40/-31)
7 files modified
src/exporter.cpp (+2/-2)
src/exporter.h (+5/-1)
src/indicator.h (+1/-0)
src/rotation-lock.cpp (+10/-19)
tests/glib-fixture.h (+11/-2)
tests/gtestdbus-fixture.h (+8/-2)
tests/manual (+3/-5)
To merge this branch: bzr merge lp:~charlesk/indicator-display/lp-1378078-use-rotation-lock-key
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve on 2014-10-06
Ted Gould (community) 2014-10-06 Approve on 2014-10-06
Review via email: mp+237339@code.launchpad.net

Commit message

Use com.ubuntu.touch.system's "rotation-lock" boolean for the rotation lock indicator.

Description of the change

Use com.ubuntu.touch.system's "rotation-lock" boolean for the rotation lock indicator.

Tested on mako + r73

Manual tests: indicator-display/rotation-indicator

To post a comment you must log in.
Ted Gould (ted) wrote :

This looks like mostly flint fixes :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/exporter.cpp'
2--- src/exporter.cpp 2014-08-21 16:59:37 +0000
3+++ src/exporter.cpp 2014-10-06 20:57:23 +0000
4@@ -140,8 +140,8 @@
5 g_action_map_add_action(G_ACTION_MAP(action_group), G_ACTION(a));
6 profile->header().changed().connect([action_group,action_name](const Header& header){
7 auto state = create_header_state(header);
8- auto tmp = g_variant_print(state, true);
9- g_message("header changed; updating action state to '%s'", tmp);
10+ char* tmp = g_variant_print(state, true);
11+ g_debug("header changed; updating action state to '%s'", tmp);
12 g_action_group_change_action_state(G_ACTION_GROUP(action_group),
13 action_name.c_str(),
14 create_header_state(header));
15
16=== modified file 'src/exporter.h'
17--- src/exporter.h 2014-08-21 03:35:16 +0000
18+++ src/exporter.h 2014-10-06 20:57:23 +0000
19@@ -17,6 +17,9 @@
20 * Charles Kerr <charles.kerr@canonical.com>
21 */
22
23+#ifndef INDICATOR_DISPLAY_EXPORTER_H
24+#define INDICATOR_DISPLAY_EXPORTER_H
25+
26 #include <src/indicator.h>
27
28 #include <core/signal.h>
29@@ -26,7 +29,7 @@
30 class Exporter
31 {
32 public:
33- Exporter(const std::shared_ptr<Indicator>& indicator);
34+ explicit Exporter(const std::shared_ptr<Indicator>& indicator);
35 ~Exporter();
36 core::Signal<std::string>& name_lost();
37
38@@ -38,3 +41,4 @@
39 Exporter& operator=(const Exporter&) =delete;
40 };
41
42+#endif /* INDICATOR_DISPLAY_EXPORTER_H */
43
44=== modified file 'src/indicator.h'
45--- src/indicator.h 2014-08-21 03:35:16 +0000
46+++ src/indicator.h 2014-10-06 20:57:23 +0000
47@@ -52,6 +52,7 @@
48 virtual std::string name() const =0;
49 virtual const core::Property<Header>& header() const =0;
50 virtual std::shared_ptr<GMenuModel> menu_model() const =0;
51+ virtual ~Profile() =default;
52
53 protected:
54 Profile() =default;
55
56=== modified file 'src/rotation-lock.cpp'
57--- src/rotation-lock.cpp 2014-08-21 03:35:16 +0000
58+++ src/rotation-lock.cpp 2014-10-06 20:57:23 +0000
59@@ -30,7 +30,7 @@
60 m_action_group(create_action_group())
61 {
62 // build the rotation lock icon
63- auto icon = g_themed_icon_new_with_default_fallbacks("orientation-lock");
64+ auto icon = g_themed_icon_new_with_default_fallbacks(m_rotation_lock_icon_name);
65 auto icon_deleter = [](GIcon* o){g_object_unref(G_OBJECT(o));};
66 m_icon.reset(icon, icon_deleter);
67
68@@ -69,8 +69,7 @@
69 GVariant *variant,
70 gpointer /*unused*/)
71 {
72- bool is_locked = g_strcmp0(g_variant_get_string(variant, nullptr), "none");
73- g_value_set_variant(value, g_variant_new_boolean(is_locked));
74+ g_value_set_variant(value, variant);
75 return TRUE;
76 }
77
78@@ -78,16 +77,7 @@
79 const GVariantType * /*expected_type*/,
80 gpointer /*unused*/)
81 {
82- // Toggling to 'on' *should* lock to the screen's current orientation.
83- // We don't have any way of knowing Screen.orientation in this service,
84- // so just pick one at random to satisfy the binding's needs.
85- //
86- // In practice this doesn't matter since the indicator isn't visible
87- // when the lock mode is 'none' so the end user won't ever be able
88- // to toggle the menuitem from None to anything else.
89-
90- auto state_is_true = g_variant_get_boolean(g_value_get_variant(value));
91- return g_variant_new_string(state_is_true ? "PrimaryOrientation" : "none");
92+ return g_variant_new_boolean(g_value_get_boolean(value));
93 }
94
95 GSimpleActionGroup* create_action_group()
96@@ -99,17 +89,18 @@
97 action = g_simple_action_new_stateful("rotation-lock",
98 nullptr,
99 g_variant_new_boolean(false));
100- g_settings_bind_with_mapping(m_settings, "orientation-lock",
101+ g_settings_bind_with_mapping(m_settings, "rotation-lock",
102 action, "state",
103 G_SETTINGS_BIND_DEFAULT,
104 settings_to_action_state,
105 action_state_to_settings,
106 nullptr,
107 nullptr);
108+
109 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(action));
110 g_object_unref(G_OBJECT(action));
111- g_signal_connect_swapped(m_settings, "changed::orientation-lock",
112- G_CALLBACK(on_orientation_lock_setting_changed), this);
113+ g_signal_connect_swapped(m_settings, "changed::rotation-lock",
114+ G_CALLBACK(on_rotation_lock_setting_changed), this);
115
116 return group;
117 }
118@@ -118,7 +109,7 @@
119 **** Phone profile
120 ***/
121
122- static void on_orientation_lock_setting_changed (gpointer gself)
123+ static void on_rotation_lock_setting_changed (gpointer gself)
124 {
125 static_cast<Impl*>(gself)->update_phone_header();
126 }
127@@ -143,7 +134,7 @@
128 Header h;
129 h.title = _("Rotation lock");
130 h.a11y = h.title;
131- h.is_visible = g_settings_get_enum(m_settings, "orientation-lock") != 0;
132+ h.is_visible = g_settings_get_boolean(m_settings, "rotation-lock");
133 h.icon = m_icon;
134 m_phone->header().set(h);
135 }
136@@ -153,7 +144,7 @@
137 ***/
138
139 static constexpr char const * m_schema_name {"com.ubuntu.touch.system"};
140- static constexpr char const * m_orientation_lock_icon_name {"orientation-lock"};
141+ static constexpr char const * m_rotation_lock_icon_name {"orientation-lock"};
142 GSettings* m_settings = nullptr;
143 GSimpleActionGroup* m_action_group = nullptr;
144 std::shared_ptr<SimpleProfile> m_phone;
145
146=== modified file 'tests/glib-fixture.h'
147--- tests/glib-fixture.h 2014-08-21 03:35:16 +0000
148+++ tests/glib-fixture.h 2014-10-06 20:57:23 +0000
149@@ -17,6 +17,9 @@
150 * Charles Kerr <charles.kerr@canonical.com>
151 */
152
153+#ifndef INDICATOR_TESTS_GLIB_FIXTURE_H
154+#define INDICATOR_TESTS_GLIB_FIXTURE_H
155+
156 #include <map>
157
158 #include <glib.h>
159@@ -52,7 +55,7 @@
160
161 if (expected_log[level] != n)
162 for (size_t i=0; i<n; ++i)
163- g_message("%d %s", (n+1), v[i].c_str());
164+ g_print("%d %s\n", (n+1), v[i].c_str());
165 }
166
167 expected_log.clear();
168@@ -64,7 +67,7 @@
169 const gchar * message,
170 gpointer self)
171 {
172- auto tmp = g_strdup_printf ("%s:%d \"%s\"", log_domain, (int)log_level, message);
173+ char* tmp = g_strdup_printf ("%s:%d \"%s\"", log_domain, (int)log_level, message);
174 static_cast<GlibFixture*>(self)->log[log_level].push_back(tmp);
175 g_free(tmp);
176 }
177@@ -140,4 +143,10 @@
178 }
179
180 GMainLoop * loop;
181+
182+ public:
183+
184+ virtual ~GlibFixture() =default;
185 };
186+
187+#endif /* INDICATOR_TESTS_GLIB_FIXTURE_H */
188
189=== modified file 'tests/gtestdbus-fixture.h'
190--- tests/gtestdbus-fixture.h 2014-08-21 03:35:16 +0000
191+++ tests/gtestdbus-fixture.h 2014-10-06 20:57:23 +0000
192@@ -17,6 +17,9 @@
193 * Charles Kerr <charles.kerr@canonical.com>
194 */
195
196+#ifndef INDICATOR_TESTS_GTESTDBUS_FIXTURE_H
197+#define INDICATOR_TESTS_GTESTDBUS_FIXTURE_H
198+
199 #include "glib-fixture.h"
200
201 /***
202@@ -27,9 +30,10 @@
203 {
204 public:
205
206- GTestDBusFixture() {}
207+ GTestDBusFixture() =default;
208+ virtual ~GTestDBusFixture() =default;
209
210- GTestDBusFixture(const std::vector<std::string>& service_dirs_in): service_dirs(service_dirs_in) {}
211+ explicit GTestDBusFixture(const std::vector<std::string>& service_dirs_in): service_dirs(service_dirs_in) {}
212
213 private:
214
215@@ -100,3 +104,5 @@
216 super::TearDown();
217 }
218 };
219+
220+#endif /* INDICATOR_TESTS_GTESTDBUS_FIXTURE_H */
221
222=== modified file 'tests/manual'
223--- tests/manual 2014-09-05 22:12:51 +0000
224+++ tests/manual 2014-10-06 20:57:23 +0000
225@@ -1,14 +1,12 @@
226
227 Test-case indicator-display/rotation-indicator
228 <dl>
229- <dt>On the phone, enable the orientation lock in ubuntu-system-settings.</dt>
230+ <dt>On the phone, enable the rotation lock in ubuntu-system-settings.</dt>
231 <dd>The rotation lock indicator should appear, and its switch menuitem should be set to 'true'.</dd>
232- <dd>NOTE: Current builds this is broken, until it is fixed in system settings you can set it with: <tt>gsettings set com.ubuntu.touch.system orientation-lock 'LandscapeOrientation'</tt></dd>
233
234- <dt>With the orientation locked, click on the indicator's switch menuitem to toggle from locked to unlocked.</dd>
235+ <dt>With the rotation locked, click on the indicator's switch menuitem to toggle from locked to unlocked.</dd>
236 <dd>The rotation lock indicator should disappear</dd>
237- <dd>In ubuntu-system-settings, the orientation lock control should change to 'none'.</dd>
238- <dd>NOTE: Current builds this is broken, until it is fixed in system settings you can get it with: <tt>gsettings get com.ubuntu.touch.system orientation-lock</tt></dd>
239+ <dd>In ubuntu-system-settings, the rotation lock control should change to 'none'.</dd>
240 </dl>
241
242

Subscribers

People subscribed via source and target branches