Skip to content
Permalink
Browse files

Merge pull request #242 from stoolye/master

Initial support for 3.12. Keep compatible with 3.10.
  • Loading branch information
darkxst committed May 5, 2014
2 parents 32dff76 + 12baefc commit 1b632f98d74407f60d80ef7638378fcbdc725ead
@@ -857,51 +857,72 @@ const Battery = new Lang.Class({
// callback function for when battery stats updated.
let battery_found = false;
let isBattery = false;
this._proxy.GetDevicesRemote(Lang.bind(this, function(devices, error) {
if (error) {

log("SM: Power proxy error: " + error)
if (this._proxy.GetDevicesRemote == undefined) {
let device_type = this._proxy.Type;
isBattery = (device_type == Power.UPower.DeviceKind.BATTERY);
if (isBattery) {
battery_found = true;
let icon = this._proxy.IconName;
let percentage = this._proxy.Percentage;
let seconds = this._proxy.TimeToEmpty;
this.update_battery_value(seconds, percentage, icon);
} else {
log("SM: No battery found");
this.actor.hide();

this.menu_item.actor.hide();
return;
}
} else {
this._proxy.GetDevicesRemote(Lang.bind(this, function(devices, error) {
if (error) {

let [result] = devices;
for (let i = 0; i < result.length; i++) {
let [device_id, device_type, icon, percentage, state, seconds] = result[i];

if (Compat.versionCompare(shell_Version, "3.9"))
isBattery = (device_type == Power.UPower.DeviceKind.BATTERY);
else
isBattery = (device_type == Power.UPDeviceType.BATTERY);

if (isBattery && !battery_found) {
battery_found = true;
//grab data
if (seconds > 60){
let time = Math.round(seconds / 60);
let minutes = time % 60;
let hours = Math.floor(time / 60);
this.timeString = C_("battery time remaining","%d:%02d").format(hours,minutes);
} else {
this.timeString = '-- ';
log("SM: Power proxy error: " + error)
this.actor.hide();
this.menu_item.actor.hide();
return;
}

let [result] = devices;
for (let i = 0; i < result.length; i++) {
let [device_id, device_type, icon, percentage, state, seconds] = result[i];

if (Compat.versionCompare(shell_Version, "3.9"))
isBattery = (device_type == Power.UPower.DeviceKind.BATTERY);
else
isBattery = (device_type == Power.UPDeviceType.BATTERY);

if (isBattery) {
battery_found = true;
this.update_battery_value(seconds, percentage, icon);
break;
}
this.percentage = Math.ceil(percentage);
this.gicon = Gio.icon_new_for_string(icon);
}

if (!battery_found) {
log("SM: No battery found")
this.actor.hide();

if (Schema.get_boolean(this.elt + '-display'))
this.actor.show()
if (Schema.get_boolean(this.elt + '-show-menu'))
this.menu_item.actor.show();
this.menu_item.actor.hide();
}
}
if (!battery_found) {
log("SM: No battery found")
this.actor.hide();
}));
}
},
update_battery_value: function(seconds, percentage, icon) {
if (seconds > 60){
let time = Math.round(seconds / 60);
let minutes = time % 60;
let hours = Math.floor(time / 60);
this.timeString = C_("battery time remaining","%d:%02d").format(hours,minutes);
} else {
this.timeString = '-- ';
}
this.percentage = Math.ceil(percentage);
this.gicon = Gio.icon_new_for_string(icon);

this.menu_item.actor.hide();
}
}));
if (Schema.get_boolean(this.elt + '-display'))
this.actor.show()
if (Schema.get_boolean(this.elt + '-show-menu'))
this.menu_item.actor.show();
},
hide_system_icon: function(override) {
let value = Schema.get_boolean(this.elt + '-hidesystem');
@@ -1809,8 +1830,9 @@ var enable = function () {
if (_gsmPrefs.get_state() == _gsmPrefs.SHELL_APP_STATE_RUNNING){
_gsmPrefs.activate();
} else {
_gsmPrefs.launch(global.display.get_current_time_roundtrip(),
[metadata.uuid],-1,null);
let info = _gsmPrefs.get_app_info();
let timestamp = global.display.get_current_time_roundtrip();
info.launch_uris([metadata.uuid], global.create_app_launch_context(timestamp, -1));
}
});
tray.menu.addMenuItem(item);
@@ -1,5 +1,5 @@
{
"shell-version": ["3.4","3.6","3.8","3.10"],
"shell-version": ["3.4","3.6","3.8","3.10", "3.12"],
"uuid": "system-monitor@paradoxxx.zero.gmail.com",
"name": "system-monitor",
"url": "https://github.com/paradoxxxzero/gnome-shell-system-monitor-applet",

0 comments on commit 1b632f9

Please sign in to comment.
You can’t perform that action at this time.