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
@ -2,7 +2,6 @@
|
||||
|
||||
const Gio = imports.gi.Gio;
|
||||
const GLib = imports.gi.GLib;
|
||||
const Lang = imports.lang;
|
||||
const Params = imports.misc.params;
|
||||
const Signals = imports.signals;
|
||||
|
||||
@ -27,9 +26,8 @@ const ObjectManagerIface = `
|
||||
|
||||
const ObjectManagerInfo = Gio.DBusInterfaceInfo.new_for_xml(ObjectManagerIface);
|
||||
|
||||
var ObjectManager = new Lang.Class({
|
||||
Name: 'ObjectManager',
|
||||
_init(params) {
|
||||
var ObjectManager = class {
|
||||
constructor(params) {
|
||||
params = Params.parse(params, { connection: null,
|
||||
name: null,
|
||||
objectPath: null,
|
||||
@ -63,7 +61,7 @@ var ObjectManager = new Lang.Class({
|
||||
this._managerProxy.init_async(GLib.PRIORITY_DEFAULT,
|
||||
this._cancellable,
|
||||
this._onManagerProxyLoaded.bind(this));
|
||||
},
|
||||
}
|
||||
|
||||
_tryToCompleteLoad() {
|
||||
if (this._numLoadInhibitors == 0)
|
||||
@ -74,7 +72,7 @@ var ObjectManager = new Lang.Class({
|
||||
if (this._onLoaded)
|
||||
this._onLoaded();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_addInterface(objectPath, interfaceName, onFinished) {
|
||||
let info = this._interfaceInfos[interfaceName];
|
||||
@ -129,7 +127,7 @@ var ObjectManager = new Lang.Class({
|
||||
if (onFinished)
|
||||
onFinished();
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
_removeInterface(objectPath, interfaceName) {
|
||||
if (!this._objects[objectPath])
|
||||
@ -155,7 +153,7 @@ var ObjectManager = new Lang.Class({
|
||||
delete this._objects[objectPath];
|
||||
this.emit('object-removed', objectPath);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_onManagerProxyLoaded(initable, result) {
|
||||
let error = null;
|
||||
@ -194,7 +192,7 @@ var ObjectManager = new Lang.Class({
|
||||
|
||||
if (this._managerProxy.g_name_owner)
|
||||
this._onNameAppeared();
|
||||
},
|
||||
}
|
||||
|
||||
_onNameAppeared() {
|
||||
this._managerProxy.GetManagedObjectsRemote((result, error) => {
|
||||
@ -232,7 +230,7 @@ var ObjectManager = new Lang.Class({
|
||||
}
|
||||
this._tryToCompleteLoad();
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
_onNameVanished() {
|
||||
let objectPaths = Object.keys(this._objects);
|
||||
@ -248,14 +246,14 @@ var ObjectManager = new Lang.Class({
|
||||
this._removeInterface(objectPath, interfaceName);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_registerInterfaces(interfaces) {
|
||||
for (let i = 0; i < interfaces.length; i++) {
|
||||
let info = Gio.DBusInterfaceInfo.new_for_xml(interfaces[i]);
|
||||
this._interfaceInfos[info.name] = info;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
getProxy(objectPath, interfaceName) {
|
||||
let object = this._objects[objectPath];
|
||||
@ -264,7 +262,7 @@ var ObjectManager = new Lang.Class({
|
||||
return null;
|
||||
|
||||
return object[interfaceName];
|
||||
},
|
||||
}
|
||||
|
||||
getProxiesForInterface(interfaceName) {
|
||||
let proxyList = this._interfaces[interfaceName];
|
||||
@ -273,7 +271,7 @@ var ObjectManager = new Lang.Class({
|
||||
return [];
|
||||
|
||||
return proxyList;
|
||||
},
|
||||
}
|
||||
|
||||
getAllProxies() {
|
||||
let proxies = [];
|
||||
@ -292,5 +290,5 @@ var ObjectManager = new Lang.Class({
|
||||
|
||||
return proxies;
|
||||
}
|
||||
});
|
||||
};
|
||||
Signals.addSignalMethods(ObjectManager.prototype);
|
||||
|
Reference in New Issue
Block a user