Merge pull request #12 from Eeems/patch-1

Gnome 43 support
This commit is contained in:
Martin Zurowietz 2023-02-02 10:52:10 +01:00 committed by GitHub
commit 63103c7da6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 13 deletions

View file

@ -4,15 +4,16 @@ const Panel = imports.ui.main.panel;
class BaTimeExtension { class BaTimeExtension {
constructor() { constructor() {
this.aggregateMenu = Panel.statusArea['aggregateMenu']; this.aggregateMenu = Panel.statusArea.quickSettings;
this.originalIndicator = this.aggregateMenu._power; this.originalIndicator = this.aggregateMenu._system;
this.customIndicator = new BaTime.imports.power.Indicator(); this.aggregateMenu._system = this.customIndicator = new BaTime.imports.power.Indicator();
this.aggregateMenu._indicators.replace_child( this.aggregateMenu._indicators.replace_child(
this.originalIndicator, this.originalIndicator,
this.customIndicator this.customIndicator
); );
} }
destroy() { destroy() {
this.aggregateMenu._system = this.originalIndicator;
this.aggregateMenu._indicators.replace_child( this.aggregateMenu._indicators.replace_child(
this.customIndicator, this.customIndicator,
this.originalIndicator this.originalIndicator

View file

@ -1,9 +1,7 @@
{ {
"shell-version": [ "shell-version": [
"40", "43"
"41",
"42"
], ],
"uuid": "batime@martin.zurowietz.de", "uuid": "batime@martin.zurowietz.de",
"url": "https://github.com/mzur/gnome-shell-batime", "url": "https://github.com/mzur/gnome-shell-batime",

View file

@ -1,20 +1,22 @@
const { GObject} = imports.gi; const { GObject} = imports.gi;
const UPower = imports.gi.UPowerGlib; const UPower = imports.gi.UPowerGlib;
const BaseIndicator = imports.ui.status.power.Indicator; const BaseIndicator = imports.ui.status.system.Indicator;
var Indicator = GObject.registerClass( var Indicator = GObject.registerClass(
class Indicator extends BaseIndicator { class Indicator extends BaseIndicator {
// Adapted from _getStatus of the parent. // Adapted from _getStatus of the parent.
_getTime() { _getTime() {
let seconds = 0; let seconds = 0;
let proxy = this._systemItem.powerToggle._proxy;
let state = proxy.State;
if (this._proxy.State === UPower.DeviceState.FULLY_CHARGED) { if (state === UPower.DeviceState.FULLY_CHARGED) {
return ''; return '';
} else if (this._proxy.State === UPower.DeviceState.CHARGING) { } else if (state === UPower.DeviceState.CHARGING) {
seconds = this._proxy.TimeToFull; seconds = proxy.TimeToFull;
} else if (this._proxy.State === UPower.DeviceState.DISCHARGING) { } else if (state === UPower.DeviceState.DISCHARGING) {
seconds = this._proxy.TimeToEmpty; seconds = proxy.TimeToEmpty;
} else if (this._proxy.State === UPower.DeviceState.PENDING_CHARGE) { } else if (state === UPower.DeviceState.PENDING_CHARGE) {
return ''; return '';
} else { } else {
// state is PENDING_DISCHARGE or UNKNOWN // state is PENDING_DISCHARGE or UNKNOWN