[gnome-shell] PowerStatus: Update for gnome-power-manager API changes
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] PowerStatus: Update for gnome-power-manager API changes
- Date: Fri, 19 Nov 2010 22:10:52 +0000 (UTC)
commit de50cf80a80b09d8385abfcdb3b0dd93b84d1b8a
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Fri Nov 19 18:57:35 2010 +0100
PowerStatus: Update for gnome-power-manager API changes
g-p-m no longer exports a summary, and instead exports a GIcon to
show. Update for that.
https://bugzilla.gnome.org/show_bug.cgi?id=635288
js/ui/status/power.js | 60 +++++++++++++++++++++++++++---------------------
1 files changed, 34 insertions(+), 26 deletions(-)
---
diff --git a/js/ui/status/power.js b/js/ui/status/power.js
index 6f8ba32..52de29e 100644
--- a/js/ui/status/power.js
+++ b/js/ui/status/power.js
@@ -26,7 +26,10 @@ const UPDeviceType = {
MOUSE: 5,
KEYBOARD: 6,
PDA: 7,
- PHONE: 8
+ PHONE: 8,
+ MEDIA_PLAYER: 9,
+ TABLET: 10,
+ COMPUTER: 11
};
const UPDeviceState = {
@@ -181,24 +184,12 @@ DeviceItem.prototype = {
_init: function(device) {
PopupMenu.PopupBaseMenuItem.prototype._init.call(this);
- let [device_id, device_type, summary, percentage, state, time] = device;
+ let [device_id, device_type, icon, percentage, state, time] = device;
this._box = new St.BoxLayout({ style_class: 'popup-device-menu-item' });
- this._label = new St.Label({ text: summary });
-
- let icon;
- switch (state) {
- case UPDeviceState.FULLY_CHARGED:
- icon = 'battery-full-charged';
- break;
- case UPDeviceState.UNKNOWN:
- icon = 'battery-missing';
- break;
- default:
- icon = this._percentageToIcon(percentage) + (state == UPDeviceState.CHARGING ? '-charging' : '');
- }
+ this._label = new St.Label({ text: this._deviceTypeToString(device_type) });
- this._icon = new St.Icon({ icon_name: icon,
+ this._icon = new St.Icon({ gicon: Shell.util_icon_from_string(icon),
icon_type: St.IconType.SYMBOLIC,
style_class: 'popup-menu-icon' });
@@ -212,15 +203,32 @@ DeviceItem.prototype = {
this.addActor(percentBin);
},
- _percentageToIcon: function(p) {
- if (p > 60)
- return 'battery-full';
- if (p > 30)
- return 'battery-good';
- if (p > 10)
- return 'battery-low';
- if (p > 0)
- return 'battery-caution';
- return 'battery-empty';
+ _deviceTypeToString: function(type) {
+ switch (type) {
+ case UPDeviceType.AC_POWER:
+ return _("AC adapter");
+ case UPDeviceType.BATTERY:
+ return _("Laptop battery");
+ case UPDeviceType.UPS:
+ return _("UPS");
+ case UPDeviceType.MONITOR:
+ return _("Monitor");
+ case UPDeviceType.MOUSE:
+ return _("Mouse");
+ case UPDeviceType.KEYBOARD:
+ return _("Keyboard");
+ case UPDeviceType.PDA:
+ return _("PDA");
+ case UPDeviceType.PHONE:
+ return _("Cell phone");
+ case UPDeviceType.MEDIA_PLAYER:
+ return _("Media player");
+ case UPDeviceType.TABLET:
+ return _("Tablet");
+ case UPDeviceType.COMPUTER:
+ return _("Computer");
+ default:
+ return _("Unknown");
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]