cleanup: Port non-GObject classes to JS6 classes
ES6 finally adds standard class syntax to the language, so we can replace our custom Lang.Class framework with the new syntax. Any classes that inherit from GObject will need special treatment, so limit the port to regular javascript classes for now. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361
This commit is contained in:

committed by
Georges Basile Stavracas Neto

parent
99ce3deeb0
commit
bacfdbbb03
@ -1,7 +1,6 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
|
||||
const Gio = imports.gi.Gio;
|
||||
const Lang = imports.lang;
|
||||
const Signals = imports.signals;
|
||||
|
||||
const Main = imports.ui.main;
|
||||
@ -16,10 +15,8 @@ const OBJECT_PATH = '/org/gnome/SettingsDaemon/Rfkill';
|
||||
const RfkillManagerInterface = loadInterfaceXML('org.gnome.SettingsDaemon.Rfkill');
|
||||
const RfkillManagerProxy = Gio.DBusProxy.makeProxyWrapper(RfkillManagerInterface);
|
||||
|
||||
var RfkillManager = new Lang.Class({
|
||||
Name: 'RfkillManager',
|
||||
|
||||
_init() {
|
||||
var RfkillManager = class {
|
||||
constructor() {
|
||||
this._proxy = new RfkillManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH,
|
||||
(proxy, error) => {
|
||||
if (error) {
|
||||
@ -30,28 +27,28 @@ var RfkillManager = new Lang.Class({
|
||||
this._changed.bind(this));
|
||||
this._changed();
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
get airplaneMode() {
|
||||
return this._proxy.AirplaneMode;
|
||||
},
|
||||
}
|
||||
|
||||
set airplaneMode(v) {
|
||||
this._proxy.AirplaneMode = v;
|
||||
},
|
||||
}
|
||||
|
||||
get hwAirplaneMode() {
|
||||
return this._proxy.HardwareAirplaneMode;
|
||||
},
|
||||
}
|
||||
|
||||
get shouldShowAirplaneMode() {
|
||||
return this._proxy.ShouldShowAirplaneMode;
|
||||
},
|
||||
}
|
||||
|
||||
_changed() {
|
||||
this.emit('airplane-mode-changed');
|
||||
}
|
||||
});
|
||||
};
|
||||
Signals.addSignalMethods(RfkillManager.prototype);
|
||||
|
||||
var _manager;
|
||||
@ -63,12 +60,9 @@ function getRfkillManager() {
|
||||
return _manager;
|
||||
}
|
||||
|
||||
var Indicator = new Lang.Class({
|
||||
Name: 'RfkillIndicator',
|
||||
Extends: PanelMenu.SystemIndicator,
|
||||
|
||||
_init() {
|
||||
this.parent();
|
||||
var Indicator = class extends PanelMenu.SystemIndicator {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this._manager = getRfkillManager();
|
||||
this._manager.connect('airplane-mode-changed', this._sync.bind(this));
|
||||
@ -90,12 +84,12 @@ var Indicator = new Lang.Class({
|
||||
|
||||
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
|
||||
this._sessionUpdated();
|
||||
},
|
||||
}
|
||||
|
||||
_sessionUpdated() {
|
||||
let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
|
||||
this.menu.setSensitive(sensitive);
|
||||
},
|
||||
}
|
||||
|
||||
_sync() {
|
||||
let airplaneMode = this._manager.airplaneMode;
|
||||
@ -110,5 +104,5 @@ var Indicator = new Lang.Class({
|
||||
this._offItem.label.text = _("Use hardware switch to turn off");
|
||||
else
|
||||
this._offItem.label.text = _("Turn Off");
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user