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 735771 - Add "show battery percentage" option
Add "show battery percentage" option
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: system-status
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on: 758063
Blocks:
 
 
Reported: 2014-08-31 21:51 UTC by Bastien Nocera
Modified: 2015-11-19 13:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
power: Add battery percentage label (2.15 KB, patch)
2015-11-09 13:05 UTC, Bastien Nocera
none Details | Review
power: Add battery percentage label (3.09 KB, patch)
2015-11-13 15:26 UTC, Bastien Nocera
none Details | Review
power: Add battery percentage label (3.01 KB, patch)
2015-11-17 09:57 UTC, Bastien Nocera
none Details | Review
Tweak power indicator spacing (794 bytes, patch)
2015-11-17 18:03 UTC, Florian Müllner
committed Details | Review
power: Add battery percentage label (3.43 KB, patch)
2015-11-18 12:17 UTC, Bastien Nocera
committed Details | Review

Description Bastien Nocera 2014-08-31 21:51:47 UTC
This is an oft-requested feature (looks like there's 4 extensions to show it), and something that other platforms also allow to change.
Comment 1 Bastien Nocera 2015-11-09 13:05:45 UTC
Created attachment 315119 [details] [review]
power: Add battery percentage label

FIXME: where should the GSetting live?
FIXME: couldn't figure out how to center it vertically
Comment 2 Bastien Nocera 2015-11-09 13:06:16 UTC
WIP: http://i.imgur.com/WMnYIlf.png
Comment 3 Bastien Nocera 2015-11-09 14:16:42 UTC
Allan's notes: smaller text, less padding between the icon and its label.
Comment 4 Florian Müllner 2015-11-12 16:00:54 UTC
Review of attachment 315119 [details] [review]:

::: js/ui/status/power.js
@@ +36,2 @@
         this._indicator = this._addIndicator();
+        this._percentageLabel = new St.Label({ text: '100%' });

new St.Label({ y_expand: true,
               y_align: Clutter.ActorAlign.CENTER });
Comment 5 Bastien Nocera 2015-11-13 10:22:10 UTC
Where would I put the GSettings? In gsettings-desktop-schemas (even if unused by mutter?) or in gnome-shell?
Comment 6 Florian Müllner 2015-11-13 11:33:23 UTC
I don't have a strong preference - unless the option would be exposed in Settings, I think gnome-shell is fine, otherwise maybe stick it in org.gnome.desktop.interface?
Comment 7 Bastien Nocera 2015-11-13 15:26:27 UTC
Created attachment 315413 [details] [review]
power: Add battery percentage label

FIXME: remove some padding

Smaller text, centered
Comment 8 Bastien Nocera 2015-11-13 15:46:53 UTC
(In reply to Bastien Nocera from comment #7)
> Created attachment 315413 [details] [review] [review]
> power: Add battery percentage label
> 
> FIXME: remove some padding

Really not sure how to fix that in a way that would be acceptable for gnome-shell, so I'll just leave it there. The code is functional.
Comment 9 Florian Müllner 2015-11-13 19:27:37 UTC
Review of attachment 315413 [details] [review]:

::: js/ui/status/power.js
@@ +43,2 @@
         this._indicator = this._addIndicator();
+        //this._indicator.indicators.add_actor

Stray comment

@@ +99,3 @@
             this._item.actor.show();
+            if (this._desktopSettings.get_boolean(SHOW_BATTERY_PERCENTAGE))
+              this._percentageLabel.show();

Or:
  this._percentageLabel.visible = this._desktopSettings.get_boolean(SHOW_BATTERY_PERCENTAGE);

(this is just a side comment, no strong preference on my part)

@@ +115,3 @@
         this._item.icon.icon_name = icon;
 
+        // The label

???
Comment 10 Bastien Nocera 2015-11-17 09:56:46 UTC
(In reply to Florian Müllner from comment #9)
<snip>
> +        // The label
> 
> ???

Read the code in context? :)
Comment 11 Bastien Nocera 2015-11-17 09:57:09 UTC
Created attachment 315734 [details] [review]
power: Add battery percentage label

An oft requested feature, available in 4 separate extensions to
gnome-shell, and in most mobile OSes.
Comment 12 Florian Müllner 2015-11-17 10:27:33 UTC
Review of attachment 315734 [details] [review]:

OK
Comment 13 Bastien Nocera 2015-11-17 10:31:00 UTC
It's missing some padding fixes (lower spacing between icon and label, but not between label and drop-down arrow).
Comment 14 Florian Müllner 2015-11-17 10:35:58 UTC
> > +        // The label
> > 
> > ???
> 
> Read the code in context? :)

Well, there's a variable called "label" which is used to set a label text - adding a "The label" comment doesn't really provide any additional information ;-)
(I understand that the only reason the comment is there is consistency with the "status label" comment, which isn't the most useful comment either ...)
Comment 15 Bastien Nocera 2015-11-17 10:37:49 UTC
(In reply to Florian Müllner from comment #14)
> > > +        // The label
> > > 
> > > ???
> > 
> > Read the code in context? :)
> 
> Well, there's a variable called "label" which is used to set a label text -
> adding a "The label" comment doesn't really provide any additional
> information ;-)
> (I understand that the only reason the comment is there is consistency with
> the "status label" comment, which isn't the most useful comment either ...)

That's the only reason, I'm fine removing it. But I find it weird when separate sections are added and only some have headings/comments. In any case, whatever is comfortable for you.
Comment 16 Florian Müllner 2015-11-17 11:05:34 UTC
(In reply to Bastien Nocera from comment #13)
> It's missing some padding fixes (lower spacing between icon and label, but
> not between label and drop-down arrow).

Probably the easiest way:

 - add something like "this.indicators.add_style_class('power-status');" in init
 - use .power-status.status-indicators-box in the CSS to override the spacing


(In reply to Bastien Nocera from comment #15)
> That's the only reason, I'm fine removing it. But I find it weird when
> separate sections are added and only some have headings/comments.

Yeah, I think "icon label" hits the spot between consistency with other sections and non-informativeness.
Comment 17 Bastien Nocera 2015-11-17 17:47:29 UTC
(In reply to Florian Müllner from comment #16)
> (In reply to Bastien Nocera from comment #13)
> > It's missing some padding fixes (lower spacing between icon and label, but
> > not between label and drop-down arrow).
> 
> Probably the easiest way:
> 
>  - add something like "this.indicators.add_style_class('power-status');" in
> init
>  - use .power-status.status-indicators-box in the CSS to override the spacing

Couldn't figure out how to regenerate (or understand) the SASS code that I'm supposed to edit.

> (In reply to Bastien Nocera from comment #15)
> > That's the only reason, I'm fine removing it. But I find it weird when
> > separate sections are added and only some have headings/comments.
> 
> Yeah, I think "icon label" hits the spot between consistency with other
> sections and non-informativeness.

Changed locally.
Comment 18 Florian Müllner 2015-11-17 18:03:14 UTC
Created attachment 315777 [details] [review]
Tweak power indicator spacing

(In reply to Bastien Nocera from comment #17)
> Couldn't figure out how to regenerate (or understand) the SASS code that I'm
> supposed to edit.

Yeah, it's way too complicated. I'm attaching a sass patch, if it looks good to you I'll push it and do a gnome-shell patch you can squash.


> > Yeah, I think "icon label" hits the spot between consistency with other
> > sections and non-informativeness.
> 
> Changed locally.

Huh? I meant to say that the comment in the current patch versions looks good to me.
Comment 19 Bastien Nocera 2015-11-18 12:17:42 UTC
Created attachment 315818 [details] [review]
power: Add battery percentage label

An oft requested feature, available in 4 separate extensions to
gnome-shell, and in most mobile OSes.
Comment 20 Bastien Nocera 2015-11-18 12:29:11 UTC
(In reply to Florian Müllner from comment #18)
> Created attachment 315777 [details] [review] [review]
> Tweak power indicator spacing
> 
> (In reply to Bastien Nocera from comment #17)
> > Couldn't figure out how to regenerate (or understand) the SASS code that I'm
> > supposed to edit.
> 
> Yeah, it's way too complicated. I'm attaching a sass patch, if it looks good
> to you I'll push it and do a gnome-shell patch you can squash.

Allan said "good enough". I figured out the packages I needed to regenerate the gnome-shell CSS files.

> > > Yeah, I think "icon label" hits the spot between consistency with other
> > > sections and non-informativeness.
> > 
> > Changed locally.
> 
> Huh? I meant to say that the comment in the current patch versions looks
> good to me.

Well, that would be why it was already fixed locally ;)

I've merged the gsettings-desktop-schemas patch. I'll let you commit this last patch.
Comment 21 Florian Müllner 2015-11-19 13:05:56 UTC
Attachment 315818 [details] pushed as 31201d9 - power: Add battery percentage label