mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
cleanup: Use Function.prototype.bind()
When not using arrow notation with anonymous functions, we use Lang.bind() to bind `this` to named callbacks. However since ES5, this functionality is already provided by Function.prototype.bind() - in fact, Lang.bind() itself uses it when no extra arguments are specified. Just use the built-in function directly where possible, and use arrow notation in the few places where we pass additional arguments. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
This commit is contained in:
parent
213e38c2ef
commit
3b1330880f
100 changed files with 1021 additions and 999 deletions
|
|
@ -55,13 +55,13 @@ var AuthPrompt = new Lang.Class({
|
|||
|
||||
this._userVerifier = new GdmUtil.ShellUserVerifier(this._gdmClient, { reauthenticationOnly: reauthenticationOnly });
|
||||
|
||||
this._userVerifier.connect('ask-question', Lang.bind(this, this._onAskQuestion));
|
||||
this._userVerifier.connect('show-message', Lang.bind(this, this._onShowMessage));
|
||||
this._userVerifier.connect('verification-failed', Lang.bind(this, this._onVerificationFailed));
|
||||
this._userVerifier.connect('verification-complete', Lang.bind(this, this._onVerificationComplete));
|
||||
this._userVerifier.connect('reset', Lang.bind(this, this._onReset));
|
||||
this._userVerifier.connect('smartcard-status-changed', Lang.bind(this, this._onSmartcardStatusChanged));
|
||||
this._userVerifier.connect('ovirt-user-authenticated', Lang.bind(this, this._onOVirtUserAuthenticated));
|
||||
this._userVerifier.connect('ask-question', this._onAskQuestion.bind(this));
|
||||
this._userVerifier.connect('show-message', this._onShowMessage.bind(this));
|
||||
this._userVerifier.connect('verification-failed', this._onVerificationFailed.bind(this));
|
||||
this._userVerifier.connect('verification-complete', this._onVerificationComplete.bind(this));
|
||||
this._userVerifier.connect('reset', this._onReset.bind(this));
|
||||
this._userVerifier.connect('smartcard-status-changed', this._onSmartcardStatusChanged.bind(this));
|
||||
this._userVerifier.connect('ovirt-user-authenticated', this._onOVirtUserAuthenticated.bind(this));
|
||||
this.smartcardDetected = this._userVerifier.smartcardDetected;
|
||||
|
||||
this.connect('next', () => {
|
||||
|
|
@ -76,7 +76,7 @@ var AuthPrompt = new Lang.Class({
|
|||
|
||||
this.actor = new St.BoxLayout({ style_class: 'login-dialog-prompt-layout',
|
||||
vertical: true });
|
||||
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
||||
this.actor.connect('destroy', this._onDestroy.bind(this));
|
||||
this.actor.connect('key-press-event', (actor, event) => {
|
||||
if (event.get_key_symbol() == Clutter.KEY_Escape)
|
||||
this.cancel();
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ var UserListItem = new Lang.Class({
|
|||
_init(user) {
|
||||
this.user = user;
|
||||
this._userChangedId = this.user.connect('changed',
|
||||
Lang.bind(this, this._onUserChanged));
|
||||
this._onUserChanged.bind(this));
|
||||
|
||||
let layout = new St.BoxLayout({ vertical: true });
|
||||
this.actor = new St.Button({ style_class: 'login-dialog-user-list-item',
|
||||
|
|
@ -67,8 +67,7 @@ var UserListItem = new Lang.Class({
|
|||
reactive: true,
|
||||
x_align: St.Align.START,
|
||||
x_fill: true });
|
||||
this.actor.connect('destroy',
|
||||
Lang.bind(this, this._onDestroy));
|
||||
this.actor.connect('destroy', this._onDestroy.bind(this));
|
||||
|
||||
this.actor.connect('key-focus-in', () => {
|
||||
this._setSelected(true);
|
||||
|
|
@ -90,7 +89,7 @@ var UserListItem = new Lang.Class({
|
|||
scale_x: 0 });
|
||||
layout.add(this._timedLoginIndicator);
|
||||
|
||||
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
|
||||
this.actor.connect('clicked', this._onClicked.bind(this));
|
||||
this._onUserChanged();
|
||||
},
|
||||
|
||||
|
|
@ -173,7 +172,7 @@ var UserList = new Lang.Class({
|
|||
this.actor.add_actor(this._box);
|
||||
this._items = {};
|
||||
|
||||
this.actor.connect('key-focus-in', Lang.bind(this, this._moveFocusToItems));
|
||||
this.actor.connect('key-focus-in', this._moveFocusToItems.bind(this));
|
||||
},
|
||||
|
||||
_moveFocusToItems() {
|
||||
|
|
@ -270,8 +269,7 @@ var UserList = new Lang.Class({
|
|||
|
||||
this._items[userName] = item;
|
||||
|
||||
item.connect('activate',
|
||||
Lang.bind(this, this._onItemActivated));
|
||||
item.connect('activate', this._onItemActivated.bind(this));
|
||||
|
||||
// Try to keep the focused item front-and-center
|
||||
item.actor.connect('key-focus-in', () => { this.scrollToItem(item); });
|
||||
|
|
@ -413,8 +411,8 @@ var LoginDialog = new Lang.Class({
|
|||
this.actor.get_accessible().set_role(Atk.Role.WINDOW);
|
||||
|
||||
this.actor.add_constraint(new Layout.MonitorConstraint({ primary: true }));
|
||||
this.actor.connect('allocate', Lang.bind(this, this._onAllocate));
|
||||
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
||||
this.actor.connect('allocate', this._onAllocate.bind(this));
|
||||
this.actor.connect('destroy', this._onDestroy.bind(this));
|
||||
parentActor.add_child(this.actor);
|
||||
|
||||
this._userManager = AccountsService.UserManager.get_default()
|
||||
|
|
@ -423,17 +421,17 @@ var LoginDialog = new Lang.Class({
|
|||
this._settings = new Gio.Settings({ schema_id: GdmUtil.LOGIN_SCREEN_SCHEMA });
|
||||
|
||||
this._settings.connect('changed::' + GdmUtil.BANNER_MESSAGE_KEY,
|
||||
Lang.bind(this, this._updateBanner));
|
||||
this._updateBanner.bind(this));
|
||||
this._settings.connect('changed::' + GdmUtil.BANNER_MESSAGE_TEXT_KEY,
|
||||
Lang.bind(this, this._updateBanner));
|
||||
this._updateBanner.bind(this));
|
||||
this._settings.connect('changed::' + GdmUtil.DISABLE_USER_LIST_KEY,
|
||||
Lang.bind(this, this._updateDisableUserList));
|
||||
this._updateDisableUserList.bind(this));
|
||||
this._settings.connect('changed::' + GdmUtil.LOGO_KEY,
|
||||
Lang.bind(this, this._updateLogo));
|
||||
this._updateLogo.bind(this));
|
||||
|
||||
this._textureCache = St.TextureCache.get_default();
|
||||
this._updateLogoTextureId = this._textureCache.connect('texture-file-changed',
|
||||
Lang.bind(this, this._updateLogoTexture));
|
||||
this._updateLogoTexture.bind(this));
|
||||
|
||||
this._userSelectionBox = new St.BoxLayout({ style_class: 'login-dialog-user-selection-box',
|
||||
x_align: Clutter.ActorAlign.CENTER,
|
||||
|
|
@ -449,8 +447,8 @@ var LoginDialog = new Lang.Class({
|
|||
y_fill: true });
|
||||
|
||||
this._authPrompt = new AuthPrompt.AuthPrompt(this._gdmClient, AuthPrompt.AuthPromptMode.UNLOCK_OR_LOG_IN);
|
||||
this._authPrompt.connect('prompted', Lang.bind(this, this._onPrompted));
|
||||
this._authPrompt.connect('reset', Lang.bind(this, this._onReset));
|
||||
this._authPrompt.connect('prompted', this._onPrompted.bind(this));
|
||||
this._authPrompt.connect('reset', this._onReset.bind(this));
|
||||
this._authPrompt.hide();
|
||||
this.actor.add_child(this._authPrompt.actor);
|
||||
|
||||
|
|
@ -467,7 +465,7 @@ var LoginDialog = new Lang.Class({
|
|||
x_align: St.Align.START,
|
||||
x_fill: true });
|
||||
|
||||
this._notListedButton.connect('clicked', Lang.bind(this, this._hideUserListAskForUsernameAndBeginVerification));
|
||||
this._notListedButton.connect('clicked', this._hideUserListAskForUsernameAndBeginVerification.bind(this));
|
||||
|
||||
this._notListedButton.hide();
|
||||
|
||||
|
|
@ -517,15 +515,15 @@ var LoginDialog = new Lang.Class({
|
|||
|
||||
this._realmManager = new Realmd.Manager();
|
||||
this._realmSignalId = this._realmManager.connect('login-format-changed',
|
||||
Lang.bind(this, this._showRealmLoginHint));
|
||||
this._showRealmLoginHint.bind(this));
|
||||
|
||||
LoginManager.getLoginManager().getCurrentSessionProxy(Lang.bind(this, this._gotGreeterSessionProxy));
|
||||
LoginManager.getLoginManager().getCurrentSessionProxy(this._gotGreeterSessionProxy.bind(this));
|
||||
|
||||
// If the user list is enabled, it should take key focus; make sure the
|
||||
// screen shield is initialized first to prevent it from stealing the
|
||||
// focus later
|
||||
this._startupCompleteId = Main.layoutManager.connect('startup-complete',
|
||||
Lang.bind(this, this._updateDisableUserList));
|
||||
this._updateDisableUserList.bind(this));
|
||||
},
|
||||
|
||||
_getBannerAllocation(dialogBox) {
|
||||
|
|
@ -723,7 +721,7 @@ var LoginDialog = new Lang.Class({
|
|||
}
|
||||
});
|
||||
} else {
|
||||
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this, this._loadUserList));
|
||||
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, this._loadUserList.bind(this));
|
||||
GLib.Source.set_name_by_id(id, '[gnome-shell] _loadUserList');
|
||||
}
|
||||
},
|
||||
|
|
@ -820,11 +818,11 @@ var LoginDialog = new Lang.Class({
|
|||
this._greeter = this._gdmClient.get_greeter_sync(null);
|
||||
|
||||
this._defaultSessionChangedId = this._greeter.connect('default-session-name-changed',
|
||||
Lang.bind(this, this._onDefaultSessionChanged));
|
||||
this._onDefaultSessionChanged.bind(this));
|
||||
this._sessionOpenedId = this._greeter.connect('session-opened',
|
||||
Lang.bind(this, this._onSessionOpened));
|
||||
this._onSessionOpened.bind(this));
|
||||
this._timedLoginRequestedId = this._greeter.connect('timed-login-requested',
|
||||
Lang.bind(this, this._onTimedLoginRequested));
|
||||
this._onTimedLoginRequested.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ var OVirtCredentialsManager = new Lang.Class({
|
|||
|
||||
this._credentials = new OVirtCredentials();
|
||||
this._credentials.connectSignal('UserAuthenticated',
|
||||
Lang.bind(this, this._onUserAuthenticated));
|
||||
this._onUserAuthenticated.bind(this));
|
||||
},
|
||||
|
||||
_onUserAuthenticated(proxy, sender, [token]) {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ var Manager = new Lang.Class({
|
|||
this._aggregateProvider = Provider(Gio.DBus.system,
|
||||
'org.freedesktop.realmd',
|
||||
'/org/freedesktop/realmd',
|
||||
Lang.bind(this, this._reloadRealms))
|
||||
this._reloadRealms.bind(this))
|
||||
this._realms = {};
|
||||
|
||||
this._signalId = this._aggregateProvider.connect('g-properties-changed',
|
||||
|
|
@ -86,7 +86,7 @@ var Manager = new Lang.Class({
|
|||
let realm = Realm(Gio.DBus.system,
|
||||
'org.freedesktop.realmd',
|
||||
realmPaths[i],
|
||||
Lang.bind(this, this._onRealmLoaded));
|
||||
this._onRealmLoaded.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ var ShellUserVerifier = new Lang.Class({
|
|||
|
||||
this._settings = new Gio.Settings({ schema_id: LOGIN_SCREEN_SCHEMA });
|
||||
this._settings.connect('changed',
|
||||
Lang.bind(this, this._updateDefaultService));
|
||||
this._updateDefaultService.bind(this));
|
||||
this._updateDefaultService();
|
||||
|
||||
this._fprintManager = Fprint.FprintManager();
|
||||
|
|
@ -147,9 +147,9 @@ var ShellUserVerifier = new Lang.Class({
|
|||
this._checkForSmartcard();
|
||||
|
||||
this._smartcardInsertedId = this._smartcardManager.connect('smartcard-inserted',
|
||||
Lang.bind(this, this._checkForSmartcard));
|
||||
this._checkForSmartcard.bind(this));
|
||||
this._smartcardRemovedId = this._smartcardManager.connect('smartcard-removed',
|
||||
Lang.bind(this, this._checkForSmartcard));
|
||||
this._checkForSmartcard.bind(this));
|
||||
|
||||
this._messageQueue = [];
|
||||
this._messageQueueTimeoutId = 0;
|
||||
|
|
@ -164,7 +164,7 @@ var ShellUserVerifier = new Lang.Class({
|
|||
this._oVirtUserAuthenticated(this._oVirtCredentialsManager.getToken());
|
||||
|
||||
this._oVirtUserAuthenticatedId = this._oVirtCredentialsManager.connect('user-authenticated',
|
||||
Lang.bind(this, this._oVirtUserAuthenticated));
|
||||
this._oVirtUserAuthenticated.bind(this));
|
||||
},
|
||||
|
||||
begin(userName, hold) {
|
||||
|
|
@ -179,9 +179,9 @@ var ShellUserVerifier = new Lang.Class({
|
|||
// If possible, reauthenticate an already running session,
|
||||
// so any session specific credentials get updated appropriately
|
||||
this._client.open_reauthentication_channel(userName, this._cancellable,
|
||||
Lang.bind(this, this._reauthenticationChannelOpened));
|
||||
this._reauthenticationChannelOpened.bind(this));
|
||||
} else {
|
||||
this._client.get_user_verifier(this._cancellable, Lang.bind(this, this._userVerifierGot));
|
||||
this._client.get_user_verifier(this._cancellable, this._userVerifierGot.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -357,7 +357,7 @@ var ShellUserVerifier = new Lang.Class({
|
|||
// Gdm emits org.freedesktop.DBus.Error.AccessDenied when there is
|
||||
// no session to reauthenticate. Fall back to performing verification
|
||||
// from this login session
|
||||
client.get_user_verifier(this._cancellable, Lang.bind(this, this._userVerifierGot));
|
||||
client.get_user_verifier(this._cancellable, this._userVerifierGot.bind(this));
|
||||
return;
|
||||
} catch(e) {
|
||||
this._reportInitError('Failed to open reauthentication channel', e);
|
||||
|
|
@ -387,13 +387,13 @@ var ShellUserVerifier = new Lang.Class({
|
|||
},
|
||||
|
||||
_connectSignals() {
|
||||
this._userVerifier.connect('info', Lang.bind(this, this._onInfo));
|
||||
this._userVerifier.connect('problem', Lang.bind(this, this._onProblem));
|
||||
this._userVerifier.connect('info-query', Lang.bind(this, this._onInfoQuery));
|
||||
this._userVerifier.connect('secret-info-query', Lang.bind(this, this._onSecretInfoQuery));
|
||||
this._userVerifier.connect('conversation-stopped', Lang.bind(this, this._onConversationStopped));
|
||||
this._userVerifier.connect('reset', Lang.bind(this, this._onReset));
|
||||
this._userVerifier.connect('verification-complete', Lang.bind(this, this._onVerificationComplete));
|
||||
this._userVerifier.connect('info', this._onInfo.bind(this));
|
||||
this._userVerifier.connect('problem', this._onProblem.bind(this));
|
||||
this._userVerifier.connect('info-query', this._onInfoQuery.bind(this));
|
||||
this._userVerifier.connect('secret-info-query', this._onSecretInfoQuery.bind(this));
|
||||
this._userVerifier.connect('conversation-stopped', this._onConversationStopped.bind(this));
|
||||
this._userVerifier.connect('reset', this._onReset.bind(this));
|
||||
this._userVerifier.connect('verification-complete', this._onVerificationComplete.bind(this));
|
||||
},
|
||||
|
||||
_getForegroundService() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue