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 @@
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const Gio = imports.gi.Gio;
|
||||
const GLib = imports.gi.GLib;
|
||||
const Lang = imports.lang;
|
||||
const Pango = imports.gi.Pango;
|
||||
const Shell = imports.gi.Shell;
|
||||
const St = imports.gi.St;
|
||||
@ -21,12 +20,9 @@ var DialogResponse = {
|
||||
CLOSED: 2
|
||||
};
|
||||
|
||||
var AccessDialog = new Lang.Class({
|
||||
Name: 'AccessDialog',
|
||||
Extends: ModalDialog.ModalDialog,
|
||||
|
||||
_init(invocation, handle, title, subtitle, body, options) {
|
||||
this.parent({ styleClass: 'access-dialog' });
|
||||
var AccessDialog = class extends ModalDialog.ModalDialog {
|
||||
constructor(invocation, handle, title, subtitle, body, options) {
|
||||
super({ styleClass: 'access-dialog' });
|
||||
|
||||
this._invocation = invocation;
|
||||
this._handle = handle;
|
||||
@ -38,7 +34,7 @@ var AccessDialog = new Lang.Class({
|
||||
options[option] = options[option].deep_unpack();
|
||||
|
||||
this._buildLayout(title, subtitle, body, options);
|
||||
},
|
||||
}
|
||||
|
||||
_buildLayout(title, subtitle, body, options) {
|
||||
// No support for non-modal system dialogs, so ignore the option
|
||||
@ -78,14 +74,14 @@ var AccessDialog = new Lang.Class({
|
||||
action: () => {
|
||||
this._sendResponse(DialogResponse.OK);
|
||||
}});
|
||||
},
|
||||
}
|
||||
|
||||
open() {
|
||||
this.parent();
|
||||
super.open();
|
||||
|
||||
let connection = this._invocation.get_connection();
|
||||
this._requestExported = this._request.export(connection, this._handle);
|
||||
},
|
||||
}
|
||||
|
||||
CloseAsync(invocation, params) {
|
||||
if (this._invocation.get_sender() != invocation.get_sender()) {
|
||||
@ -96,7 +92,7 @@ var AccessDialog = new Lang.Class({
|
||||
}
|
||||
|
||||
this._sendResponse(DialogResponse.CLOSED);
|
||||
},
|
||||
}
|
||||
|
||||
_sendResponse(response) {
|
||||
if (this._requestExported)
|
||||
@ -118,12 +114,10 @@ var AccessDialog = new Lang.Class({
|
||||
});
|
||||
this.close();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var AccessDialogDBus = new Lang.Class({
|
||||
Name: 'AccessDialogDBus',
|
||||
|
||||
_init() {
|
||||
var AccessDialogDBus = class {
|
||||
constructor() {
|
||||
this._accessDialog = null;
|
||||
|
||||
this._windowTracker = Shell.WindowTracker.get_default();
|
||||
@ -132,7 +126,7 @@ var AccessDialogDBus = new Lang.Class({
|
||||
this._dbusImpl.export(Gio.DBus.session, '/org/freedesktop/portal/desktop');
|
||||
|
||||
Gio.DBus.session.own_name('org.freedesktop.impl.portal.desktop.gnome', Gio.BusNameOwnerFlags.REPLACE, null, null);
|
||||
},
|
||||
}
|
||||
|
||||
AccessDialogAsync(params, invocation) {
|
||||
if (this._accessDialog) {
|
||||
@ -160,4 +154,4 @@ var AccessDialogDBus = new Lang.Class({
|
||||
|
||||
this._accessDialog = dialog;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user