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

Proposed by Charles Kerr
Status: Merged
Approved by: Ted Gould
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
Ted Gould (community) Approve
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.
Revision history for this message
Ted Gould (ted) wrote :

This looks like mostly flint fixes :-)

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
=== modified file 'src/exporter.cpp'
--- src/exporter.cpp 2014-08-21 16:59:37 +0000
+++ src/exporter.cpp 2014-10-06 20:57:23 +0000
@@ -140,8 +140,8 @@
140 g_action_map_add_action(G_ACTION_MAP(action_group), G_ACTION(a));140 g_action_map_add_action(G_ACTION_MAP(action_group), G_ACTION(a));
141 profile->header().changed().connect([action_group,action_name](const Header& header){141 profile->header().changed().connect([action_group,action_name](const Header& header){
142 auto state = create_header_state(header);142 auto state = create_header_state(header);
143 auto tmp = g_variant_print(state, true);143 char* tmp = g_variant_print(state, true);
144 g_message("header changed; updating action state to '%s'", tmp);144 g_debug("header changed; updating action state to '%s'", tmp);
145 g_action_group_change_action_state(G_ACTION_GROUP(action_group), 145 g_action_group_change_action_state(G_ACTION_GROUP(action_group),
146 action_name.c_str(),146 action_name.c_str(),
147 create_header_state(header));147 create_header_state(header));
148148
=== modified file 'src/exporter.h'
--- src/exporter.h 2014-08-21 03:35:16 +0000
+++ src/exporter.h 2014-10-06 20:57:23 +0000
@@ -17,6 +17,9 @@
17 * Charles Kerr <charles.kerr@canonical.com>17 * Charles Kerr <charles.kerr@canonical.com>
18 */18 */
1919
20#ifndef INDICATOR_DISPLAY_EXPORTER_H
21#define INDICATOR_DISPLAY_EXPORTER_H
22
20#include <src/indicator.h>23#include <src/indicator.h>
2124
22#include <core/signal.h>25#include <core/signal.h>
@@ -26,7 +29,7 @@
26class Exporter29class Exporter
27{30{
28public:31public:
29 Exporter(const std::shared_ptr<Indicator>& indicator);32 explicit Exporter(const std::shared_ptr<Indicator>& indicator);
30 ~Exporter();33 ~Exporter();
31 core::Signal<std::string>& name_lost();34 core::Signal<std::string>& name_lost();
3235
@@ -38,3 +41,4 @@
38 Exporter& operator=(const Exporter&) =delete;41 Exporter& operator=(const Exporter&) =delete;
39};42};
4043
44#endif /* INDICATOR_DISPLAY_EXPORTER_H */
4145
=== modified file 'src/indicator.h'
--- src/indicator.h 2014-08-21 03:35:16 +0000
+++ src/indicator.h 2014-10-06 20:57:23 +0000
@@ -52,6 +52,7 @@
52 virtual std::string name() const =0;52 virtual std::string name() const =0;
53 virtual const core::Property<Header>& header() const =0;53 virtual const core::Property<Header>& header() const =0;
54 virtual std::shared_ptr<GMenuModel> menu_model() const =0;54 virtual std::shared_ptr<GMenuModel> menu_model() const =0;
55 virtual ~Profile() =default;
5556
56protected:57protected:
57 Profile() =default;58 Profile() =default;
5859
=== modified file 'src/rotation-lock.cpp'
--- src/rotation-lock.cpp 2014-08-21 03:35:16 +0000
+++ src/rotation-lock.cpp 2014-10-06 20:57:23 +0000
@@ -30,7 +30,7 @@
30 m_action_group(create_action_group())30 m_action_group(create_action_group())
31 {31 {
32 // build the rotation lock icon32 // build the rotation lock icon
33 auto icon = g_themed_icon_new_with_default_fallbacks("orientation-lock");33 auto icon = g_themed_icon_new_with_default_fallbacks(m_rotation_lock_icon_name);
34 auto icon_deleter = [](GIcon* o){g_object_unref(G_OBJECT(o));};34 auto icon_deleter = [](GIcon* o){g_object_unref(G_OBJECT(o));};
35 m_icon.reset(icon, icon_deleter);35 m_icon.reset(icon, icon_deleter);
3636
@@ -69,8 +69,7 @@
69 GVariant *variant,69 GVariant *variant,
70 gpointer /*unused*/)70 gpointer /*unused*/)
71 {71 {
72 bool is_locked = g_strcmp0(g_variant_get_string(variant, nullptr), "none");72 g_value_set_variant(value, variant);
73 g_value_set_variant(value, g_variant_new_boolean(is_locked));
74 return TRUE;73 return TRUE;
75 }74 }
7675
@@ -78,16 +77,7 @@
78 const GVariantType * /*expected_type*/,77 const GVariantType * /*expected_type*/,
79 gpointer /*unused*/)78 gpointer /*unused*/)
80 {79 {
81 // Toggling to 'on' *should* lock to the screen's current orientation.80 return g_variant_new_boolean(g_value_get_boolean(value));
82 // We don't have any way of knowing Screen.orientation in this service,
83 // so just pick one at random to satisfy the binding's needs.
84 //
85 // In practice this doesn't matter since the indicator isn't visible
86 // when the lock mode is 'none' so the end user won't ever be able
87 // to toggle the menuitem from None to anything else.
88
89 auto state_is_true = g_variant_get_boolean(g_value_get_variant(value));
90 return g_variant_new_string(state_is_true ? "PrimaryOrientation" : "none");
91 }81 }
92 82
93 GSimpleActionGroup* create_action_group()83 GSimpleActionGroup* create_action_group()
@@ -99,17 +89,18 @@
99 action = g_simple_action_new_stateful("rotation-lock",89 action = g_simple_action_new_stateful("rotation-lock",
100 nullptr,90 nullptr,
101 g_variant_new_boolean(false));91 g_variant_new_boolean(false));
102 g_settings_bind_with_mapping(m_settings, "orientation-lock",92 g_settings_bind_with_mapping(m_settings, "rotation-lock",
103 action, "state",93 action, "state",
104 G_SETTINGS_BIND_DEFAULT,94 G_SETTINGS_BIND_DEFAULT,
105 settings_to_action_state,95 settings_to_action_state,
106 action_state_to_settings,96 action_state_to_settings,
107 nullptr,97 nullptr,
108 nullptr);98 nullptr);
99
109 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(action));100 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(action));
110 g_object_unref(G_OBJECT(action));101 g_object_unref(G_OBJECT(action));
111 g_signal_connect_swapped(m_settings, "changed::orientation-lock",102 g_signal_connect_swapped(m_settings, "changed::rotation-lock",
112 G_CALLBACK(on_orientation_lock_setting_changed), this);103 G_CALLBACK(on_rotation_lock_setting_changed), this);
113104
114 return group;105 return group;
115 }106 }
@@ -118,7 +109,7 @@
118 **** Phone profile109 **** Phone profile
119 ***/110 ***/
120111
121 static void on_orientation_lock_setting_changed (gpointer gself)112 static void on_rotation_lock_setting_changed (gpointer gself)
122 {113 {
123 static_cast<Impl*>(gself)->update_phone_header();114 static_cast<Impl*>(gself)->update_phone_header();
124 }115 }
@@ -143,7 +134,7 @@
143 Header h;134 Header h;
144 h.title = _("Rotation lock");135 h.title = _("Rotation lock");
145 h.a11y = h.title;136 h.a11y = h.title;
146 h.is_visible = g_settings_get_enum(m_settings, "orientation-lock") != 0;137 h.is_visible = g_settings_get_boolean(m_settings, "rotation-lock");
147 h.icon = m_icon;138 h.icon = m_icon;
148 m_phone->header().set(h);139 m_phone->header().set(h);
149 }140 }
@@ -153,7 +144,7 @@
153 ***/144 ***/
154145
155 static constexpr char const * m_schema_name {"com.ubuntu.touch.system"};146 static constexpr char const * m_schema_name {"com.ubuntu.touch.system"};
156 static constexpr char const * m_orientation_lock_icon_name {"orientation-lock"};147 static constexpr char const * m_rotation_lock_icon_name {"orientation-lock"};
157 GSettings* m_settings = nullptr;148 GSettings* m_settings = nullptr;
158 GSimpleActionGroup* m_action_group = nullptr;149 GSimpleActionGroup* m_action_group = nullptr;
159 std::shared_ptr<SimpleProfile> m_phone;150 std::shared_ptr<SimpleProfile> m_phone;
160151
=== modified file 'tests/glib-fixture.h'
--- tests/glib-fixture.h 2014-08-21 03:35:16 +0000
+++ tests/glib-fixture.h 2014-10-06 20:57:23 +0000
@@ -17,6 +17,9 @@
17 * Charles Kerr <charles.kerr@canonical.com>17 * Charles Kerr <charles.kerr@canonical.com>
18 */18 */
1919
20#ifndef INDICATOR_TESTS_GLIB_FIXTURE_H
21#define INDICATOR_TESTS_GLIB_FIXTURE_H
22
20#include <map>23#include <map>
2124
22#include <glib.h>25#include <glib.h>
@@ -52,7 +55,7 @@
5255
53 if (expected_log[level] != n)56 if (expected_log[level] != n)
54 for (size_t i=0; i<n; ++i)57 for (size_t i=0; i<n; ++i)
55 g_message("%d %s", (n+1), v[i].c_str());58 g_print("%d %s\n", (n+1), v[i].c_str());
56 }59 }
5760
58 expected_log.clear();61 expected_log.clear();
@@ -64,7 +67,7 @@
64 const gchar * message,67 const gchar * message,
65 gpointer self)68 gpointer self)
66 {69 {
67 auto tmp = g_strdup_printf ("%s:%d \"%s\"", log_domain, (int)log_level, message);70 char* tmp = g_strdup_printf ("%s:%d \"%s\"", log_domain, (int)log_level, message);
68 static_cast<GlibFixture*>(self)->log[log_level].push_back(tmp);71 static_cast<GlibFixture*>(self)->log[log_level].push_back(tmp);
69 g_free(tmp);72 g_free(tmp);
70 }73 }
@@ -140,4 +143,10 @@
140 }143 }
141144
142 GMainLoop * loop;145 GMainLoop * loop;
146
147 public:
148
149 virtual ~GlibFixture() =default;
143};150};
151
152#endif /* INDICATOR_TESTS_GLIB_FIXTURE_H */
144153
=== modified file 'tests/gtestdbus-fixture.h'
--- tests/gtestdbus-fixture.h 2014-08-21 03:35:16 +0000
+++ tests/gtestdbus-fixture.h 2014-10-06 20:57:23 +0000
@@ -17,6 +17,9 @@
17 * Charles Kerr <charles.kerr@canonical.com>17 * Charles Kerr <charles.kerr@canonical.com>
18 */18 */
1919
20#ifndef INDICATOR_TESTS_GTESTDBUS_FIXTURE_H
21#define INDICATOR_TESTS_GTESTDBUS_FIXTURE_H
22
20#include "glib-fixture.h"23#include "glib-fixture.h"
2124
22/***25/***
@@ -27,9 +30,10 @@
27{30{
28 public:31 public:
2932
30 GTestDBusFixture() {}33 GTestDBusFixture() =default;
34 virtual ~GTestDBusFixture() =default;
3135
32 GTestDBusFixture(const std::vector<std::string>& service_dirs_in): service_dirs(service_dirs_in) {}36 explicit GTestDBusFixture(const std::vector<std::string>& service_dirs_in): service_dirs(service_dirs_in) {}
3337
34 private:38 private:
3539
@@ -100,3 +104,5 @@
100 super::TearDown();104 super::TearDown();
101 }105 }
102};106};
107
108#endif /* INDICATOR_TESTS_GTESTDBUS_FIXTURE_H */
103109
=== modified file 'tests/manual'
--- tests/manual 2014-09-05 22:12:51 +0000
+++ tests/manual 2014-10-06 20:57:23 +0000
@@ -1,14 +1,12 @@
11
2Test-case indicator-display/rotation-indicator2Test-case indicator-display/rotation-indicator
3<dl>3<dl>
4 <dt>On the phone, enable the orientation lock in ubuntu-system-settings.</dt>4 <dt>On the phone, enable the rotation lock in ubuntu-system-settings.</dt>
5 <dd>The rotation lock indicator should appear, and its switch menuitem should be set to 'true'.</dd>5 <dd>The rotation lock indicator should appear, and its switch menuitem should be set to 'true'.</dd>
6 <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>
76
8 <dt>With the orientation locked, click on the indicator's switch menuitem to toggle from locked to unlocked.</dd>7 <dt>With the rotation locked, click on the indicator's switch menuitem to toggle from locked to unlocked.</dd>
9 <dd>The rotation lock indicator should disappear</dd>8 <dd>The rotation lock indicator should disappear</dd>
10 <dd>In ubuntu-system-settings, the orientation lock control should change to 'none'.</dd>9 <dd>In ubuntu-system-settings, the rotation lock control should change to 'none'.</dd>
11 <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>
12</dl>10</dl>
1311
1412

Subscribers

People subscribed via source and target branches