From ed386e9d7a51375f09063302a3b1e73103ea86c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Tue, 8 Mar 2016 15:15:13 +0100 Subject: add "Desktop mode" switch for Lomiri --- src/service.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file 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 Date: Tue, 8 Mar 2016 15:26:24 +0100 Subject: plug a memleak --- src/service.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/service.c b/src/service.c index 30226c9..3fca33b 100644 --- a/src/service.c +++ b/src/service.c @@ -105,6 +105,7 @@ struct _IndicatorSessionServicePrivate GSimpleAction * header_action; GSimpleAction * user_switcher_action; GSimpleAction * guest_switcher_action; + GSimpleAction * usage_mode_action; GHashTable * users; GHashTable * reported_users; guint rebuild_id; @@ -1021,6 +1022,7 @@ init_gactions (IndicatorSessionService * self) 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, @@ -1435,6 +1437,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); -- cgit v1.2.3 From 9b7b8400b7824f19ef1c877f059473a373670e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Tue, 8 Mar 2016 23:12:26 +0100 Subject: use ellipsis and convergence friendly "about" caption --- src/service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/service.c b/src/service.c index 3fca33b..f6f6251 100644 --- a/src/service.c +++ b/src/service.c @@ -375,9 +375,9 @@ create_admin_section (void) { GMenu * menu; 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"); + g_menu_append (menu, _("About This Device…"), "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); -- cgit v1.2.3 From a7f9ed4a8c4dadaf3b19283a70fb37e7bd9d3efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Wed, 9 Mar 2016 15:47:25 +0100 Subject: open https://forums.ubports.com under Lomiri --- src/backend-dbus/actions.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend-dbus/actions.c b/src/backend-dbus/actions.c index c18ae72..b4ea42d 100644 --- a/src/backend-dbus/actions.c +++ b/src/backend-dbus/actions.c @@ -882,6 +882,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")) -- cgit v1.2.3 From 31d06b6a5456e6a60e0e6bc21cafbff36f1f4c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Tue, 15 Mar 2016 14:39:58 +0100 Subject: change the About string only for u8 would be confusing for u7/desktop and need a string freeze exception at this point --- src/service.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/service.c b/src/service.c index f6f6251..206079a 100644 --- a/src/service.c +++ b/src/service.c @@ -377,7 +377,13 @@ create_admin_section (void) 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()); menu = g_menu_new (); - g_menu_append (menu, _("About This Device…"), "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); -- cgit v1.2.3 From df4c24eb24ae2b58b772b51e08b7d7f338f25140 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Tue, 15 Mar 2016 15:33:29 +0100 Subject: Only use Lomiri schema if it's installed to avoid hard dependency --- src/service.c | 52 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/src/service.c b/src/service.c index 206079a..dbe9698 100644 --- a/src/service.c +++ b/src/service.c @@ -371,9 +371,10 @@ on_usage_mode_setting_changed (gpointer 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()); menu = g_menu_new (); @@ -389,7 +390,7 @@ create_admin_section (void) g_free (desktop_help_label); g_free (distro_help_label); - if (ayatana_common_utils_is_lomiri()) + 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"); @@ -799,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); @@ -1014,21 +1015,24 @@ init_gactions (IndicatorSessionService * self) p->user_switcher_action = a; /* add usage-mode action */ - a = g_simple_action_new_stateful("usage-mode", + 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, - 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; + 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, @@ -1071,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) @@ -1240,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); @@ -1263,7 +1268,16 @@ indicator_session_service_init (IndicatorSessionService * self) 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); + + /* 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; -- cgit v1.2.3 From dd4e19f35bfe81395d20f3a8f52805ab138a5c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 8 Apr 2016 22:34:13 +0200 Subject: Ensure we request the UI to verify restart availability when unity proxy connects/disconnects --- src/backend-dbus/actions.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/backend-dbus/actions.c b/src/backend-dbus/actions.c index b4ea42d..88caf80 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)); } -- cgit v1.2.3 From 44fb1ec00d9c1ed129574fa3efd631a663b096a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 8 Apr 2016 22:49:07 +0200 Subject: Actions: add force-restart-menuitem option to make it visible in any environments Basically it allows to see the "Reboot..." option when indicator-session is in unity --- data/org.ayatana.indicator.session.gschema.xml.in | 5 +++++ src/backend-dbus/actions.c | 5 +++++ 2 files changed, 10 insertions(+) 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. <_description>Makes it so that the shutdown button doesn’t show in the session menu. + + false + <_summary>Force the visibility of Restart item in the session menu + <_description>Makes it so that the restart shows in the session menu even in the environments where it should not show. + false Determine the visibility of the User's real name on the panel diff --git a/src/backend-dbus/actions.c b/src/backend-dbus/actions.c index 88caf80..c83d352 100644 --- a/src/backend-dbus/actions.c +++ b/src/backend-dbus/actions.c @@ -414,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")) @@ -1184,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, -- cgit v1.2.3