diff options
-rw-r--r-- | data/org.ayatana.indicator.session.gschema.xml.in | 5 | ||||
-rw-r--r-- | src/backend-dbus/actions.c | 10 | ||||
-rw-r--r-- | src/service.c | 108 |
3 files changed, 116 insertions, 7 deletions
diff --git a/data/org.ayatana.indicator.session.gschema.xml.in b/data/org.ayatana.indicator.session.gschema.xml.in index 9e099fb..c46a738 100644 --- a/data/org.ayatana.indicator.session.gschema.xml.in +++ b/data/org.ayatana.indicator.session.gschema.xml.in @@ -20,6 +20,11 @@ <_summary>Remove the shutdown item from the session menu.</_summary> <_description>Makes it so that the shutdown button doesn’t show in the session menu.</_description> </key> + <key name="force-restart-menuitem" type="b"> + <default>false</default> + <_summary>Force the visibility of Restart item in the session menu</_summary> + <_description>Makes it so that the restart shows in the session menu even in the environments where it should not show.</_description> + </key> <key type="b" name="show-real-name-on-panel"> <default>false</default> <summary>Determine the visibility of the User's real name on the panel</summary> diff --git a/src/backend-dbus/actions.c b/src/backend-dbus/actions.c index c18ae72..c83d352 100644 --- a/src/backend-dbus/actions.c +++ b/src/backend-dbus/actions.c @@ -369,6 +369,9 @@ on_end_session_dialog_proxy_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res { INDICATOR_SESSION_ACTIONS_DBUS(gself)->priv->end_session_dialog = end_session_dialog; + g_signal_connect_swapped (end_session_dialog, "notify::g-name-owner", + G_CALLBACK(indicator_session_actions_notify_can_switch), gself); + indicator_session_actions_notify_can_prompt (INDICATOR_SESSION_ACTIONS(gself)); indicator_session_actions_notify_can_reboot (INDICATOR_SESSION_ACTIONS(gself)); } @@ -411,6 +414,9 @@ my_can_reboot (IndicatorSessionActions * actions) if (g_settings_get_boolean (p->indicator_settings, "suppress-restart-menuitem")) return FALSE; + if (g_settings_get_boolean (p->indicator_settings, "force-restart-menuitem")) + return TRUE; + /* Shutdown and Restart are the same dialog prompt in Unity, so disable the redundant 'Restart' menuitem in that mode */ if (!g_settings_get_boolean (p->indicator_settings, "suppress-shutdown-menuitem")) @@ -882,6 +888,8 @@ my_desktop_help (IndicatorSessionActions * self G_GNUC_UNUSED) { if (ayatana_common_utils_have_budgie_program ("yelp")) ayatana_common_utils_execute_command ("yelp help:gnome-user-guide"); + else if (ayatana_common_utils_is_lomiri()) + ayatana_common_utils_open_url("https://forums.ubports.com"); else if (ayatana_common_utils_have_gnome_program ("yelp")) ayatana_common_utils_execute_command ("yelp help:gnome-user-guide"); else if (ayatana_common_utils_have_mate_program ("yelp")) @@ -1179,6 +1187,8 @@ indicator_session_actions_dbus_init (IndicatorSessionActionsDbus * self) G_CALLBACK(indicator_session_actions_notify_can_reboot), self); g_signal_connect_swapped (s, "changed::suppress-shutdown-menuitem", G_CALLBACK(indicator_session_actions_notify_can_reboot), self); + g_signal_connect_swapped (s, "changed::force-restart-menuitem", + G_CALLBACK(indicator_session_actions_notify_can_reboot), self); p->indicator_settings = s; gnome_screen_saver_proxy_new_for_bus (G_BUS_TYPE_SESSION, diff --git a/src/service.c b/src/service.c index 1d3115f..dbe9698 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,12 +98,14 @@ 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]; GSimpleAction * header_action; GSimpleAction * user_switcher_action; GSimpleAction * guest_switcher_action; + GSimpleAction * usage_mode_action; GHashTable * users; GHashTable * reported_users; guint rebuild_id; @@ -149,6 +153,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,18 +343,62 @@ 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) +create_admin_section (IndicatorSessionService * self) { GMenu * menu; + priv_t * p = self->priv; gchar * desktop_help_label = g_strdup_printf(_("%s Desktop Help"), get_desktop_name()); - gchar * distro_help_label = g_strdup_printf(_("%s Help"), get_distro_name()); + gchar * distro_help_label = g_strdup_printf(_("%s Help…"), get_distro_name()); menu = g_menu_new (); - g_menu_append (menu, _("About This Computer"), "indicator.about"); + + if (ayatana_common_utils_is_lomiri()) { + g_menu_append (menu, _("About This Device…"), "indicator.about"); + } else { + g_menu_append (menu, _("About This Computer"), "indicator.about"); + } + g_menu_append (menu, desktop_help_label, "indicator.desktop_help"); g_menu_append (menu, distro_help_label, "indicator.distro_help"); g_free (desktop_help_label); g_free (distro_help_label); + + if (p->usage_mode_action && 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); } @@ -747,7 +800,7 @@ create_menu (IndicatorSessionService * self, int profile) if (profile == PROFILE_DESKTOP) { - sections[n++] = create_admin_section (); + sections[n++] = create_admin_section (self); sections[n++] = create_settings_section (self); sections[n++] = create_switch_section (self, profile); sections[n++] = create_logout_section (self); @@ -954,13 +1007,33 @@ 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 */ + if (p->usage_mode_settings) + { + 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); + p->usage_mode_action = a; + } + /* add the header action */ a = g_simple_action_new_stateful ("_header", NULL, action_state_for_header (self)); @@ -1002,7 +1075,7 @@ rebuild_now (IndicatorSessionService * self, int sections) if (sections & SECTION_ADMIN) { - rebuild_section (desktop->submenu, 0, create_admin_section()); + rebuild_section (desktop->submenu, 0, create_admin_section(self)); } if (sections & SECTION_SETTINGS) @@ -1171,6 +1244,7 @@ indicator_session_service_init (IndicatorSessionService * self) priv_t * p; gpointer gp; GIcon * icon; + GSettingsSchema * usage_mode_schema; /* init our priv pointer */ p = indicator_session_service_get_instance_private (self); @@ -1183,10 +1257,28 @@ 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"); + + /* Only use unity8 schema if it's installed; this avoids a hard dependency + on unity8-schemas */ + usage_mode_schema = g_settings_schema_source_lookup (g_settings_schema_source_get_default (), + usage_mode_schema_name, TRUE); + if (usage_mode_schema) + { + p->usage_mode_settings = g_settings_new (usage_mode_schema_name); + g_settings_schema_unref (usage_mode_schema); + } + } self->priv = p; @@ -1356,6 +1448,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) @@ -1364,6 +1457,7 @@ my_dispose (GObject * o) g_clear_object (&p->header_action); g_clear_object (&p->user_switcher_action); g_clear_object (&p->guest_switcher_action); + g_clear_object (&p->usage_mode_action); g_clear_object (&p->conn); g_clear_pointer (&p->default_icon_serialized, g_variant_unref); |