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
@ -8,7 +8,6 @@ const Gio = imports.gi.Gio;
|
||||
const GLib = imports.gi.GLib;
|
||||
const GnomeDesktop = imports.gi.GnomeDesktop;
|
||||
const Gtk = imports.gi.Gtk;
|
||||
const Lang = imports.lang;
|
||||
const Meta = imports.gi.Meta;
|
||||
const Signals = imports.signals;
|
||||
const Shell = imports.gi.Shell;
|
||||
@ -28,10 +27,8 @@ const LoginDialog = imports.gdm.loginDialog;
|
||||
// The timeout before going back automatically to the lock screen (in seconds)
|
||||
const IDLE_TIMEOUT = 2 * 60;
|
||||
|
||||
var UnlockDialog = new Lang.Class({
|
||||
Name: 'UnlockDialog',
|
||||
|
||||
_init(parentActor) {
|
||||
var UnlockDialog = class {
|
||||
constructor(parentActor) {
|
||||
this.actor = new St.Widget({ accessible_role: Atk.Role.WINDOW,
|
||||
style_class: 'login-dialog',
|
||||
layout_manager: new Clutter.BoxLayout(),
|
||||
@ -85,7 +82,7 @@ var UnlockDialog = new Lang.Class({
|
||||
|
||||
this._idleMonitor = Meta.IdleMonitor.get_core();
|
||||
this._idleWatchId = this._idleMonitor.add_idle_watch(IDLE_TIMEOUT * 1000, this._escape.bind(this));
|
||||
},
|
||||
}
|
||||
|
||||
_updateSensitivity(sensitive) {
|
||||
this._authPrompt.updateSensitivity(sensitive);
|
||||
@ -94,11 +91,11 @@ var UnlockDialog = new Lang.Class({
|
||||
this._otherUserButton.reactive = sensitive;
|
||||
this._otherUserButton.can_focus = sensitive;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_fail() {
|
||||
this.emit('failed');
|
||||
},
|
||||
}
|
||||
|
||||
_onReset(authPrompt, beginRequest) {
|
||||
let userName;
|
||||
@ -110,18 +107,18 @@ var UnlockDialog = new Lang.Class({
|
||||
}
|
||||
|
||||
this._authPrompt.begin({ userName: userName });
|
||||
},
|
||||
}
|
||||
|
||||
_escape() {
|
||||
if (this.allowCancel)
|
||||
this._authPrompt.cancel();
|
||||
},
|
||||
}
|
||||
|
||||
_otherUserClicked(button, event) {
|
||||
Gdm.goto_login_session_sync(null);
|
||||
|
||||
this._authPrompt.cancel();
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.popModal();
|
||||
@ -131,21 +128,21 @@ var UnlockDialog = new Lang.Class({
|
||||
this._idleMonitor.remove_watch(this._idleWatchId);
|
||||
this._idleWatchId = 0;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
cancel() {
|
||||
this._authPrompt.cancel();
|
||||
|
||||
this.destroy();
|
||||
},
|
||||
}
|
||||
|
||||
addCharacter(unichar) {
|
||||
this._authPrompt.addCharacter(unichar);
|
||||
},
|
||||
}
|
||||
|
||||
finish(onComplete) {
|
||||
this._authPrompt.finish(onComplete);
|
||||
},
|
||||
}
|
||||
|
||||
open(timestamp) {
|
||||
this.actor.show();
|
||||
@ -160,7 +157,7 @@ var UnlockDialog = new Lang.Class({
|
||||
this._isModal = true;
|
||||
|
||||
return true;
|
||||
},
|
||||
}
|
||||
|
||||
popModal(timestamp) {
|
||||
if (this._isModal) {
|
||||
@ -168,5 +165,5 @@ var UnlockDialog = new Lang.Class({
|
||||
this._isModal = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
Signals.addSignalMethods(UnlockDialog.prototype);
|
||||
|
Reference in New Issue
Block a user