aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/actions.c26
-rw-r--r--src/actions.h4
-rw-r--r--src/service.c11
-rw-r--r--tests/backend-mock-actions.c7
-rw-r--r--tests/com.canonical.indicator.session.backendmock.gschema.xml4
5 files changed, 43 insertions, 9 deletions
diff --git a/src/actions.c b/src/actions.c
index babc285..ca086b7 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -34,6 +34,7 @@ enum
PROP_CAN_SUSPEND,
PROP_CAN_LOCK,
PROP_CAN_LOGOUT,
+ PROP_CAN_REBOOT,
PROP_CAN_PROMPT,
PROP_HAS_ONLINE_ACCOUNT_ERROR,
PROP_LAST
@@ -71,6 +72,10 @@ my_get_property (GObject * o,
g_value_set_boolean (value, indicator_session_actions_can_logout (self));
break;
+ case PROP_CAN_REBOOT:
+ g_value_set_boolean (value, indicator_session_actions_can_reboot (self));
+ break;
+
case PROP_CAN_PROMPT:
g_value_set_boolean (value, indicator_session_actions_can_prompt (self));
break;
@@ -96,6 +101,7 @@ indicator_session_actions_class_init (IndicatorSessionActionsClass * klass)
klass->can_lock = NULL;
klass->can_logout = NULL;
+ klass->can_reboot = NULL;
klass->can_switch = NULL;
klass->can_suspend = NULL;
klass->can_hibernate = NULL;
@@ -144,6 +150,12 @@ indicator_session_actions_class_init (IndicatorSessionActionsClass * klass)
"Whether or not the system services allow the user to logout",
TRUE, flags);
+ properties[PROP_CAN_REBOOT] =
+ g_param_spec_boolean (INDICATOR_SESSION_ACTIONS_PROP_CAN_REBOOT,
+ "Can Reboot",
+ "Whether or not the system services allow the user to reboot",
+ TRUE, flags);
+
properties[PROP_CAN_PROMPT] =
g_param_spec_boolean (INDICATOR_SESSION_ACTIONS_PROP_CAN_PROMPT,
"Can Show End Session Dialog",
@@ -186,6 +198,14 @@ indicator_session_actions_can_logout (IndicatorSessionActions * self)
}
gboolean
+indicator_session_actions_can_reboot (IndicatorSessionActions * self)
+{
+ g_return_val_if_fail (INDICATOR_IS_SESSION_ACTIONS (self), FALSE);
+
+ return INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->can_reboot (self);
+}
+
+gboolean
indicator_session_actions_can_switch (IndicatorSessionActions * self)
{
g_return_val_if_fail (INDICATOR_IS_SESSION_ACTIONS (self), FALSE);
@@ -353,6 +373,12 @@ indicator_session_actions_notify_can_logout (IndicatorSessionActions * self)
}
void
+indicator_session_actions_notify_can_reboot (IndicatorSessionActions * self)
+{
+ notify_func (self, PROP_CAN_REBOOT);
+}
+
+void
indicator_session_actions_notify_can_switch (IndicatorSessionActions * self)
{
notify_func (self, PROP_CAN_SWITCH);
diff --git a/src/actions.h b/src/actions.h
index bba6045..0f8aa1d 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -38,6 +38,7 @@ typedef struct _IndicatorSessionActionsClass IndicatorSessionActionsClass;
/* property keys */
#define INDICATOR_SESSION_ACTIONS_PROP_CAN_LOCK "can-lock"
#define INDICATOR_SESSION_ACTIONS_PROP_CAN_LOGOUT "can-logout"
+#define INDICATOR_SESSION_ACTIONS_PROP_CAN_REBOOT "can-reboot"
#define INDICATOR_SESSION_ACTIONS_PROP_CAN_SWITCH "can-switch"
#define INDICATOR_SESSION_ACTIONS_PROP_CAN_SUSPEND "can-suspend"
#define INDICATOR_SESSION_ACTIONS_PROP_CAN_HIBERNATE "can-hibernate"
@@ -62,6 +63,7 @@ struct _IndicatorSessionActionsClass
gboolean (*can_lock) (IndicatorSessionActions * self);
gboolean (*can_logout) (IndicatorSessionActions * self);
+ gboolean (*can_reboot) (IndicatorSessionActions * self);
gboolean (*can_switch) (IndicatorSessionActions * self);
gboolean (*can_suspend) (IndicatorSessionActions * self);
gboolean (*can_hibernate) (IndicatorSessionActions * self);
@@ -92,6 +94,7 @@ GType indicator_session_actions_get_type (void);
gboolean indicator_session_actions_can_lock (IndicatorSessionActions * self);
gboolean indicator_session_actions_can_logout (IndicatorSessionActions * self);
+gboolean indicator_session_actions_can_reboot (IndicatorSessionActions * self);
gboolean indicator_session_actions_can_switch (IndicatorSessionActions * self);
gboolean indicator_session_actions_can_suspend (IndicatorSessionActions * self);
gboolean indicator_session_actions_can_hibernate (IndicatorSessionActions * self);
@@ -101,6 +104,7 @@ gboolean indicator_session_actions_has_online_account_error (IndicatorSession
void indicator_session_actions_notify_can_lock (IndicatorSessionActions * self);
void indicator_session_actions_notify_can_logout (IndicatorSessionActions * self);
+void indicator_session_actions_notify_can_reboot (IndicatorSessionActions * self);
void indicator_session_actions_notify_can_switch (IndicatorSessionActions * self);
void indicator_session_actions_notify_can_suspend (IndicatorSessionActions * self);
void indicator_session_actions_notify_can_hibernate (IndicatorSessionActions * self);
diff --git a/src/service.c b/src/service.c
index 166f729..3de37e3 100644
--- a/src/service.c
+++ b/src/service.c
@@ -529,8 +529,7 @@ create_session_section (IndicatorSessionService * self, int profile)
menu = g_menu_new ();
if ((profile == PROFILE_DESKTOP) &&
- (indicator_session_actions_can_logout (p->backend_actions)) &&
- (!g_settings_get_boolean (s, "suppress-logout-menuitem")))
+ (indicator_session_actions_can_logout (p->backend_actions)))
{
const char * label = ellipsis ? _("Log Out…") : _("Log Out");
g_menu_append (menu, label, "indicator.logout");
@@ -542,9 +541,7 @@ create_session_section (IndicatorSessionService * self, int profile)
if (indicator_session_actions_can_hibernate (p->backend_actions))
g_menu_append (menu, _("Hibernate"), "indicator.hibernate");
- /* NB: check 'ellipsis' here to skip this item if prompting is enabled
- because this shows the same prompt as 'Shut Down' in Unity */
- if (!ellipsis && !g_settings_get_boolean (s, "suppress-restart-menuitem"))
+ if (indicator_session_actions_can_reboot (p->backend_actions))
{
const char * label = ellipsis ? _("Restart…") : _("Restart");
g_menu_append (menu, label, "indicator.reboot");
@@ -1021,10 +1018,6 @@ indicator_session_service_init (IndicatorSessionService * self)
G_CALLBACK(rebuild_switch_section_soon), self);
g_signal_connect_swapped (gp, "changed::suppress-logout-restart-shutdown",
G_CALLBACK(rebuild_session_section_soon), self);
- g_signal_connect_swapped (gp, "changed::suppress-logout-menuitem",
- G_CALLBACK(rebuild_session_section_soon), self);
- g_signal_connect_swapped (gp, "changed::suppress-restart-menuitem",
- G_CALLBACK(rebuild_session_section_soon), self);
g_signal_connect_swapped (gp, "changed::suppress-shutdown-menuitem",
G_CALLBACK(rebuild_session_section_soon), self);
g_signal_connect_swapped (gp, "changed::show-real-name-on-panel",
diff --git a/tests/backend-mock-actions.c b/tests/backend-mock-actions.c
index d5a506b..af4afd9 100644
--- a/tests/backend-mock-actions.c
+++ b/tests/backend-mock-actions.c
@@ -44,6 +44,12 @@ my_can_logout (IndicatorSessionActions * self G_GNUC_UNUSED)
}
static gboolean
+my_can_reboot (IndicatorSessionActions * self G_GNUC_UNUSED)
+{
+ return g_settings_get_boolean (mock_settings, "can-reboot");
+}
+
+static gboolean
my_can_switch (IndicatorSessionActions * self G_GNUC_UNUSED)
{
return g_settings_get_boolean (mock_settings, "can-switch-sessions");
@@ -177,6 +183,7 @@ indicator_session_actions_mock_class_init (IndicatorSessionActionsMockClass * kl
actions_class = INDICATOR_SESSION_ACTIONS_CLASS (klass);
actions_class->can_lock = my_can_lock;
actions_class->can_logout = my_can_logout;
+ actions_class->can_reboot = my_can_reboot;
actions_class->can_switch = my_can_switch;
actions_class->can_suspend = my_can_suspend;
actions_class->can_hibernate = my_can_hibernate;
diff --git a/tests/com.canonical.indicator.session.backendmock.gschema.xml b/tests/com.canonical.indicator.session.backendmock.gschema.xml
index 34479df..79d0c02 100644
--- a/tests/com.canonical.indicator.session.backendmock.gschema.xml
+++ b/tests/com.canonical.indicator.session.backendmock.gschema.xml
@@ -21,6 +21,10 @@
<default>true</default>
<summary>Is logging out allowed?</summary>
</key>
+ <key type="b" name="can-reboot">
+ <default>true</default>
+ <summary>Is rebooting allowed?</summary>
+ </key>
<key type="b" name="can-lock">
<default>true</default>
<summary>Is locking the session allowed?</summary>