Revert "power: Stop making time estimates"

This reverts commit 6c08799c7b.

See https://bugzilla.gnome.org/show_bug.cgi?id=708472#c87
This commit is contained in:
Michael Biebl 2015-11-17 13:16:45 +01:00
parent a456d5eb19
commit d7401c8646

View File

@ -59,11 +59,39 @@ const Indicator = new Lang.Class({
}, },
_getStatus: function() { _getStatus: function() {
let seconds = 0;
if (this._proxy.State == UPower.DeviceState.FULLY_CHARGED) if (this._proxy.State == UPower.DeviceState.FULLY_CHARGED)
return _("Fully Charged"); return _("Fully Charged");
else if (this._proxy.State == UPower.DeviceState.CHARGING) else if (this._proxy.State == UPower.DeviceState.CHARGING)
return _("%d\u2009%% Charging").format(hours, minutes, this._proxy.Percentage); seconds = this._proxy.TimeToFull;
return _("%d\u2009%% Charged").format(this._proxy.Percentage); else if (this._proxy.State == UPower.DeviceState.DISCHARGING)
seconds = this._proxy.TimeToEmpty;
// state is one of PENDING_CHARGING, PENDING_DISCHARGING
else
return _("Estimating…");
let time = Math.round(seconds / 60);
if (time == 0) {
// 0 is reported when UPower does not have enough data
// to estimate battery life
return _("Estimating…");
}
let minutes = time % 60;
let hours = Math.floor(time / 60);
if (this._proxy.State == UPower.DeviceState.DISCHARGING) {
// Translators: this is <hours>:<minutes> Remaining (<percentage>)
return _("%d\u2236%02d Remaining (%d\u2009%%)").format(hours, minutes, this._proxy.Percentage);
}
if (this._proxy.State == UPower.DeviceState.CHARGING) {
// Translators: this is <hours>:<minutes> Until Full (<percentage>)
return _("%d\u2236%02d Until Full (%d\u2009%%)").format(hours, minutes, this._proxy.Percentage);
}
return null;
}, },
_sync: function() { _sync: function() {