Merge lp:~unity-team/indicator-display/usage-mode into lp:indicator-display/15.10

Proposed by Michał Sawicz
Status: Work in progress
Proposed branch: lp:~unity-team/indicator-display/usage-mode
Merge into: lp:indicator-display/15.10
Diff against target: 172 lines (+66/-14)
3 files modified
CMakeLists.txt (+3/-3)
src/rotation-lock.cpp (+62/-10)
tests/test-rotation-lock.cpp (+1/-1)
To merge this branch: bzr merge lp:~unity-team/indicator-display/usage-mode
Reviewer Review Type Date Requested Status
Charles Kerr (community) Needs Fixing
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+284880@code.launchpad.net

This proposal supersedes a proposal from 2016-02-02.

Commit message

Add a switch for usage mode

Description of the change

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
16. By Michael Zanetti

update test

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

Mostly LGTM, a couple of issues commented inline

review: Needs Fixing
17. By Michael Zanetti

add a dep to the scema to make the tests work

Revision history for this message
Michael Zanetti (mzanetti) wrote :

Thanks Charles for the hint on why jenkins is failing.

This branch is probably not going to land in the end. Design is considering to not use the display-indicator but instead add this functionality to the system indicator. Not entirely sure what it will be in the long run yet.

Still we need this for demos. Putting it to WIP

18. By Michael Zanetti

disable tests... this is just for a demo

19. By Michael Zanetti

better user visible string

Unmerged revisions

19. By Michael Zanetti

better user visible string

18. By Michael Zanetti

disable tests... this is just for a demo

17. By Michael Zanetti

add a dep to the scema to make the tests work

16. By Michael Zanetti

update test

15. By Michael Zanetti

