aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/service.c75
1 files changed, 73 insertions, 2 deletions
diff --git a/src/service.c b/src/service.c
index 1d3115f..30226c9 100644
--- a/src/service.c
+++ b/src/service.c
@@ -76,6 +76,8 @@ static const char * const menu_names[N_PROFILES] =
"desktop_lockscreen"
};
+static const char * const usage_mode_schema_name = "com.lomiri.Shell";
+
struct ProfileMenuInfo
{
/* the root level -- the header is the only child of this */
@@ -96,6 +98,7 @@ struct _IndicatorSessionServicePrivate
IndicatorSessionActions * backend_actions;
GSettings * indicator_settings;
GSettings * keybinding_settings;
+ GSettings * usage_mode_settings;
GSimpleActionGroup * actions;
guint actions_export_id;
struct ProfileMenuInfo menus[N_PROFILES];
@@ -149,6 +152,11 @@ rebuild_settings_section_soon (IndicatorSessionService * self)
{
rebuild_soon (self, SECTION_SETTINGS);
}
+static inline void
+rebuild_admin_section_soon (IndicatorSessionService * self)
+{
+ rebuild_soon (self, SECTION_ADMIN);
+}
/***
****
@@ -334,6 +342,33 @@ get_current_real_name (IndicatorSessionService * self)
return "";
}
+static gboolean
+usage_mode_to_action_state(GValue *value,
+ GVariant *variant,
+ gpointer unused)
+{
+ const gchar* usage_mode = g_variant_get_string(variant, NULL);
+ GVariant* ret_var = g_variant_new_boolean(g_strcmp0(usage_mode, "Windowed") == 0 ? TRUE : FALSE);
+ g_value_set_variant(value, ret_var);
+ return TRUE;
+}
+
+static GVariant*
+action_state_to_usage_mode(const GValue *value,
+ const GVariantType * unused_expected_type,
+ gpointer unused)
+{
+ GVariant* var = g_value_get_variant(value);
+ GVariant* ret = g_variant_new_string(g_variant_get_boolean(var) == TRUE ? "Windowed" : "Staged");
+ return ret;
+}
+
+static void
+on_usage_mode_setting_changed (gpointer gself)
+{
+ rebuild_admin_section_soon((IndicatorSessionService*)(gself));
+}
+
static GMenuModel *
create_admin_section (void)
{
@@ -346,6 +381,16 @@ create_admin_section (void)
g_menu_append (menu, distro_help_label, "indicator.distro_help");
g_free (desktop_help_label);
g_free (distro_help_label);
+
+ if (ayatana_common_utils_is_lomiri())
+ {
+ GMenuItem * menu_item = NULL;
+ menu_item = g_menu_item_new(_("Desktop mode"), "indicator.usage-mode");
+ g_menu_item_set_attribute(menu_item, "x-ayatana-type", "s", "org.ayatana.indicator.switch");
+ g_menu_append_item(menu, menu_item);
+ g_object_unref(menu_item);
+ }
+
g_menu_append (menu, _("Report a Bug…"), "indicator.bug");
return G_MENU_MODEL (menu);
}
@@ -954,13 +999,29 @@ init_gactions (IndicatorSessionService * self)
g_action_map_add_action (G_ACTION_MAP (p->actions), G_ACTION(a));
p->guest_switcher_action = a;
- /* add switch-to-user action... parameter is the uesrname */
+ /* add switch-to-user action... parameter is the username */
v = create_user_switcher_state (self);
a = g_simple_action_new_stateful ("switch-to-user", G_VARIANT_TYPE_STRING, v);
g_signal_connect (a, "activate", G_CALLBACK(on_user_activated), self);
g_action_map_add_action (G_ACTION_MAP (p->actions), G_ACTION(a));
p->user_switcher_action = a;
+ /* add usage-mode action */
+ a = g_simple_action_new_stateful("usage-mode",
+ NULL,
+ g_variant_new_boolean(FALSE));
+ g_settings_bind_with_mapping(p->usage_mode_settings, "usage-mode",
+ a, "state",
+ G_SETTINGS_BIND_DEFAULT,
+ usage_mode_to_action_state,
+ action_state_to_usage_mode,
+ NULL,
+ NULL);
+
+ g_action_map_add_action(G_ACTION_MAP(p->actions), G_ACTION(a));
+ g_signal_connect_swapped(p->usage_mode_settings, "changed::usage-mode",
+ G_CALLBACK(on_usage_mode_setting_changed), self);
+
/* add the header action */
a = g_simple_action_new_stateful ("_header", NULL,
action_state_for_header (self));
@@ -1183,9 +1244,18 @@ indicator_session_service_init (IndicatorSessionService * self)
{
p->keybinding_settings = g_settings_new ("org.gnome.settings-daemon.plugins.media-keys");
}
- else if (ayatana_common_utils_is_gnome() || ayatana_common_utils_is_unity())
+ else if (ayatana_common_utils_is_gnome())
+ {
+ p->keybinding_settings = g_settings_new ("org.gnome.settings-daemon.plugins.media-keys");
+ }
+ else if (ayatana_common_utils_is_unity())
+ {
+ p->keybinding_settings = g_settings_new ("org.gnome.settings-daemon.plugins.media-keys");
+ }
+ else if (ayatana_common_utils_is_lomiri())
{
p->keybinding_settings = g_settings_new ("org.gnome.settings-daemon.plugins.media-keys");
+ p->usage_mode_settings = g_settings_new(usage_mode_schema_name);
}
self->priv = p;
@@ -1356,6 +1426,7 @@ my_dispose (GObject * o)
g_clear_object (&p->backend_actions);
g_clear_object (&p->indicator_settings);
g_clear_object (&p->keybinding_settings);
+ g_clear_object (&p->usage_mode_settings);
g_clear_object (&p->actions);
for (i=0; i<N_PROFILES; ++i)