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

Proposed by Michael Zanetti
Status: Superseded
Proposed branch: lp:~unity-team/indicator-display/usage-mode
Merge into: lp:indicator-display/15.04
Diff against target: 147 lines (+62/-10)
1 file modified
src/rotation-lock.cpp (+62/-10)
To merge this branch: bzr merge lp:~unity-team/indicator-display/usage-mode
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Indicator Applet Developers Pending
Review via email: mp+284773@code.launchpad.net

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

This proposal has been superseded by a proposal from 2016-02-03.

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 :
review: Needs Fixing (continuous-integration)
16. By Michael Zanetti

update test

17. By Michael Zanetti

add a dep to the scema to make the tests work

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

Subscribers

People subscribed via source and target branches