Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:GA
gnome-shell
gnome-shell-874712-use-upower-directly.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gnome-shell-874712-use-upower-directly.patch of Package gnome-shell
diff -ur gnome-shell-3.10.4.orig/js/ui/status/power.js gnome-shell-3.10.4/js/ui/status/power.js --- gnome-shell-3.10.4.orig/js/ui/status/power.js 2014-02-19 12:19:32.000000000 -0600 +++ gnome-shell-3.10.4/js/ui/status/power.js 2014-05-22 20:07:23.564013684 -0500 @@ -8,20 +8,22 @@ const PanelMenu = imports.ui.panelMenu; const PopupMenu = imports.ui.popupMenu; -const BUS_NAME = 'org.gnome.SettingsDaemon.Power'; -const OBJECT_PATH = '/org/gnome/SettingsDaemon/Power'; +const BUS_NAME = 'org.freedesktop.UPower'; +const OBJECT_PATH = '/org/freedesktop/UPower/devices/DisplayDevice'; -const PowerManagerInterface = <interface name="org.gnome.SettingsDaemon.Power"> -<method name="GetDevices"> - <arg type="a(susdut)" direction="out" /> -</method> -<method name="GetPrimaryDevice"> - <arg type="(susdut)" direction="out" /> -</method> -<property name="Icon" type="s" access="read" /> -</interface>; +const DisplayDeviceInterface = '<node> \ +<interface name="org.freedesktop.UPower.Device"> \ + <property name="Type" type="u" access="read"/> \ + <property name="State" type="u" access="read"/> \ + <property name="Percentage" type="d" access="read"/> \ + <property name="TimeToEmpty" type="x" access="read"/> \ + <property name="TimeToFull" type="x" access="read"/> \ + <property name="IsPresent" type="b" access="read"/> \ + <property name="IconName" type="s" access="read"/> \ +</interface> \ +</node>'; -const PowerManagerProxy = Gio.DBusProxy.makeProxyWrapper(PowerManagerInterface); +const PowerManagerProxy = Gio.DBusProxy.makeProxyWrapper(DisplayDeviceInterface); const Indicator = new Lang.Class({ Name: 'PowerIndicator', @@ -32,7 +34,7 @@ this._indicator = this._addIndicator(); - this._proxy = new PowerManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH, + this._proxy = new PowerManagerProxy(Gio.DBus.system, BUS_NAME, OBJECT_PATH, Lang.bind(this, function(proxy, error) { if (error) { log(error.message); @@ -43,7 +45,7 @@ this._sync(); })); - this._item = new PopupMenu.PopupSubMenuMenuItem(_("Battery"), true); + this._item = new PopupMenu.PopupSubMenuMenuItem("", true); this._item.menu.addSettingsAction(_("Power Settings"), 'gnome-power-panel.desktop'); this.menu.addMenuItem(this._item); @@ -56,11 +58,18 @@ this.menu.setSensitive(sensitive); }, - _statusForDevice: function(device) { - let [device_id, device_type, icon, percentage, state, seconds] = device; + _getStatus: function() { + let seconds = 0; - if (state == UPower.DeviceState.FULLY_CHARGED) + if (this._proxy.State == UPower.DeviceState.FULLY_CHARGED) return _("Fully Charged"); + else if (this._proxy.State == UPower.DeviceState.CHARGING) + 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) { @@ -72,44 +81,43 @@ let minutes = time % 60; let hours = Math.floor(time / 60); - if (state == UPower.DeviceState.DISCHARGING) { + if (this._proxy.State == UPower.DeviceState.DISCHARGING) { // Translators: this is <hours>:<minutes> Remaining (<percentage>) - return _("%d\u2236%02d Remaining (%d%%)").format(hours, minutes, percentage); + return _("%d\u2236%02d Remaining (%d%%)").format(hours, minutes, this._proxy.Percentage); } - if (state == UPower.DeviceState.CHARGING) { + if (this._proxy.State == UPower.DeviceState.CHARGING) { // Translators: this is <hours>:<minutes> Until Full (<percentage>) - return _("%d\u2236%02d Until Full (%d%%)").format(hours, minutes, percentage); + return _("%d\u2236%02d Until Full (%d%%)").format(hours, minutes, this._proxy.Percentage); } - // state is one of PENDING_CHARGING, PENDING_DISCHARGING - return _("Estimating…"); + return null; }, _sync: function() { - function isBattery(result) { - if (!result) - return false; - - let [device] = result; - let [, deviceType] = device; - return (deviceType == UPower.DeviceKind.BATTERY); + // Do we have batteries or a UPS? + let visible = this._proxy.IsPresent; + if (visible) { + this._item.actor.show(); + } else { + // If there's no battery, then we use the power icon. + this._item.actor.hide(); + this._indicator.icon_name = 'system-shutdown-symbolic'; + return; } - 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(); - } - })); + // The icons + let icon = this._proxy.IconName; + this._indicator.icon_name = icon; + this._item.icon.icon_name = icon; + + // The status label + this._item.status.text = this._getStatus(); + + // The sub-menu heading + if (this._proxy.Type == UPower.DeviceKind.UPS) + this._item.label.text = _("UPS"); + else + this._item.label.text = _("Battery"); }, });
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor