[gnome-shell] Revert "power: Stop making time estimates"



commit d7401c8646e005cd5df7ee42819205656db89b40
Author: Michael Biebl <biebl debian org>
Date:   Tue Nov 17 13:16:45 2015 +0100

    Revert "power: Stop making time estimates"
    
    This reverts commit 6c08799c7b7a4d824acc8f2cf546749b7cc041f0.
    
    See https://bugzilla.gnome.org/show_bug.cgi?id=708472#c87

 js/ui/status/power.js |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/status/power.js b/js/ui/status/power.js
index 7f494f4..0bec19c 100644
--- a/js/ui/status/power.js
+++ b/js/ui/status/power.js
@@ -59,11 +59,39 @@ const Indicator = new Lang.Class({
     },
 
     _getStatus: function() {
+        let seconds = 0;
+
         if (this._proxy.State == UPower.DeviceState.FULLY_CHARGED)
             return _("Fully Charged");
         else if (this._proxy.State == UPower.DeviceState.CHARGING)
-            return _("%d\u2009%% Charging").format(hours, minutes, this._proxy.Percentage);
-        return _("%d\u2009%% Charged").format(this._proxy.Percentage);
+            seconds = this._proxy.TimeToFull;
+        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() {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]