PowerStatus: report 0 minutes as "Estimating..."

When UPower has not yet collected enough data to calculate a time
to discharge, it will report 0 minutes. Show "Estimating..." in
that case instead.

https://bugzilla.gnome.org/show_bug.cgi?id=642753
This commit is contained in:
Giovanni Campagna 2011-02-19 15:40:53 +01:00
parent 102b2e2ca6
commit 89dcd9027d

View File

@ -104,6 +104,11 @@ Indicator.prototype = {
if (device_type == UPDeviceType.BATTERY) { if (device_type == UPDeviceType.BATTERY) {
this._hasPrimary = true; this._hasPrimary = true;
let time = Math.round(seconds / 60); let time = Math.round(seconds / 60);
if (time == 0) {
// 0 is reported when UPower does not have enough data
// to estimate battery life
this._batteryItem.label.text = _("Estimating...");
} else {
let minutes = time % 60; let minutes = time % 60;
let hours = Math.floor(time / 60); let hours = Math.floor(time / 60);
let timestring; let timestring;
@ -119,6 +124,7 @@ Indicator.prototype = {
} else } else
timestring = Gettext.ngettext("%d minute remaining", "%d minutes remaining", minutes).format(minutes); timestring = Gettext.ngettext("%d minute remaining", "%d minutes remaining", minutes).format(minutes);
this._batteryItem.label.text = timestring; this._batteryItem.label.text = timestring;
}
this._primaryPercentage.text = Math.round(percentage) + '%'; this._primaryPercentage.text = Math.round(percentage) + '%';
this._batteryItem.actor.show(); this._batteryItem.actor.show();
if (this._deviceItems.length > 0) if (this._deviceItems.length > 0)