After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 764508 - power: respect the value of CanSuspend() to show Suspend/Power Off section
power: respect the value of CanSuspend() to show Suspend/Power Off section
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Power
unspecified
Other All
: Normal normal
: ---
Assigned To: Richard Hughes
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-04-02 18:13 UTC by Cosimo Cecchi
Modified: 2016-04-06 03:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
power: remove unneeded call (912 bytes, patch)
2016-04-02 18:14 UTC, Cosimo Cecchi
committed Details | Review
power: move function call into section method (1.38 KB, patch)
2016-04-02 18:14 UTC, Cosimo Cecchi
committed Details | Review
power: show "Suspend & Power Off" section only when system can suspend (2.94 KB, patch)
2016-04-02 18:14 UTC, Cosimo Cecchi
none Details | Review
power: show "Suspend & Power Off" section only when system can suspend (3.24 KB, patch)
2016-04-02 18:16 UTC, Cosimo Cecchi
none Details | Review
power: show "Suspend & Power Off" section only when relevant (12.20 KB, patch)
2016-04-05 17:35 UTC, Cosimo Cecchi
committed Details | Review

Description Cosimo Cecchi 2016-04-02 18:13:57 UTC
See patches.
Comment 1 Cosimo Cecchi 2016-04-02 18:14:01 UTC
Created attachment 325231 [details] [review]
power: remove unneeded call

This function is already called from add_suspend_and_power_off_section()
a few lines above.
Comment 2 Cosimo Cecchi 2016-04-02 18:14:05 UTC
Created attachment 325232 [details] [review]
power: move function call into section method

This function logically belongs into the section constructor. Move it
there.
Comment 3 Cosimo Cecchi 2016-04-02 18:14:11 UTC
Created attachment 325233 [details] [review]
power: show "Suspend & Power Off" section only when system can suspend

Ask logind's D-Bus service 'org.freedesktop.login1.Manager.CanSuspend'
to determine whether it should be visible or not, similar to what GDM
and the Shell already do.
Comment 4 Cosimo Cecchi 2016-04-02 18:16:02 UTC
Created attachment 325234 [details] [review]
power: show "Suspend & Power Off" section only when system can suspend

Ask logind's D-Bus service 'org.freedesktop.login1.Manager.CanSuspend'
to determine whether it should be visible or not, similar to what GDM
and the Shell already do.
Comment 5 Bastien Nocera 2016-04-04 16:01:04 UTC
Review of attachment 325231 [details] [review]:

OK.
Comment 6 Bastien Nocera 2016-04-04 16:01:27 UTC
Review of attachment 325232 [details] [review]:

Sure.
Comment 7 Bastien Nocera 2016-04-04 16:05:46 UTC
Review of attachment 325234 [details] [review]:

::: panels/power/cc-power-panel.c
@@ +2477,3 @@
   add_power_saving_section (self);
+
+  if (can_suspend (self))

If you can't suspend but can hibernate, then this will hide the "power button" row, which is probably not what we'd want to do.
Comment 8 Cosimo Cecchi 2016-04-05 17:35:48 UTC
Created attachment 325449 [details] [review]
power: show "Suspend & Power Off" section only when relevant

We now ask logind whether the system can suspend or hibernate, and
change the visibility of the items in the panel based on that.

Based on a patch by Mario Sanchez Prada <mario@endlessm.com>.
Comment 9 Bastien Nocera 2016-04-05 20:28:52 UTC
Review of attachment 325449 [details] [review]:

Looks fine to me.
Comment 10 Cosimo Cecchi 2016-04-06 03:34:03 UTC
Attachment 325231 [details] pushed as eb94d06 - power: remove unneeded call
Attachment 325232 [details] pushed as 0e54ee8 - power: move function call into section method
Attachment 325449 [details] pushed as b1e2bc6 - power: show "Suspend & Power Off" section only when relevant