[gnome-shell] power: Use the icon from the primary device for status



commit 575b373cd5bc926e4dd8306cce8bf4b3f2af871c
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Oct 10 11:11:24 2013 -0400

    power: Use the icon from the primary device for status
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709925

 js/ui/status/power.js |   42 +++++++++++++++++-------------------------
 1 files changed, 17 insertions(+), 25 deletions(-)
---
diff --git a/js/ui/status/power.js b/js/ui/status/power.js
index ec1e9ae..429db7a 100644
--- a/js/ui/status/power.js
+++ b/js/ui/status/power.js
@@ -86,38 +86,30 @@ const Indicator = new Lang.Class({
         return _("Estimating…");
     },
 
-    _syncStatusLabel: function() {
-        this._proxy.GetPrimaryDeviceRemote(Lang.bind(this, function(result, error) {
-            if (error) {
-                this._item.actor.hide();
-                return;
-            }
+    _sync: function() {
+        function isBattery(result) {
+            if (!result)
+                return false;
 
             let [device] = result;
-            let [device_id, device_type] = device;
-            if (device_type == UPower.DeviceKind.BATTERY) {
+            let [, deviceType] = device;
+            return (deviceType == UPower.DeviceKind.BATTERY);
+        }
+
+        this._proxy.GetPrimaryDeviceRemote(Lang.bind(this, function(result, error) {
+            if (isBattery(result)) {
+                let [device] = result;
+                let [,, icon] = device;
+                let gicon = Gio.icon_new_for_string(icon);
+                this._indicator.gicon = gicon;
+                this._item.icon.gicon = gicon;
                 this._item.status.text = this._statusForDevice(device);
                 this._item.actor.show();
             } else {
+                // If there's no battery, then we use the power icon.
+                this._indicator.icon_name = 'system-shutdown-symbolic';
                 this._item.actor.hide();
             }
         }));
     },
-
-    _syncIcon: function() {
-        let icon = this._proxy.Icon;
-        if (icon) {
-            let gicon = Gio.icon_new_for_string(icon);
-            this._indicator.gicon = gicon;
-            this._item.icon.gicon = gicon;
-        } else {
-            // If there's no battery, then we use the power icon.
-            this._indicator.icon_name = 'system-shutdown-symbolic';
-        }
-    },
-
-    _sync: function() {
-        this._syncIcon();
-        this._syncStatusLabel();
-    }
 });


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