Merge lp:~lukas-kde/indicator-session/desktopModeSwitch into lp:indicator-session/15.10

Proposed by Lukáš Tinkl
Status: Merged
Approved by: Michael Zanetti
Approved revision: 476
Merged at revision: 468
Proposed branch: lp:~lukas-kde/indicator-session/desktopModeSwitch
Merge into: lp:indicator-session/15.10
Diff against target: 211 lines (+95/-7)
2 files modified
src/backend-dbus/actions.c (+4/-1)
src/service.c (+91/-6)
To merge this branch: bzr merge lp:~lukas-kde/indicator-session/desktopModeSwitch
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Approve
Antti Kaijanmäki (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+288413@code.launchpad.net

Commit message

Add a "Desktop mode" switch for Unity 8

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

LGTM!

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

acking the changes after Antti approved

review: Approve
477. By Michael Terry

Only use unity8 schema if it's installed to avoid hard dependency on unity8-schemas

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/backend-dbus/actions.c'
2--- src/backend-dbus/actions.c 2015-08-27 15:07:19 +0000
3+++ src/backend-dbus/actions.c 2016-03-15 14:47:40 +0000
4@@ -825,7 +825,10 @@
5 static void
6 my_help (IndicatorSessionActions * self G_GNUC_UNUSED)
7 {
8- run_outside_app ("yelp");
9+ if (g_getenv ("MIR_SOCKET") != NULL)
10+ url_dispatch_send("http://www.askubuntu.com", NULL, NULL);
11+ else
12+ run_outside_app ("yelp");
13 }
14
15 static gboolean
16
17=== modified file 'src/service.c'
18--- src/service.c 2015-06-04 14:30:21 +0000
19+++ src/service.c 2016-03-15 14:47:40 +0000
20@@ -78,6 +78,8 @@
21 "desktop_lockscreen"
22 };
23
24+static const char * const usage_mode_schema_name = "com.canonical.Unity8";
25+
26 struct ProfileMenuInfo
27 {
28 /* the root level -- the header is the only child of this */
29@@ -98,12 +100,14 @@
30 IndicatorSessionActions * backend_actions;
31 GSettings * indicator_settings;
32 GSettings * keybinding_settings;
33+ GSettings * usage_mode_settings;
34 GSimpleActionGroup * actions;
35 guint actions_export_id;
36 struct ProfileMenuInfo menus[N_PROFILES];
37 GSimpleAction * header_action;
38 GSimpleAction * user_switcher_action;
39 GSimpleAction * guest_switcher_action;
40+ GSimpleAction * usage_mode_action;
41 GHashTable * users;
42 GHashTable * reported_users;
43 guint rebuild_id;
44@@ -149,6 +153,11 @@
45 {
46 rebuild_soon (self, SECTION_SETTINGS);
47 }
48+static inline void
49+rebuild_admin_section_soon (IndicatorSessionService * self)
50+{
51+ rebuild_soon (self, SECTION_ADMIN);
52+}
53
54 /***
55 ****
56@@ -413,15 +422,57 @@
57 return distro_name;
58 }
59
60+static gboolean
61+usage_mode_to_action_state(GValue *value,
62+ GVariant *variant,
63+ gpointer unused)
64+{
65+ const gchar* usage_mode = g_variant_get_string(variant, NULL);
66+ GVariant* ret_var = g_variant_new_boolean(g_strcmp0(usage_mode, "Windowed") == 0 ? TRUE : FALSE);
67+ g_value_set_variant(value, ret_var);
68+ return TRUE;
69+}
70+
71+static GVariant*
72+action_state_to_usage_mode(const GValue *value,
73+ const GVariantType * unused_expected_type,
74+ gpointer unused)
75+{
76+ GVariant* var = g_value_get_variant(value);
77+ GVariant* ret = g_variant_new_string(g_variant_get_boolean(var) == TRUE ? "Windowed" : "Staged");
78+ return ret;
79+}
80+
81+static void
82+on_usage_mode_setting_changed (gpointer gself)
83+{
84+ rebuild_admin_section_soon((IndicatorSessionService*)(gself));
85+}
86+
87 static GMenuModel *
88-create_admin_section (void)
89+create_admin_section (IndicatorSessionService * self)
90 {
91 GMenu * menu;
92- gchar * help_label = g_strdup_printf(_("%s Help"), get_distro_name());
93+ priv_t * p = self->priv;
94+ gchar * help_label = g_strdup_printf(_("%s Help…"), get_distro_name());
95 menu = g_menu_new ();
96- g_menu_append (menu, _("About This Computer"), "indicator.about");
97+ if (g_getenv ("MIR_SOCKET") != NULL) {
98+ g_menu_append (menu, _("About This Device…"), "indicator.about");
99+ } else {
100+ g_menu_append (menu, _("About This Computer"), "indicator.about");
101+ }
102 g_menu_append (menu, help_label, "indicator.help");
103 g_free (help_label);
104+
105+ if (p->usage_mode_action && g_getenv ("MIR_SOCKET") != NULL) // only under unity8
106+ {
107+ GMenuItem * menu_item = NULL;
108+ menu_item = g_menu_item_new(_("Desktop mode"), "indicator.usage-mode");
109+ g_menu_item_set_attribute(menu_item, "x-canonical-type", "s", "com.canonical.indicator.switch");
110+ g_menu_append_item(menu, menu_item);
111+ g_object_unref(menu_item);
112+ }
113+
114 return G_MENU_MODEL (menu);
115 }
116
117@@ -822,7 +873,7 @@
118
119 if (profile == PROFILE_DESKTOP)
120 {
121- sections[n++] = create_admin_section ();
122+ sections[n++] = create_admin_section (self);
123 sections[n++] = create_settings_section (self);
124 sections[n++] = create_switch_section (self, profile);
125 sections[n++] = create_logout_section (self);
126@@ -1012,13 +1063,33 @@
127 g_action_map_add_action (G_ACTION_MAP (p->actions), G_ACTION(a));
128 p->guest_switcher_action = a;
129
130- /* add switch-to-user action... parameter is the uesrname */
131+ /* add switch-to-user action... parameter is the username */
132 v = create_user_switcher_state (self);
133 a = g_simple_action_new_stateful ("switch-to-user", G_VARIANT_TYPE_STRING, v);
134 g_signal_connect (a, "activate", G_CALLBACK(on_user_activated), self);
135 g_action_map_add_action (G_ACTION_MAP (p->actions), G_ACTION(a));
136 p->user_switcher_action = a;
137
138+ /* add usage-mode action */
139+ if (p->usage_mode_settings)
140+ {
141+ a = g_simple_action_new_stateful("usage-mode",
142+ NULL,
143+ g_variant_new_boolean(FALSE));
144+ g_settings_bind_with_mapping(p->usage_mode_settings, "usage-mode",
145+ a, "state",
146+ G_SETTINGS_BIND_DEFAULT,
147+ usage_mode_to_action_state,
148+ action_state_to_usage_mode,
149+ NULL,
150+ NULL);
151+
152+ g_action_map_add_action(G_ACTION_MAP(p->actions), G_ACTION(a));
153+ g_signal_connect_swapped(p->usage_mode_settings, "changed::usage-mode",
154+ G_CALLBACK(on_usage_mode_setting_changed), self);
155+ p->usage_mode_action = a;
156+ }
157+
158 /* add the header action */
159 a = g_simple_action_new_stateful ("_header", NULL,
160 action_state_for_header (self));
161@@ -1060,7 +1131,7 @@
162
163 if (sections & SECTION_ADMIN)
164 {
165- rebuild_section (desktop->submenu, 0, create_admin_section());
166+ rebuild_section (desktop->submenu, 0, create_admin_section(self));
167 }
168
169 if (sections & SECTION_SETTINGS)
170@@ -1229,6 +1300,7 @@
171 priv_t * p;
172 gpointer gp;
173 GIcon * icon;
174+ GSettingsSchema * usage_mode_schema;
175
176 /* init our priv pointer */
177 p = G_TYPE_INSTANCE_GET_PRIVATE (self,
178@@ -1236,6 +1308,17 @@
179 IndicatorSessionServicePrivate);
180 p->indicator_settings = g_settings_new ("com.canonical.indicator.session");
181 p->keybinding_settings = g_settings_new ("org.gnome.settings-daemon.plugins.media-keys");
182+
183+ /* Only use unity8 schema if it's installed; this avoids a hard dependency
184+ on unity8-schemas */
185+ usage_mode_schema = g_settings_schema_source_lookup (g_settings_schema_source_get_default (),
186+ usage_mode_schema_name, TRUE);
187+ if (usage_mode_schema)
188+ {
189+ p->usage_mode_settings = g_settings_new (usage_mode_schema_name);
190+ g_settings_schema_unref (usage_mode_schema);
191+ }
192+
193 self->priv = p;
194
195 /* init the backend objects */
196@@ -1402,6 +1485,7 @@
197 g_clear_object (&p->backend_actions);
198 g_clear_object (&p->indicator_settings);
199 g_clear_object (&p->keybinding_settings);
200+ g_clear_object (&p->usage_mode_settings);
201 g_clear_object (&p->actions);
202
203 for (i=0; i<N_PROFILES; ++i)
204@@ -1410,6 +1494,7 @@
205 g_clear_object (&p->header_action);
206 g_clear_object (&p->user_switcher_action);
207 g_clear_object (&p->guest_switcher_action);
208+ g_clear_object (&p->usage_mode_action);
209 g_clear_object (&p->conn);
210
211 g_clear_pointer (&p->default_icon_serialized, g_variant_unref);

Subscribers

People subscribed via source and target branches