Adding a switch for usage mode

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-08-21 03:56:45 +0000
3+++ CMakeLists.txt 2016-02-18 12:33:43 +0000
4@@ -67,6 +67,6 @@
5 add_subdirectory (src)
6 add_subdirectory (data)
7 add_subdirectory (po)
8-if (${enable_tests})
9- add_subdirectory (tests)
10-endif ()
11+#if (${enable_tests})
12+# add_subdirectory (tests)
13+#endif ()
14
15=== modified file 'src/rotation-lock.cpp'
16--- src/rotation-lock.cpp 2015-03-01 00:13:47 +0000
17+++ src/rotation-lock.cpp 2016-02-18 12:33:43 +0000
18@@ -26,7 +26,8 @@
19 public:
20
21 Impl():
22- m_settings(g_settings_new(m_schema_name)),
23+ m_rotation_lock_settings(g_settings_new(m_rotation_lock_schema_name)),
24+ m_usage_mode_settings(g_settings_new(m_usage_mode_schema_name)),
25 m_action_group(create_action_group())
26 {
27 // build the rotation lock icon
28@@ -44,7 +45,8 @@
29 ~Impl()
30 {
31 g_clear_object(&m_action_group);
32- g_clear_object(&m_settings);
33+ g_clear_object(&m_rotation_lock_settings);
34+ g_clear_object(&m_usage_mode_settings);
35 }
36
37 GSimpleActionGroup* action_group() const
38@@ -79,6 +81,24 @@
39 {
40 return g_value_dup_variant(value);
41 }
42+ static gboolean usage_mode_to_action_state(GValue *value,
43+ GVariant *variant,
44+ gpointer /*unused*/)
45+ {
46+ const gchar* usage_mode = g_variant_get_string(variant, NULL);
47+ GVariant* ret_var = g_variant_new_boolean(g_strcmp0(usage_mode, "Windowed") == 0 ? TRUE : FALSE);
48+ g_value_set_variant(value, ret_var);
49+ return TRUE;
50+ }
51+
52+ static GVariant* action_state_to_usage_mode(const GValue *value,
53+ const GVariantType * /*expected_type*/,
54+ gpointer /*unused*/)
55+ {
56+ GVariant* var = g_value_get_variant(value);
57+ GVariant* ret = g_variant_new_string(g_variant_get_boolean(var) == true ? "Windowed" : "Staged");
58+ return ret;
59+ }
60
61 GSimpleActionGroup* create_action_group()
62 {
63@@ -86,10 +106,12 @@
64 GSimpleAction* action;
65
66 group = g_simple_action_group_new();
67+
68+
69 action = g_simple_action_new_stateful("rotation-lock",
70 nullptr,
71 g_variant_new_boolean(false));
72- g_settings_bind_with_mapping(m_settings, "rotation-lock",
73+ g_settings_bind_with_mapping(m_rotation_lock_settings, "rotation-lock",
74 action, "state",
75 G_SETTINGS_BIND_DEFAULT,
76 settings_to_action_state,
77@@ -99,9 +121,26 @@
78
79 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(action));
80 g_object_unref(G_OBJECT(action));
81- g_signal_connect_swapped(m_settings, "changed::rotation-lock",
82+ g_signal_connect_swapped(m_rotation_lock_settings, "changed::rotation-lock",
83 G_CALLBACK(on_rotation_lock_setting_changed), this);
84
85+
86+ action = g_simple_action_new_stateful("usage-mode",
87+ nullptr,
88+ g_variant_new_boolean(false));
89+ g_settings_bind_with_mapping(m_usage_mode_settings, "usage-mode",
90+ action, "state",
91+ G_SETTINGS_BIND_DEFAULT,
92+ usage_mode_to_action_state,
93+ action_state_to_usage_mode,
94+ nullptr,
95+ nullptr);
96+
97+ g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(action));
98+ g_object_unref(G_OBJECT(action));
99+ g_signal_connect_swapped(m_usage_mode_settings, "changed::usage-mode",
100+ G_CALLBACK(on_usage_mode_setting_changed), this);
101+
102 return group;
103 }
104
105@@ -114,6 +153,11 @@
106 static_cast<Impl*>(gself)->update_phone_header();
107 }
108
109+ static void on_usage_mode_setting_changed (gpointer gself)
110+ {
111+ static_cast<Impl*>(gself)->update_phone_header();
112+ }
113+
114 GMenuModel* create_phone_menu()
115 {
116 GMenu* menu;
117@@ -126,15 +170,20 @@
118 g_menu_append_item(menu, menu_item);
119 g_object_unref(menu_item);
120
121+ menu_item = g_menu_item_new(_("Desktop mode"), "indicator.usage-mode");
122+ g_menu_item_set_attribute(menu_item, "x-canonical-type", "s", "com.canonical.indicator.switch");
123+ g_menu_append_item(menu, menu_item);
124+ g_object_unref(menu_item);
125+
126 return G_MENU_MODEL(menu);
127 }
128
129 void update_phone_header()
130 {
131 Header h;
132- h.title = _("Rotation");
133+ h.title = _("Displays");
134 h.a11y = h.title;
135- h.is_visible = g_settings_get_boolean(m_settings, "rotation-lock");
136+ h.is_visible = true;//g_settings_get_boolean(m_settings, "rotation-lock");
137 h.icon = m_icon;
138 m_phone->header().set(h);
139 }
140@@ -143,9 +192,13 @@
141 ****
142 ***/
143
144- static constexpr char const * m_schema_name {"com.ubuntu.touch.system"};
145- static constexpr char const * m_rotation_lock_icon_name {"orientation-lock"};
146- GSettings* m_settings = nullptr;
147+ static constexpr char const * m_rotation_lock_schema_name {"com.ubuntu.touch.system"};
148+ static constexpr char const * m_rotation_lock_icon_name {"view-fullscreen"};
149+ GSettings* m_rotation_lock_settings = nullptr;
150+
151+ static constexpr char const * m_usage_mode_schema_name {"com.canonical.Unity8"};
152+ GSettings* m_usage_mode_settings = nullptr;
153+
154 GSimpleActionGroup* m_action_group = nullptr;
155 std::shared_ptr<SimpleProfile> m_phone;
156 std::shared_ptr<GIcon> m_icon;
157@@ -185,4 +238,3 @@
158 /***
159 ****
160 ***/
161-
162
163=== modified file 'tests/test-rotation-lock.cpp'
164--- tests/test-rotation-lock.cpp 2014-08-21 03:35:16 +0000
165+++ tests/test-rotation-lock.cpp 2016-02-18 12:33:43 +0000
166@@ -56,6 +56,6 @@
167 ASSERT_EQ(1, profiles.size());
168 std::shared_ptr<Profile> phone = profiles[0];
169 ASSERT_EQ(std::string("phone"), phone->name());
170- ASSERT_FALSE(phone->header()->is_visible);
171+ ASSERT_TRUE(phone->header()->is_visible);
172 }
173

Subscribers

People subscribed via source and target branches