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 757880 - Offer configuration of the power button
Offer configuration of the power button
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Power
git master
Other Linux
: Normal normal
: ---
Assigned To: Richard Hughes
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-11-10 13:03 UTC by Bastien Nocera
Modified: 2015-11-13 15:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
power: Add configuration for Power Button (9.29 KB, patch)
2015-11-12 14:49 UTC, Bastien Nocera
none Details | Review
power: Don't throw errors when D-Bus calls are cancelled (2.36 KB, patch)
2015-11-12 14:49 UTC, Bastien Nocera
committed Details | Review
power: Add configuration for Power Button (9.69 KB, patch)
2015-11-13 15:22 UTC, Bastien Nocera
committed Details | Review

Description Bastien Nocera 2015-11-10 13:03:13 UTC
Not for VMs or tablets, but for laptops and desktops.
Comment 1 Bastien Nocera 2015-11-10 13:03:28 UTC
See also https://bugzilla.gnome.org/show_bug.cgi?id=755953
Comment 2 Bastien Nocera 2015-11-12 14:49:13 UTC
Created attachment 315341 [details] [review]
power: Add configuration for Power Button

When running on something other than a VM or a tablet, which have
hard-coded actions when the power button is pressed, offer to configure
the power button to either suspend (default), hibernate, or do nothing.
Comment 3 Bastien Nocera 2015-11-12 14:49:20 UTC
Created attachment 315342 [details] [review]
power: Don't throw errors when D-Bus calls are cancelled
Comment 4 Rui Matos 2015-11-12 17:07:59 UTC
Review of attachment 315342 [details] [review]:

sure
Comment 5 Rui Matos 2015-11-12 17:30:32 UTC
Review of attachment 315341 [details] [review]:

::: panels/power/cc-power-panel.c
@@ +200,3 @@
+                               cancellable,
+                               &error);
+  if (connection == NULL) {

This file uses standard glib/gtk+ style so:

if (condition)
  {
    statement;
  }

@@ +222,3 @@
+  if (variant == NULL) {
+    if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+      g_debug ("Failed to get property '%s': %s", "Chassis", error->message);

g_warning as above?

::: panels/power/power.ui
@@ +113,3 @@
+        <col id="0" translatable="yes">Nothing</col>
+        <col id="1">0</col>
+      </row>

I'd prefer that this was created in code with the real enum values for the second column and the strings from an array indexed by the enums so that if more values are added later we don't have a potentially difficult to track bug
Comment 6 Bastien Nocera 2015-11-13 15:12:40 UTC
(In reply to Rui Matos from comment #5)
> Review of attachment 315341 [details] [review] [review]:
> 
> ::: panels/power/cc-power-panel.c
> @@ +200,3 @@
> +                               cancellable,
> +                               &error);
> +  if (connection == NULL) {
> 
> This file uses standard glib/gtk+ style so:
> 
> if (condition)
>   {
>     statement;
>   }
> 
> @@ +222,3 @@
> +  if (variant == NULL) {
> +    if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
> +      g_debug ("Failed to get property '%s': %s", "Chassis",
> error->message);
> 
> g_warning as above?

No system bus -> system is utterly busted.
No logind -> non-Linux or non-systemd system

> ::: panels/power/power.ui
> @@ +113,3 @@
> +        <col id="0" translatable="yes">Nothing</col>
> +        <col id="1">0</col>
> +      </row>
> 
> I'd prefer that this was created in code with the real enum values for the
> second column and the strings from an array indexed by the enums so that if
> more values are added later we don't have a potentially difficult to track
> bug

Right...
Comment 7 Bastien Nocera 2015-11-13 15:22:21 UTC
Created attachment 315412 [details] [review]
power: Add configuration for Power Button

When running on something other than a VM or a tablet, which have
hard-coded actions when the power button is pressed, offer to configure
the power button to either suspend (default), hibernate, or do nothing.
Comment 8 Bastien Nocera 2015-11-13 15:23:06 UTC
Attachment 315342 [details] pushed as dc49fb6 - power: Don't throw errors when D-Bus calls are cancelled
Attachment 315412 [details] pushed as 3a34080 - power: Add configuration for Power Button