cleanup: Port GObject classes to JS6 classes

GJS added API for defining GObject classes with ES6 class syntax
last cycle, use it to port the remaining Lang.Class classes to
the new syntax.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361
This commit is contained in:
Florian Müllner
2017-10-31 02:23:39 +01:00
committed by Georges Basile Stavracas Neto
parent bacfdbbb03
commit e68dfed1f7
43 changed files with 1036 additions and 1235 deletions

View File

@ -24,7 +24,6 @@ const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const Meta = imports.gi.Meta;
const Pango = imports.gi.Pango;
const Shell = imports.gi.Shell;
@ -400,13 +399,11 @@ var SessionMenuButton = class {
};
Signals.addSignalMethods(SessionMenuButton.prototype);
var LoginDialog = new Lang.Class({
Name: 'LoginDialog',
Extends: St.Widget,
var LoginDialog = GObject.registerClass({
Signals: { 'failed': {} },
}, class LoginDialog extends St.Widget {
_init(parentActor) {
this.parent({ style_class: 'login-dialog',
super._init({ style_class: 'login-dialog',
visible: false });
this.get_accessible().set_role(Atk.Role.WINDOW);
@ -524,7 +521,7 @@ var LoginDialog = new Lang.Class({
// focus later
this._startupCompleteId = Main.layoutManager.connect('startup-complete',
this._updateDisableUserList.bind(this));
},
}
_getBannerAllocation(dialogBox) {
let actorBox = new Clutter.ActorBox();
@ -538,7 +535,7 @@ var LoginDialog = new Lang.Class({
actorBox.y2 = actorBox.y1 + natHeight;
return actorBox;
},
}
_getLogoBinAllocation(dialogBox) {
let actorBox = new Clutter.ActorBox();
@ -552,7 +549,7 @@ var LoginDialog = new Lang.Class({
actorBox.y2 = actorBox.y1 + natHeight;
return actorBox;
},
}
_getCenterActorAllocation(dialogBox, actor) {
let actorBox = new Clutter.ActorBox();
@ -570,7 +567,7 @@ var LoginDialog = new Lang.Class({
actorBox.y2 = actorBox.y1 + natHeight;
return actorBox;
},
}
vfunc_allocate(dialogBox, flags) {
this.set_allocation(dialogBox, flags);
@ -713,7 +710,7 @@ var LoginDialog = new Lang.Class({
if (logoAllocation)
this._logoBin.allocate(logoAllocation, flags);
},
}
_ensureUserListLoaded() {
if (!this._userManager.is_loaded) {
@ -729,7 +726,7 @@ var LoginDialog = new Lang.Class({
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, this._loadUserList.bind(this));
GLib.Source.set_name_by_id(id, '[gnome-shell] _loadUserList');
}
},
}
_updateDisableUserList() {
let disableUserList = this._settings.get_boolean(GdmUtil.DISABLE_USER_LIST_KEY);
@ -744,7 +741,7 @@ var LoginDialog = new Lang.Class({
if (this._authPrompt.verificationStatus == AuthPrompt.AuthPromptStatus.NOT_VERIFYING)
this._authPrompt.reset();
}
},
}
_updateCancelButton() {
let cancelVisible;
@ -757,7 +754,7 @@ var LoginDialog = new Lang.Class({
cancelVisible = true;
this._authPrompt.cancelButton.visible = cancelVisible;
},
}
_updateBanner() {
let enabled = this._settings.get_boolean(GdmUtil.BANNER_MESSAGE_KEY);
@ -769,7 +766,7 @@ var LoginDialog = new Lang.Class({
} else {
this._bannerLabel.hide();
}
},
}
_fadeInBannerView() {
this._bannerView.show();
@ -777,13 +774,13 @@ var LoginDialog = new Lang.Class({
{ opacity: 255,
time: _FADE_ANIMATION_TIME,
transition: 'easeOutQuad' });
},
}
_hideBannerView() {
Tweener.removeTweens(this._bannerView);
this._bannerView.opacity = 0;
this._bannerView.hide();
},
}
_updateLogoTexture(cache, file) {
if (this._logoFile && !this._logoFile.equal(file))
@ -796,14 +793,14 @@ var LoginDialog = new Lang.Class({
-1, _LOGO_ICON_HEIGHT,
scaleFactor));
}
},
}
_updateLogo() {
let path = this._settings.get_string(GdmUtil.LOGO_KEY);
this._logoFile = path ? Gio.file_new_for_path(path) : null;
this._updateLogoTexture(this._textureCache, this._logoFile);
},
}
_onPrompted() {
if (this._shouldShowSessionMenuButton()) {
@ -813,7 +810,7 @@ var LoginDialog = new Lang.Class({
this._sessionMenuButton.updateSensitivity(false);
}
this._showPrompt();
},
}
_resetGreeterProxy() {
if (GLib.getenv('GDM_GREETER_TEST') != '1') {
@ -829,7 +826,7 @@ var LoginDialog = new Lang.Class({
this._timedLoginRequestedId = this._greeter.connect('timed-login-requested',
this._onTimedLoginRequested.bind(this));
}
},
}
_onReset(authPrompt, beginRequest) {
this._resetGreeterProxy();
@ -850,11 +847,11 @@ var LoginDialog = new Lang.Class({
} else {
this._hideUserListAndBeginVerification();
}
},
}
_onDefaultSessionChanged(client, sessionId) {
this._sessionMenuButton.setActiveSession(sessionId);
},
}
_shouldShowSessionMenuButton() {
if (this._authPrompt.verificationStatus != AuthPrompt.AuthPromptStatus.VERIFYING &&
@ -865,7 +862,7 @@ var LoginDialog = new Lang.Class({
return false;
return true;
},
}
_showPrompt() {
if (this._authPrompt.actor.visible)
@ -877,7 +874,7 @@ var LoginDialog = new Lang.Class({
time: _FADE_ANIMATION_TIME,
transition: 'easeOutQuad' });
this._fadeInBannerView();
},
}
_showRealmLoginHint(realmManager, hint) {
if (!hint)
@ -890,7 +887,7 @@ var LoginDialog = new Lang.Class({
// Translators: this message is shown below the username entry field
// to clue the user in on how to login to the local network realm
this._authPrompt.setMessage(_("(e.g., user or %s)").format(hint), GdmUtil.MessageType.HINT);
},
}
_askForUsernameAndBeginVerification() {
this._authPrompt.setPasswordChar('');
@ -917,7 +914,7 @@ var LoginDialog = new Lang.Class({
this._sessionMenuButton.updateSensitivity(false);
this._authPrompt.updateSensitivity(true);
this._showPrompt();
},
}
_loginScreenSessionActivated() {
if (this.opacity == 255 && this._authPrompt.verificationStatus == AuthPrompt.AuthPromptStatus.NOT_VERIFYING)
@ -941,7 +938,7 @@ var LoginDialog = new Lang.Class({
this._authPrompt.reset();
},
onCompleteScope: this });
},
}
_gotGreeterSessionProxy(proxy) {
this._greeterSessionProxy = proxy;
@ -950,7 +947,7 @@ var LoginDialog = new Lang.Class({
if (proxy.Active)
this._loginScreenSessionActivated();
});
},
}
_startSession(serviceName) {
Tweener.addTween(this,
@ -970,11 +967,11 @@ var LoginDialog = new Lang.Class({
this._greeter.call_start_session_when_ready_sync(serviceName, true, null);
},
onCompleteScope: this });
},
}
_onSessionOpened(client, serviceName) {
this._authPrompt.finish(() => { this._startSession(serviceName); });
},
}
_waitForItemForUser(userName) {
let item = this._userList.getItemFromUserName(userName);
@ -994,7 +991,7 @@ var LoginDialog = new Lang.Class({
hold.connect('release', () => { this._userList.disconnect(signalId); });
return hold;
},
}
_blockTimedLoginUntilIdle() {
let hold = new Batch.Hold();
@ -1007,7 +1004,7 @@ var LoginDialog = new Lang.Class({
});
GLib.Source.set_name_by_id(this._timedLoginIdleTimeOutId, '[gnome-shell] this._timedLoginIdleTimeOutId');
return hold;
},
}
_startTimedLogin(userName, delay) {
let firstRun = true;
@ -1080,7 +1077,7 @@ var LoginDialog = new Lang.Class({
this._timedLoginBatch = new Batch.ConsecutiveBatch(this, tasks);
return this._timedLoginBatch.run();
},
}
_onTimedLoginRequested(client, userName, seconds) {
if (this._timedLoginBatch)
@ -1097,28 +1094,28 @@ var LoginDialog = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
});
},
}
_setUserListExpanded(expanded) {
this._userList.updateStyle(expanded);
this._userSelectionBox.visible = expanded;
},
}
_hideUserList() {
this._setUserListExpanded(false);
if (this._userSelectionBox.visible)
GdmUtil.cloneAndFadeOutActor(this._userSelectionBox);
},
}
_hideUserListAskForUsernameAndBeginVerification() {
this._hideUserList();
this._askForUsernameAndBeginVerification();
},
}
_hideUserListAndBeginVerification() {
this._hideUserList();
this._authPrompt.begin();
},
}
_showUserList() {
this._ensureUserListLoaded();
@ -1128,7 +1125,7 @@ var LoginDialog = new Lang.Class({
this._setUserListExpanded(true);
this._notListedButton.show();
this._userList.actor.grab_key_focus();
},
}
_beginVerificationForItem(item) {
this._authPrompt.setUser(item.user);
@ -1139,7 +1136,7 @@ var LoginDialog = new Lang.Class({
this._authPrompt.begin({ userName: userName,
hold: hold });
return hold;
},
}
_onUserListActivated(activatedItem) {
this._user = activatedItem.user;
@ -1149,7 +1146,7 @@ var LoginDialog = new Lang.Class({
let batch = new Batch.ConcurrentBatch(this, [GdmUtil.cloneAndFadeOutActor(this._userSelectionBox),
this._beginVerificationForItem(activatedItem)]);
batch.run();
},
}
_onDestroy() {
if (this._userManagerLoadedId) {
@ -1190,7 +1187,7 @@ var LoginDialog = new Lang.Class({
this._realmManager.release();
this._realmManager = null;
}
},
}
_loadUserList() {
if (this._userListLoaded)
@ -1228,7 +1225,7 @@ var LoginDialog = new Lang.Class({
});
return GLib.SOURCE_REMOVE;
},
}
open() {
Main.ctrlAltTabManager.addGroup(this,
@ -1247,22 +1244,22 @@ var LoginDialog = new Lang.Class({
transition: 'easeInQuad' });
return true;
},
}
close() {
Main.popModal(this);
Main.ctrlAltTabManager.removeGroup(this);
},
}
cancel() {
this._authPrompt.cancel();
},
}
addCharacter(unichar) {
// Don't allow type ahead at the login screen
},
}
finish(onComplete) {
this._authPrompt.finish(onComplete);
},
}
});