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 710273 - power: Use UPower directly instead of gnome-settings-daemon
power: Use UPower directly instead of gnome-settings-daemon
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: system-status
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks: 709736
 
 
Reported: 2013-10-16 14:01 UTC by Bastien Nocera
Modified: 2013-10-17 15:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
power: Use UPower directly instead of gnome-settings-daemon (6.82 KB, patch)
2013-10-16 14:02 UTC, Bastien Nocera
needs-work Details | Review
power: Use UPower directly instead of gnome-settings-daemon (7.01 KB, patch)
2013-10-16 20:09 UTC, Bastien Nocera
needs-work Details | Review
power: Use UPower directly instead of gnome-settings-daemon (6.13 KB, patch)
2013-10-17 14:47 UTC, Bastien Nocera
reviewed Details | Review
power: Use UPower directly instead of gnome-settings-daemon (5.86 KB, patch)
2013-10-17 15:31 UTC, Bastien Nocera
committed Details | Review

Description Bastien Nocera 2013-10-16 14:01:47 UTC
.
Comment 1 Bastien Nocera 2013-10-16 14:02:02 UTC
Created attachment 257424 [details] [review]
power: Use UPower directly instead of gnome-settings-daemon

UPower master exports a display device that can be used to
compute whether to show a status icon, and what we should show.
Comment 2 Florian Müllner 2013-10-16 15:23:15 UTC
Review of attachment 257424 [details] [review]:

Needs rebasing after https://git.gnome.org/browse/gnome-shell/commit/?id=575b373cd5bc
Comment 3 Bastien Nocera 2013-10-16 20:09:49 UTC
Created attachment 257447 [details] [review]
power: Use UPower directly instead of gnome-settings-daemon

UPower master exports a display device that can be used to
compute whether to show a status icon, and what we should show.
Comment 4 Jasper St. Pierre (not reading bugmail) 2013-10-16 20:13:20 UTC
Review of attachment 257447 [details] [review]:

::: js/ui/status/power.js
@@ -57,3 @@
     },
 
-    _statusForDevice: function(device) {

I really like the statusForDevice that simply returns our status string instead of a bunch of wacky flow control. Please keep it, even if you have to rename it _getStatus() or something.

@@ +59,3 @@
+    _syncStatusLabel: function() {
+        if (this._proxy.Type == UPower.DeviceKind.UPS)
+            this._item.label.text = _("UPS");

Are you sure the designers want to show UPS?

@@ +116,3 @@
     },
+
+    _sync: function() {

I'd prefer if this kept the post-rewrite form, with the _sync simply doing everything.
Comment 5 Bastien Nocera 2013-10-16 20:20:21 UTC
(In reply to comment #4)
> @@ +59,3 @@
> +    _syncStatusLabel: function() {
> +        if (this._proxy.Type == UPower.DeviceKind.UPS)
> +            this._item.label.text = _("UPS");
> 
> Are you sure the designers want to show UPS?

We need to show discharging UPSes, this is what this does.
Comment 6 Bastien Nocera 2013-10-17 14:47:44 UTC
Created attachment 257542 [details] [review]
power: Use UPower directly instead of gnome-settings-daemon

UPower master exports a display device that can be used to
compute whether to show a status icon, and what we should show.
Comment 7 Jasper St. Pierre (not reading bugmail) 2013-10-17 15:16:54 UTC
Review of attachment 257542 [details] [review]:

::: js/ui/status/power.js
@@ +94,3 @@
 
+    _syncVisibility: function() {
+        let visible = this._proxy.IsPresent;

What does IsPresent mean if the primary device is e.g. a keyboard battery or something else like that?

What we want:

  * If there's no battery (or UPS) device:
    * Hide the menu item.
    * The indicator should be the power icon (system-shutdown-symbolic). It might make sense to add this as a separate indicator using _addIndicator.

  * If there's a battery (or UPS) device:
    * Show the menu item.
    * The indicator should be the battery icon.

@@ +115,3 @@
+     },
+
+    _syncLabels: function() {

Could you merge these three methods?
Comment 8 Bastien Nocera 2013-10-17 15:26:48 UTC
(In reply to comment #7)
> Review of attachment 257542 [details] [review]:
> 
> ::: js/ui/status/power.js
> @@ +94,3 @@
> 
> +    _syncVisibility: function() {
> +        let visible = this._proxy.IsPresent;
> 
> What does IsPresent mean if the primary device is e.g. a keyboard battery or
> something else like that?

It's never a keyboard battery. It's a composite device that aggregates all the batteries or UPSes on the system. On a system with neither, the properties are undefined, and IsPresent is false.

> What we want:
> 
>   * If there's no battery (or UPS) device:
>     * Hide the menu item.
>     * The indicator should be the power icon (system-shutdown-symbolic). It
> might make sense to add this as a separate indicator using _addIndicator.

I missed that last bit. I'll respin the code.

>   * If there's a battery (or UPS) device:
>     * Show the menu item.
>     * The indicator should be the battery icon.

That works as expected.

> @@ +115,3 @@
> +     },
> +
> +    _syncLabels: function() {
> 
> Could you merge these three methods?

Sure.
Comment 9 Bastien Nocera 2013-10-17 15:31:17 UTC
Created attachment 257550 [details] [review]
power: Use UPower directly instead of gnome-settings-daemon

UPower master exports a display device that can be used to
compute whether to show a status icon, and what we should show.
Comment 10 Jasper St. Pierre (not reading bugmail) 2013-10-17 15:33:44 UTC
Review of attachment 257550 [details] [review]:

Looks good.

::: js/ui/status/power.js
@@ +120,2 @@
     },
+

Stray whitespace.
Comment 11 Bastien Nocera 2013-10-17 15:40:29 UTC
Pushed minus the stray linefeed.

Attachment 257550 [details] pushed as 0b8c0c2 - power: Use UPower directly instead of gnome-settings-daemon