From 59ba112959ebba8147138a7ad94c542e47f3e420 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Sat, 20 Nov 2010 18:19:32 +0100 Subject: [PATCH] Complete porting to new gnome-power-manager API We updated the normal devices part, but we forgot the part about the primary device (possibly because it is not reported as such in case it is fully charged). Update that as well, to avoid showing weird GIcon serializations. https://bugzilla.gnome.org/show_bug.cgi?id=635288 --- js/ui/status/power.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/js/ui/status/power.js b/js/ui/status/power.js index 52de29ed9..794a090ec 100644 --- a/js/ui/status/power.js +++ b/js/ui/status/power.js @@ -71,12 +71,19 @@ Indicator.prototype = { this._deviceItems = [ ]; this._hasPrimary = false; this._primaryDeviceId = null; + this._batteryItem = new PopupMenu.PopupMenuItem(''); + this._primaryPercentage = new St.Label(); + let percentBin = new St.Bin(); + percentBin.set_child(this._primaryPercentage, { x_align: St.Align.END }); + this._batteryItem.addActor(percentBin); this.menu.addMenuItem(this._batteryItem); + this._deviceSep = new PopupMenu.PopupSeparatorMenuItem(); this.menu.addMenuItem(this._deviceSep); this._otherDevicePosition = 2; this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); + this.menu.addAction(_("What's using power..."),function() { GLib.spawn_command_line_async('gnome-power-statistics --device wakeups'); }); @@ -98,10 +105,12 @@ Indicator.prototype = { this._deviceSep.actor.hide(); return; } - let [device_id, device_type, summary, percentage, state, time] = device; + let [device_id, device_type, icon, percentage, state, time] = device; if (device_type == UPDeviceType.BATTERY) { this._hasPrimary = true; - this._batteryItem.label.text = summary; + let minutes = Math.floor(time / 60); + this._batteryItem.label.text = Gettext.ngettext("%d minute remaining", "%d minutes remaining", minutes).format(minutes); + this._primaryPercentage.text = '%d%%'.format(Math.round(percentage)); this._batteryItem.actor.show(); if (this._deviceItems.length > 0) this._deviceSep.actor.show();