[polari/wip/fmuellner/cleanups] cleanup: Get rid of Lang.bind()
- From: Gitlab Administrative User <gitlab src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/cleanups] cleanup: Get rid of Lang.bind()
- Date: Fri, 10 Nov 2017 19:02:01 +0000 (UTC)
commit e2f6f6b467254aea561dc2ff43fc2c833cf50485
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Nov 10 19:01:11 2017 +0100
cleanup: Get rid of Lang.bind()
After replacing Lang.Class with ES6 classes and adopting arrow notation
for anonymous callbacks, we only use the Lang module 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.
src/accountsMonitor.js | 14 ++++-------
src/appNotifications.js | 11 ++++-----
src/application.js | 35 ++++++++++++++--------------
src/chatView.js | 60 ++++++++++++++++++++++--------------------------
src/connections.js | 24 +++++++++----------
src/emojiPicker.js | 3 +--
src/entryArea.js | 31 ++++++++++++-------------
src/initialSetup.js | 5 ++--
src/joinDialog.js | 9 ++++----
src/mainWindow.js | 23 +++++++++----------
src/pasteManager.js | 14 +++++------
src/polari-accounts.in | 6 ++---
src/roomList.js | 33 ++++++++++++--------------
src/roomManager.js | 7 +++---
src/roomStack.js | 13 ++++-------
src/serverRoomManager.js | 12 ++++------
src/tabCompletion.js | 15 ++++++------
src/telepathyClient.js | 41 ++++++++++++++++-----------------
src/userList.js | 57 ++++++++++++++++++++++-----------------------
src/userTracker.js | 25 ++++++++++----------
20 files changed, 203 insertions(+), 235 deletions(-)
---
diff --git a/src/accountsMonitor.js b/src/accountsMonitor.js
index c303f15..1ae5900 100644
--- a/src/accountsMonitor.js
+++ b/src/accountsMonitor.js
@@ -1,5 +1,4 @@
const Gio = imports.gi.Gio;
-const Lang = imports.lang;
const Signals = imports.signals;
const Tp = imports.gi.TelepathyGLib;
@@ -16,7 +15,7 @@ var AccountsMonitor = class {
this._app = Gio.Application.get_default();
this._app.connect('prepare-shutdown',
- Lang.bind(this, this._onPrepareShutdown));
+ this._onPrepareShutdown.bind(this));
this._accountManager = Tp.AccountManager.dup();
@@ -26,8 +25,7 @@ var AccountsMonitor = class {
factory.add_contact_features([Tp.ContactFeature.ALIAS]);
this._preparedCallbacks = [];
- this._accountManager.prepare_async(null,
- Lang.bind(this, this._onPrepared));
+ this._accountManager.prepare_async(null, this._onPrepared.bind(this));
}
get accounts() {
@@ -75,7 +73,7 @@ var AccountsMonitor = class {
return; // no point in carrying on
}
- am.dup_valid_accounts().forEach(Lang.bind(this, this._addAccount));
+ am.dup_valid_accounts().forEach(this._addAccount.bind(this));
am.connect('account-validity-changed', (am, account, valid) => {
if (valid)
@@ -86,10 +84,8 @@ var AccountsMonitor = class {
am.connect('account-removed', (am, account) => {
this._removeAccount(account);
});
- am.connect('account-enabled',
- Lang.bind(this, this._accountEnabledChanged));
- am.connect('account-disabled',
- Lang.bind(this, this._accountEnabledChanged));
+ am.connect('account-enabled', this._accountEnabledChanged.bind(this));
+ am.connect('account-disabled', this._accountEnabledChanged.bind(this));
this._preparedCallbacks.forEach(callback => { callback(); });
}
diff --git a/src/appNotifications.js b/src/appNotifications.js
index 264df72..9c57cfa 100644
--- a/src/appNotifications.js
+++ b/src/appNotifications.js
@@ -1,6 +1,5 @@
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Pango = imports.gi.Pango;
@@ -16,7 +15,7 @@ class AppNotification extends Gtk.Revealer {
super._init({ reveal_child: true,
transition_type: Gtk.RevealerTransitionType.SLIDE_DOWN });
this.connect('notify::child-revealed',
- Lang.bind(this, this._onChildRevealed));
+ this._onChildRevealed.bind(this));
}
close() {
@@ -34,7 +33,7 @@ class MessageNotification extends AppNotification {
_init(label, iconName) {
super._init();
- Mainloop.timeout_add_seconds(TIMEOUT, Lang.bind(this, this.close));
+ Mainloop.timeout_add_seconds(TIMEOUT, this.close.bind(this));
this._box = new Gtk.Box({ spacing: 12 });
@@ -46,7 +45,7 @@ class MessageNotification extends AppNotification {
let closeButton = new Gtk.Button({ relief: Gtk.ReliefStyle.NONE });
closeButton.image = new Gtk.Image({ icon_name: 'window-close-symbolic' });
- closeButton.connect('clicked', Lang.bind(this, this.close));
+ closeButton.connect('clicked', this.close.bind(this));
this._box.pack_end(closeButton, false, false, 0);
this.add(this._box);
@@ -100,7 +99,7 @@ class CommandOutputNotification extends AppNotification {
this.transition_type = Gtk.RevealerTransitionType.SLIDE_UP;
Mainloop.timeout_add_seconds(COMMAND_OUTPUT_REVEAL_TIME,
- Lang.bind(this, this.close));
+ this.close.bind(this));
}
});
@@ -165,7 +164,7 @@ class NotificationQueue extends Gtk.Frame {
addNotification(notification) {
this._grid.add(notification);
- notification.connect('destroy', Lang.bind(this, this._onChildDestroy));
+ notification.connect('destroy', this._onChildDestroy.bind(this));
this.show();
}
diff --git a/src/application.js b/src/application.js
index 090766a..8b276c5 100644
--- a/src/application.js
+++ b/src/application.js
@@ -3,7 +3,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 Polari = imports.gi.Polari;
const Tp = imports.gi.TelepathyGLib;
@@ -151,38 +150,38 @@ var Application = GObject.registerClass({
let actionEntries = [
{ name: 'show-join-dialog',
- activate: Lang.bind(this, this._onShowJoinDialog),
+ activate: this._onShowJoinDialog.bind(this),
accels: ['<Primary>n'] },
{ name: 'join-room',
- activate: Lang.bind(this, this._onJoinRoom),
+ activate: this._onJoinRoom.bind(this),
parameter_type: GLib.VariantType.new('(ssu)') },
{ name: 'message-user',
- activate: Lang.bind(this, this._onMessageUser),
+ activate: this._onMessageUser.bind(this),
parameter_type: GLib.VariantType.new('(sssu)') },
{ name: 'leave-room',
parameter_type: GLib.VariantType.new('(ss)') },
{ name: 'leave-current-room',
- activate: Lang.bind(this, this._onLeaveCurrentRoom),
+ activate: this._onLeaveCurrentRoom.bind(this),
create_hook: (a) => { a.enabled = false; },
accels: ['<Primary>w'] },
{ name: 'authenticate-account',
parameter_type: GLib.VariantType.new('(os)') },
{ name: 'connect-account',
- activate: Lang.bind(this, this._onConnectAccount),
+ activate: this._onConnectAccount.bind(this),
parameter_type: GLib.VariantType.new('o') },
{ name: 'reconnect-account',
- activate: Lang.bind(this, this._onConnectAccount),
+ activate: this._onConnectAccount.bind(this),
parameter_type: GLib.VariantType.new('o') },
{ name: 'user-list',
- activate: Lang.bind(this, this._onToggleAction),
- create_hook: Lang.bind(this, this._userListCreateHook),
+ activate: this._onToggleAction.bind(this),
+ create_hook: this._userListCreateHook.bind(this),
state: GLib.Variant.new('b', false),
accels: ['F9', '<Primary>u'] },
{ name: 'remove-connection',
- activate: Lang.bind(this, this._onRemoveConnection),
+ activate: this._onRemoveConnection.bind(this),
parameter_type: GLib.VariantType.new('o') },
{ name: 'edit-connection',
- activate: Lang.bind(this, this._onEditConnection),
+ activate: this._onEditConnection.bind(this),
parameter_type: GLib.VariantType.new('o') },
{ name: 'save-identify-password',
parameter_type: GLib.VariantType.new('o') },
@@ -191,14 +190,14 @@ var Application = GObject.registerClass({
{ name: 'show-emoji-picker',
accels: ['<Primary>e'] },
{ name: 'start-client',
- activate: Lang.bind(this, this._onStartClient) },
+ activate: this._onStartClient.bind(this) },
{ name: 'help',
- activate: Lang.bind(this, this._onShowHelp),
+ activate: this._onShowHelp.bind(this),
accels: ['F1'] },
{ name: 'about',
- activate: Lang.bind(this, this._onShowAbout) },
+ activate: this._onShowAbout.bind(this) },
{ name: 'quit',
- activate: Lang.bind(this, this._onQuit),
+ activate: this._onQuit.bind(this),
accels: ['<Primary>q'] },
{ name: 'next-room',
accels: ['<Primary>Page_Down', '<Alt>Down'] },
@@ -239,7 +238,7 @@ var Application = GObject.registerClass({
this.add_action(action);
this._settings.connect('changed::run-in-background',
- Lang.bind(this, this._onRunInBackgroundChanged));
+ this._onRunInBackgroundChanged.bind(this));
this._onRunInBackgroundChanged();
for (let i = 1; i < 10; i++)
@@ -254,7 +253,7 @@ var Application = GObject.registerClass({
this._serverRoomManager = ServerRoomManager.getDefault();
this._accountsMonitor.connect('account-status-changed',
- Lang.bind(this, this._onAccountStatusChanged));
+ this._onAccountStatusChanged.bind(this));
this._accountsMonitor.connect('account-added', (am, account) => {
// Reset nickname at startup
let accountName = this._getTrimmedAccountName(account);
@@ -321,7 +320,7 @@ var Application = GObject.registerClass({
action.enabled = window.active_room != null;
window.connect('active-room-state-changed',
- Lang.bind(this, this._updateUserListAction));
+ this._updateUserListAction.bind(this));
this._updateUserListAction();
}
diff --git a/src/chatView.js b/src/chatView.js
index 5c43968..e50bc21 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -3,7 +3,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 Mainloop = imports.mainloop;
const Pango = imports.gi.Pango;
const PangoCairo = imports.gi.PangoCairo;
@@ -51,8 +50,8 @@ class TextView extends Gtk.TextView {
_init(params) {
super._init(params);
- this.buffer.connect('mark-set', Lang.bind(this, this._onMarkSet));
- this.connect('screen-changed', Lang.bind(this, this._updateLayout));
+ this.buffer.connect('mark-set', this._onMarkSet.bind(this));
+ this.connect('screen-changed', this._updateLayout.bind(this));
}
vfunc_get_preferred_width() {
@@ -310,36 +309,33 @@ var ChatView = GObject.registerClass({
this._createTags();
- this.connect('style-updated',
- Lang.bind(this, this._onStyleUpdated));
+ this.connect('style-updated', this._onStyleUpdated.bind(this));
this._onStyleUpdated();
- this.connect('destroy', Lang.bind(this, this._onDestroy));
- this.connect('screen-changed',
- Lang.bind(this, this._updateIndent));
- this.connect('scroll-event', Lang.bind(this, this._onScroll));
+ this.connect('destroy', this._onDestroy.bind(this));
+ this.connect('screen-changed', this._updateIndent.bind(this));
+ this.connect('scroll-event', this._onScroll.bind(this));
this.connect('edge-reached', (w, pos) => {
if (pos == Gtk.PositionType.BOTTOM)
this._autoscroll = true;
});
this.vadjustment.connect('value-changed',
- Lang.bind(this, this._onValueChanged));
- this.vadjustment.connect('changed',
- Lang.bind(this, this._updateScroll));
+ this._onValueChanged.bind(this));
+ this.vadjustment.connect('changed', this._updateScroll.bind(this));
- this._view.connect('key-press-event', Lang.bind(this, this._onKeyPress));
+ this._view.connect('key-press-event', this._onKeyPress.bind(this));
this._view.connect('motion-notify-event',
- Lang.bind(this, this._handleButtonTagsHover));
+ this._handleButtonTagsHover.bind(this));
this._view.connect('enter-notify-event',
- Lang.bind(this, this._handleButtonTagsHover));
+ this._handleButtonTagsHover.bind(this));
this._view.connect('leave-notify-event',
- Lang.bind(this, this._handleButtonTagsHover));
+ this._handleButtonTagsHover.bind(this));
/* pick up DPI changes (e.g. via the 'text-scaling-factor' setting):
the default handler calls pango_cairo_context_set_resolution(), so
update the indent after that */
this._view.connect_after('style-updated',
- Lang.bind(this, this._updateIndent));
+ this._updateIndent.bind(this));
this._room = room;
this._state = { lastNick: null, lastTimestamp: 0, lastStatusGroup: 0 };
@@ -372,7 +368,7 @@ var ChatView = GObject.registerClass({
this._fetchingBacklog = true;
this._logWalker.get_events_async(NUM_INITIAL_LOG_EVENTS,
- Lang.bind(this, this._onLogEventsReady));
+ this._onLogEventsReady.bind(this));
this._autoscroll = true;
@@ -380,7 +376,7 @@ var ChatView = GObject.registerClass({
DropTargetIface.addTargets(this, this._view);
this._app.connect('room-focus-changed',
- Lang.bind(this, this._checkMessages));
+ this._checkMessages.bind(this));
this._hoverCursor = Gdk.Cursor.new_from_name(this.get_display(),
'pointer');
@@ -390,19 +386,19 @@ var ChatView = GObject.registerClass({
let roomSignals = [
{ name: 'notify::channel',
- handler: Lang.bind(this, this._onChannelChanged) },
+ handler: this._onChannelChanged.bind(this) },
{ name: 'member-renamed',
- handler: Lang.bind(this, this._onMemberRenamed) },
+ handler: this._onMemberRenamed.bind(this) },
{ name: 'member-disconnected',
- handler: Lang.bind(this, this._onMemberDisconnected) },
+ handler: this._onMemberDisconnected.bind(this) },
{ name: 'member-kicked',
- handler: Lang.bind(this, this._onMemberKicked) },
+ handler: this._onMemberKicked.bind(this) },
{ name: 'member-banned',
- handler: Lang.bind(this, this._onMemberBanned) },
+ handler: this._onMemberBanned.bind(this) },
{ name: 'member-joined',
- handler: Lang.bind(this, this._onMemberJoined) },
+ handler: this._onMemberJoined.bind(this) },
{ name: 'member-left',
- handler: Lang.bind(this, this._onMemberLeft) }
+ handler: this._onMemberLeft.bind(this) }
];
this._roomSignals = [];
roomSignals.forEach(signal => {
@@ -412,7 +408,7 @@ var ChatView = GObject.registerClass({
this._nickStatusChangedId = this._userTracker.watchRoomStatus(this._room,
null,
- Lang.bind(this, this._onNickStatusChanged));
+ this._onNickStatusChanged.bind(this));
this.connect('destroy', () => {
this._userTracker.unwatchRoomStatus(this._room, this._nickStatusChangedId);
@@ -731,7 +727,7 @@ var ChatView = GObject.registerClass({
this._showLoadingIndicator();
this._backlogTimeoutId = Mainloop.timeout_add(500, () => {
this._logWalker.get_events_async(NUM_LOG_EVENTS,
- Lang.bind(this, this._onLogEventsReady));
+ this._onLogEventsReady.bind(this));
this._backlogTimeoutId = 0;
return GLib.SOURCE_REMOVE;
});
@@ -927,11 +923,11 @@ var ChatView = GObject.registerClass({
let channelSignals = [
{ name: 'message-received',
- handler: Lang.bind(this, this._onMessageReceived) },
+ handler: this._onMessageReceived.bind(this) },
{ name: 'message-sent',
- handler: Lang.bind(this, this._onMessageSent) },
+ handler: this._onMessageSent.bind(this) },
{ name: 'pending-message-removed',
- handler: Lang.bind(this, this._pendingMessageRemoved) }
+ handler: this._pendingMessageRemoved.bind(this) }
];
channelSignals.forEach(signal => {
this._channelSignals.push(this._channel.connect(signal.name, signal.handler));
@@ -1244,7 +1240,7 @@ var ChatView = GObject.registerClass({
if (!nickTag) {
nickTag = new ButtonTag({ name: nickTagName });
- nickTag.connect('clicked', Lang.bind(this, this._onNickTagClicked));
+ nickTag.connect('clicked', this._onNickTagClicked.bind(this));
let status = this._userTracker.getNickRoomStatus(message.nick, this._room);
this._updateNickTag(nickTag, status);
diff --git a/src/connections.js b/src/connections.js
index 39b64d9..aecbdd5 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -1,7 +1,6 @@
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
const Tp = imports.gi.TelepathyGLib;
const {AccountsMonitor} = imports.accountsMonitor;
@@ -88,16 +87,15 @@ var ConnectionsList = GObject.registerClass({
this.hscrollbar_policy = Gtk.PolicyType.NEVER;
this._list = new Gtk.ListBox({ visible: true });
- this._list.connect('row-activated',
- Lang.bind(this, this._onRowActivated));
+ this._list.connect('row-activated', this._onRowActivated.bind(this));
this.add(this._list);
this._rows = new Map();
this._filterTerms = [];
- this._list.set_filter_func(Lang.bind(this, this._filterRows));
- this._list.set_header_func(Lang.bind(this, this._updateHeader));
- this._list.set_sort_func(Lang.bind(this, this._sort));
+ this._list.set_filter_func(this._filterRows.bind(this));
+ this._list.set_header_func(this._updateHeader.bind(this));
+ this._list.set_sort_func(this._sort.bind(this));
let placeholder = new Gtk.Box({ halign: Gtk.Align.CENTER,
valign: Gtk.Align.CENTER,
@@ -123,7 +121,7 @@ var ConnectionsList = GObject.registerClass({
this._networksManager = NetworksManager.getDefault();
this._networksManager.connect('changed',
- Lang.bind(this, this._networksChanged));
+ this._networksChanged.bind(this));
this._networksChanged();
}
@@ -273,15 +271,15 @@ var ConnectionDetails = GObject.registerClass({
super._init(params);
this._nameEntry.connect('changed',
- Lang.bind(this, this._onCanConfirmChanged));
+ this._onCanConfirmChanged.bind(this));
this._serverEntry.connect('changed',
- Lang.bind(this, this._onCanConfirmChanged));
+ this._onCanConfirmChanged.bind(this));
this._nickEntry.connect('changed',
- Lang.bind(this, this._onCanConfirmChanged));
+ this._onCanConfirmChanged.bind(this));
this._realnameEntry.connect('changed',
- Lang.bind(this, this._onCanConfirmChanged));
+ this._onCanConfirmChanged.bind(this));
this._sslCheckbox.connect('toggled',
- Lang.bind(this, this._onCanConfirmChanged));
+ this._onCanConfirmChanged.bind(this));
let realnameStore = new Gtk.ListStore();
realnameStore.set_column_types([GObject.TYPE_STRING]);
@@ -501,7 +499,7 @@ var ConnectionProperties = GObject.registerClass({
this.set_default_response(Gtk.ResponseType.OK);
account.connect('notify::connection-status',
- Lang.bind(this, this._syncErrorMessage));
+ this._syncErrorMessage.bind(this));
this._syncErrorMessage(account);
}
diff --git a/src/emojiPicker.js b/src/emojiPicker.js
index 2eb28ba..590161d 100644
--- a/src/emojiPicker.js
+++ b/src/emojiPicker.js
@@ -2,7 +2,6 @@ const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
const modifierBlacklist = [
'child',
@@ -212,7 +211,7 @@ var EmojiPicker = GObject.registerClass({
});
this._adjustment.connect('value-changed',
- Lang.bind(this, this._updateIndicators));
+ this._updateIndicators.bind(this));
this.connect('map', () => {
entry.text = '';
diff --git a/src/entryArea.js b/src/entryArea.js
index df89fcc..5545245 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -5,7 +5,6 @@ const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gspell = imports.gi.Gspell;
const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Tp = imports.gi.TelepathyGLib;
@@ -48,7 +47,7 @@ var ChatEntry = GObject.registerClass({
this._emojiPickedId = 0;
- this.connect('icon-press', Lang.bind(this, this._showEmojiPicker));
+ this.connect('icon-press', this._showEmojiPicker.bind(this));
this.connect('unmap', () => {
if (this._emojiPickedId)
ChatEntry._emojiPicker.disconnect(this._emojiPickedId);
@@ -57,7 +56,7 @@ var ChatEntry = GObject.registerClass({
let app = Gio.Application.get_default();
let action = app.lookup_action('show-emoji-picker');
- action.connect('activate', Lang.bind(this, this._showEmojiPicker));
+ action.connect('activate', this._showEmojiPicker.bind(this));
let buffer = Gspell.EntryBuffer.get_from_gtk_entry_buffer(this.buffer);
buffer.set_spell_checker (ChatEntry._checker);
@@ -112,7 +111,7 @@ var ChatEntry = GObject.registerClass({
if (uris && uris.length)
this.emit('file-pasted', Gio.File.new_for_uri(uris[0]));
else
- clipboard.request_text(Lang.bind(this, this._onTextReceived));
+ clipboard.request_text(this._onTextReceived.bind(this));
});
clipboard.request_image((clipboard, pixbuf) => {
@@ -219,12 +218,12 @@ var EntryArea = GObject.registerClass({
super._init(params);
- this.connect('destroy', Lang.bind(this, this._onDestroy));
- this.connect('notify::sensitive', Lang.bind(this, this._onSensitiveChanged));
+ this.connect('destroy', this._onDestroy.bind(this));
+ this.connect('notify::sensitive', this._onSensitiveChanged.bind(this));
this.connect('realize', () => {
this._toplevel = this.get_toplevel();
this._keyPressId = this._toplevel.connect('key-press-event',
- Lang.bind(this, this._onKeyPressEvent));
+ this._onKeyPressEvent.bind(this));
});
this.connect('map', () => {
this._nickButton.popover = EntryArea._nickPopover;
@@ -280,7 +279,7 @@ var EntryArea = GObject.registerClass({
this.pasteFile(file);
});
- this._chatEntry.connect('changed', Lang.bind(this, this._onEntryChanged));
+ this._chatEntry.connect('changed', this._onEntryChanged.bind(this));
this._chatEntry.connect('activate', () => {
if (this._ircParser.process(this._chatEntry.text)) {
@@ -291,8 +290,8 @@ var EntryArea = GObject.registerClass({
}
});
- this._cancelButton.connect('clicked', Lang.bind(this, this._onCancelClicked));
- this._pasteButton.connect('clicked', Lang.bind(this, this._onPasteClicked));
+ this._cancelButton.connect('clicked', this._onCancelClicked.bind(this));
+ this._pasteButton.connect('clicked', this._onPasteClicked.bind(this));
this._pasteBox.connect_after('key-press-event', (w, event) => {
let [, keyval] = event.get_keyval();
@@ -312,7 +311,7 @@ var EntryArea = GObject.registerClass({
this._completion = new TabCompletion(this._chatEntry);
this._membersChangedId =
this._room.connect('members-changed',
- Lang.bind(this, this._updateCompletions));
+ this._updateCompletions.bind(this));
this._nicknameChangedId =
this._room.account.connect('notify::nickname', () => {
if (!this._room.channel)
@@ -320,11 +319,11 @@ var EntryArea = GObject.registerClass({
});
this._channelChangedId =
this._room.connect('notify::channel',
- Lang.bind(this, this._onChannelChanged));
+ this._onChannelChanged.bind(this));
this._onChannelChanged(this._room);
- this._chatEntry.connect('map', Lang.bind(this, this._updateCompletions));
- this._chatEntry.connect('unmap', Lang.bind(this, this._updateCompletions));
+ this._chatEntry.connect('map', this._updateCompletions.bind(this));
+ this._chatEntry.connect('unmap', this._updateCompletions.bind(this));
}
set max_nick_chars(maxChars) {
@@ -418,7 +417,7 @@ var EntryArea = GObject.registerClass({
file.query_info_async(Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
Gio.FileQueryInfoFlags.NONE,
GLib.PRIORITY_DEFAULT, null,
- Lang.bind(this, this._onFileInfoReady));
+ this._onFileInfoReady.bind(this));
}
_onFileInfoReady(file, res) {
@@ -477,7 +476,7 @@ var EntryArea = GObject.registerClass({
if (room.channel)
this._selfAliasChangedId =
room.channel.connection.connect('notify::self-contact',
- Lang.bind(this, this._updateNick));
+ this._updateNick.bind(this));
else
this._selfAliasChangedId = 0;
this._updateNick();
diff --git a/src/initialSetup.js b/src/initialSetup.js
index 334fa8f..4c103dc 100644
--- a/src/initialSetup.js
+++ b/src/initialSetup.js
@@ -2,7 +2,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 Utils = imports.utils;
@@ -35,7 +34,7 @@ var InitialSetupWindow = GObject.registerClass({
this.connect('destroy', () => { this._unsetAccount(); });
this._serverRoomList.connect('notify::can-join',
- Lang.bind(this, this._updateNextSensitivity));
+ this._updateNextSensitivity.bind(this));
this._nextButton.connect('clicked', () => {
if (this._page == SetupPage.CONNECTION) {
@@ -58,7 +57,7 @@ var InitialSetupWindow = GObject.registerClass({
this._networkMonitor = Gio.NetworkMonitor.get_default();
this._networkMonitor.connect('notify::network-available',
- Lang.bind(this, this._onNetworkAvailableChanged));
+ this._onNetworkAvailableChanged.bind(this));
this._onNetworkAvailableChanged();
}
diff --git a/src/joinDialog.js b/src/joinDialog.js
index c1bd19c..7686ce9 100644
--- a/src/joinDialog.js
+++ b/src/joinDialog.js
@@ -3,7 +3,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 {AccountsMonitor} = imports.accountsMonitor;
const Utils = imports.utils;
@@ -97,11 +96,11 @@ var JoinDialog = GObject.registerClass({
});
this._connectionCombo.connect('changed',
- Lang.bind(this, this._onAccountChanged));
+ this._onAccountChanged.bind(this));
this._connectionCombo.sensitive = false;
this._serverRoomList.connect('notify::can-join',
- Lang.bind(this, this._updateCanJoin));
+ this._updateCanJoin.bind(this));
}
_setupConnectionPage() {
@@ -117,9 +116,9 @@ var JoinDialog = GObject.registerClass({
});
this._connectionsList.connect('account-created',
- Lang.bind(this, this._onAccountCreated));
+ this._onAccountCreated.bind(this));
this._details.connect('account-created',
- Lang.bind(this, this._onAccountCreated));
+ this._onAccountCreated.bind(this));
this._customToggle.connect('notify::active', () => {
let isCustom = this._customToggle.active;
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 2958937..38bdf4d 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -3,7 +3,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 Mainloop = imports.mainloop;
const Polari = imports.gi.Polari;
const Tp = imports.gi.TelepathyGLib;
@@ -156,14 +155,14 @@ var MainWindow = GObject.registerClass({
this._accountsMonitor = AccountsMonitor.getDefault();
this._accountsMonitor.connect('accounts-changed',
- Lang.bind(this, this._onAccountsChanged));
+ this._onAccountsChanged.bind(this));
this._onAccountsChanged(this._accountsMonitor);
this._roomManager = RoomManager.getDefault();
this._roomManager.connect('rooms-loaded',
- Lang.bind(this, this._onRoomsLoaded));
+ this._onRoomsLoaded.bind(this));
this._roomManager.connect('room-removed',
- Lang.bind(this, this._onRoomRemoved));
+ this._onRoomRemoved.bind(this));
this._onRoomsLoaded();
this._updateUserListLabel();
@@ -179,7 +178,7 @@ var MainWindow = GObject.registerClass({
});
this._gtkSettings.connect('notify::gtk-decoration-layout',
- Lang.bind(this, this._updateDecorations));
+ this._updateDecorations.bind(this));
this._updateDecorations();
this._closeConfirmationDialog.transient_for = this;
@@ -191,10 +190,10 @@ var MainWindow = GObject.registerClass({
this.destroy();
});
- this.connect('window-state-event', Lang.bind(this, this._onWindowStateEvent));
- this.connect('size-allocate', Lang.bind(this, this._onSizeAllocate));
- this.connect('destroy', Lang.bind(this, this._onDestroy));
- this.connect('delete-event', Lang.bind(this, this._onDeleteEvent));
+ this.connect('window-state-event', this._onWindowStateEvent.bind(this));
+ this.connect('size-allocate', this._onSizeAllocate.bind(this));
+ this.connect('destroy', this._onDestroy.bind(this));
+ this.connect('delete-event', this._onDeleteEvent.bind(this));
this.connect('notify::active-room', () => {
this._updateUserListLabel();
});
@@ -325,13 +324,13 @@ var MainWindow = GObject.registerClass({
this._displayNameChangedId =
this._room.connect('notify::display-name',
- Lang.bind(this, this._updateTitlebar));
+ this._updateTitlebar.bind(this));
this._topicChangedId =
this._room.connect('notify::topic',
- Lang.bind(this, this._updateTitlebar));
+ this._updateTitlebar.bind(this));
this._membersChangedId =
this._room.connect('members-changed',
- Lang.bind(this, this._updateUserListLabel));
+ this._updateUserListLabel.bind(this));
this._channelChangedId =
this._room.connect('notify::channel', () => {
this._updateUserListLabel();
diff --git a/src/pasteManager.js b/src/pasteManager.js
index d069603..210411c 100644
--- a/src/pasteManager.js
+++ b/src/pasteManager.js
@@ -4,7 +4,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 Polari = imports.gi.Polari;
const Utils = imports.utils;
@@ -42,8 +41,9 @@ var PasteManager = class {
_pasteFile(file, title, callback) {
file.query_info_async(Gio.FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
Gio.FileQueryInfoFlags.NONE,
- GLib.PRIORITY_DEFAULT, null,
- Lang.bind(this, this._onFileQueryFinish, title, callback));
+ GLib.PRIORITY_DEFAULT, null, (file, res) => {
+ this._onFileQueryFinish(file, res, title, callback);
+ });
}
_onFileQueryFinish(file, res, title, callback) {
@@ -103,11 +103,11 @@ var DropTargetIface = GObject.registerClass({
widget.drag_dest_set_target_list(targetList);
- widget.connect('drag-drop', Lang.bind(this, this._onDragDrop));
- widget.connect('drag-leave', Lang.bind(this, this._onDragLeave));
- widget.connect('drag-motion', Lang.bind(this, this._onDragMotion));
+ widget.connect('drag-drop', this._onDragDrop.bind(this));
+ widget.connect('drag-leave', this._onDragLeave.bind(this));
+ widget.connect('drag-motion', this._onDragMotion.bind(this));
widget.connect_after('drag-data-received',
- Lang.bind(this, this._onDragDataReceived));
+ this._onDragDataReceived.bind(this));
}
_onDragDrop(widget, context, x, y, time) {
diff --git a/src/polari-accounts.in b/src/polari-accounts.in
index 017c9c5..2cc0feb 100755
--- a/src/polari-accounts.in
+++ b/src/polari-accounts.in
@@ -5,8 +5,6 @@ const Gtk = imports.gi.Gtk;
const Pango = imports.gi.Pango;
const Tp = imports.gi.TelepathyGLib;
-const Lang = imports.lang;
-
const AccountsWindow = GObject.registerClass(
class AccountsWindow extends Gtk.ApplicationWindow {
_init(params) {
@@ -35,7 +33,7 @@ class AccountsWindow extends Gtk.ApplicationWindow {
scrolled.show_all();
let am = Tp.AccountManager.dup();
- am.prepare_async(null, Lang.bind(this, this._onPrepared));
+ am.prepare_async(null, this._onPrepared.bind(this));
}
_onPrepared(am) {
@@ -48,7 +46,7 @@ class AccountsWindow extends Gtk.ApplicationWindow {
am.connect('account-removed', (am, account) => {
this._removeAccount(account);
});
- am.dup_valid_accounts().forEach(Lang.bind(this, this._addAccount));
+ am.dup_valid_accounts().forEach(this._addAccount.bind(this));
}
_addAccount(account) {
diff --git a/src/roomList.js b/src/roomList.js
index 796fb54..d5c8cc0 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -3,7 +3,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 Tp = imports.gi.TelepathyGLib;
const {AccountsMonitor} = imports.accountsMonitor;
@@ -31,12 +30,10 @@ var RoomRow = GObject.registerClass({
this._icon.visible = room.icon != null;
this._eventBox.connect('button-release-event',
- Lang.bind(this, this._onButtonRelease));
- this.connect('key-press-event',
- Lang.bind(this, this._onKeyPress));
+ this._onButtonRelease.bind(this));
+ this.connect('key-press-event', this._onKeyPress.bind(this));
- room.connect('notify::channel',
- Lang.bind(this, this._onChannelChanged));
+ room.connect('notify::channel', this._onChannelChanged.bind(this));
room.bind_property('display-name', this._roomLabel, 'label',
GObject.BindingFlags.SYNC_CREATE);
@@ -94,9 +91,9 @@ var RoomRow = GObject.registerClass({
if (!this._room.channel)
return;
this._room.channel.connect('message-received',
- Lang.bind(this, this._updatePending));
+ this._updatePending.bind(this));
this._room.channel.connect('pending-message-removed',
- Lang.bind(this, this._updatePending));
+ this._updatePending.bind(this));
this._updatePending();
}
@@ -187,16 +184,16 @@ var RoomListHeader = GObject.registerClass({
let displayNameChangedId =
this._account.connect('notify::display-name',
- Lang.bind(this, this._onDisplayNameChanged));
+ this._onDisplayNameChanged.bind(this));
this._onDisplayNameChanged();
let connectionStatusChangedId =
this._account.connect('notify::connection-status',
- Lang.bind(this, this._onConnectionStatusChanged));
+ this._onConnectionStatusChanged.bind(this));
let presenceChangedId =
this._account.connect('notify::requested-presence-type',
- Lang.bind(this, this._onRequestedPresenceChanged));
+ this._onRequestedPresenceChanged.bind(this));
this._onRequestedPresenceChanged();
this.connect('destroy', () => {
@@ -348,17 +345,17 @@ class RoomList extends Gtk.ListBox {
_init(params) {
super._init(params);
- this.set_header_func(Lang.bind(this, this._updateHeader));
- this.set_sort_func(Lang.bind(this, this._sort));
+ this.set_header_func(this._updateHeader.bind(this));
+ this.set_sort_func(this._sort.bind(this));
this._placeholders = new Map();
this._roomRows = new Map();
this._accountsMonitor = AccountsMonitor.getDefault();
this._accountsMonitor.connect('account-added',
- Lang.bind(this, this._accountAdded));
+ this._accountAdded.bind(this));
this._accountsMonitor.connect('account-removed',
- Lang.bind(this, this._accountRemoved));
+ this._accountRemoved.bind(this));
this._accountsMonitor.connect('account-enabled', (mon, account) => {
this._updatePlaceholderVisibility(account);
});
@@ -373,9 +370,9 @@ class RoomList extends Gtk.ListBox {
this._roomManager = RoomManager.getDefault();
this._roomManager.connect('room-added',
- Lang.bind(this, this._roomAdded));
+ this._roomAdded.bind(this));
this._roomManager.connect('room-removed',
- Lang.bind(this, this._roomRemoved));
+ this._roomRemoved.bind(this));
this._roomManager.rooms.forEach(r => { this._roomAdded(this._roomManager, r); });
let app = Gio.Application.get_default();
@@ -412,7 +409,7 @@ class RoomList extends Gtk.ListBox {
let toplevel = this.get_toplevel();
toplevel.connect('notify::active-room',
- Lang.bind(this, this._activeRoomChanged));
+ this._activeRoomChanged.bind(this));
this._activeRoomChanged();
}
diff --git a/src/roomManager.js b/src/roomManager.js
index 392e18b..7344b07 100644
--- a/src/roomManager.js
+++ b/src/roomManager.js
@@ -1,6 +1,5 @@
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
-const Lang = imports.lang;
const Polari = imports.gi.Polari;
const Signals = imports.signals;
const Tp = imports.gi.TelepathyGLib;
@@ -23,12 +22,12 @@ var RoomManager = class {
this._app = Gio.Application.get_default();
let actions = [
{ name: 'join-room',
- handler: Lang.bind(this, this._onJoinActivated) },
+ handler: this._onJoinActivated.bind(this) },
{ name: 'message-user',
- handler: Lang.bind(this, this._onQueryActivated) },
+ handler: this._onQueryActivated.bind(this) },
{ name: 'leave-room',
after: true,
- handler: Lang.bind(this, this._onLeaveActivated) }
+ handler: this._onLeaveActivated.bind(this) }
];
actions.forEach(a => {
if (a.after)
diff --git a/src/roomStack.js b/src/roomStack.js
index 4ef81d1..67ff9d7 100644
--- a/src/roomStack.js
+++ b/src/roomStack.js
@@ -2,7 +2,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 Pango = imports.gi.Pango;
const Tp = imports.gi.TelepathyGLib;
@@ -28,10 +27,8 @@ var RoomStack = GObject.registerClass({
this._roomManager = RoomManager.getDefault();
- this._roomManager.connect('room-added',
- Lang.bind(this, this._roomAdded));
- this._roomManager.connect('room-removed',
- Lang.bind(this, this._roomRemoved));
+ this._roomManager.connect('room-added', this._roomAdded.bind(this));
+ this._roomManager.connect('room-removed', this._roomRemoved.bind(this));
this._roomManager.rooms.forEach(r => { this._roomAdded(this._roomManager, r); });
this.add_named(new ChatPlaceholder(this._sizeGroup), 'placeholder');
@@ -49,9 +46,9 @@ var RoomStack = GObject.registerClass({
let toplevel = this.get_toplevel();
toplevel.connect('notify::active-room',
- Lang.bind(this, this._activeRoomChanged));
+ this._activeRoomChanged.bind(this));
toplevel.connect('active-room-state-changed',
- Lang.bind(this, this._updateSensitivity));
+ this._updateSensitivity.bind(this));
this._activeRoomChanged();
this._updateSensitivity();
}
@@ -95,7 +92,7 @@ class SavePasswordConfirmationBar extends Gtk.Revealer {
super._init({ valign: Gtk.Align.START });
- this.connect('destroy', Lang.bind(this, this._onDestroy));
+ this.connect('destroy', this._onDestroy.bind(this));
this._createWidget();
diff --git a/src/serverRoomManager.js b/src/serverRoomManager.js
index 36cb93a..c0d7656 100644
--- a/src/serverRoomManager.js
+++ b/src/serverRoomManager.js
@@ -2,7 +2,6 @@ const Gdk = imports.gi.Gdk;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Signals = imports.signals;
const Tp = imports.gi.TelepathyGLib;
@@ -26,9 +25,9 @@ var ServerRoomManager = class {
this._accountsMonitor = AccountsMonitor.getDefault();
this._accountsMonitor.connect('account-status-changed',
- Lang.bind(this, this._onAccountStatusChanged));
+ this._onAccountStatusChanged.bind(this));
this._accountsMonitor.connect('account-removed',
- Lang.bind(this, this._onAccountRemoved));
+ this._onAccountRemoved.bind(this));
this._accountsMonitor.prepare(() => {
this._accountsMonitor.enabledAccounts.forEach(a => {
this._onAccountStatusChanged(this._accountsMonitor, a);
@@ -70,9 +69,8 @@ var ServerRoomManager = class {
}
roomList.start();
});
- roomList.connect('got-room', Lang.bind(this, this._onGotRoom));
- roomList.connect('notify::listing',
- Lang.bind(this, this._onListingChanged));
+ roomList.connect('got-room', this._onGotRoom.bind(this));
+ roomList.connect('notify::listing', this._onListingChanged.bind(this));
this._roomLists.set(account, { list: roomList, rooms: [] });
}
@@ -189,7 +187,7 @@ var ServerRoomList = GObject.registerClass({
this._manager = ServerRoomManager.getDefault();
this._manager.connect('loading-changed',
- Lang.bind(this, this._onLoadingChanged));
+ this._onLoadingChanged.bind(this));
}
get can_join() {
diff --git a/src/tabCompletion.js b/src/tabCompletion.js
index 45d519f..72695cf 100644
--- a/src/tabCompletion.js
+++ b/src/tabCompletion.js
@@ -1,6 +1,5 @@
const Gdk = imports.gi.Gdk;
const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
const Pango = imports.gi.Pango;
const IrcParser = imports.ircParser;
@@ -11,9 +10,9 @@ var TabCompletion = class {
this._canComplete = false;
this._key = '';
- this._entry.connect('key-press-event', Lang.bind(this, this._onKeyPress));
- this._entry.connect('focus-out-event', Lang.bind(this, this._cancel));
- this._entry.connect('unmap', Lang.bind(this, this._cancel));
+ this._entry.connect('key-press-event', this._onKeyPress.bind(this));
+ this._entry.connect('focus-out-event', this._cancel.bind(this));
+ this._entry.connect('unmap', this._cancel.bind(this));
this._entry.connect('realize', () => {
this._popup.set_transient_for(this._entry.get_toplevel());
});
@@ -28,10 +27,10 @@ var TabCompletion = class {
this._popup.add(frame);
this._list = new Gtk.ListBox({ selection_mode: Gtk.SelectionMode.SINGLE });
- this._list.set_filter_func(Lang.bind(this, this._filter));
- this._list.connect('row-selected', Lang.bind(this, this._onRowSelected));
- this._list.connect('row-activated', Lang.bind(this, this._stop));
- this._list.connect('keynav-failed', Lang.bind(this, this._onKeynavFailed));
+ this._list.set_filter_func(this._filter.bind(this));
+ this._list.connect('row-selected', this._onRowSelected.bind(this));
+ this._list.connect('row-activated', this._stop.bind(this));
+ this._list.connect('keynav-failed', this._onKeynavFailed.bind(this));
frame.add(this._list);
this._widgetMap = new Map();
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index b7c17f3..f62b3b4 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -1,7 +1,6 @@
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
-const Lang = imports.lang;
const Polari = imports.gi.Polari;
const Tp = imports.gi.TelepathyGLib;
@@ -50,16 +49,15 @@ class SASLAuthHandler {
this._proxy = new SASLAuthProxy(Gio.DBus.session,
channel.bus_name,
channel.object_path,
- Lang.bind(this, this._onProxyReady));
+ this._onProxyReady.bind(this));
}
_onProxyReady(proxy) {
this._proxy.connectSignal('SASLStatusChanged',
- Lang.bind(this, this._onSASLStatusChanged));
+ this._onSASLStatusChanged.bind(this));
let account = this._channel.connection.get_account();
- Utils.lookupAccountPassword(account,
- Lang.bind(this, this._onPasswordReady));
+ Utils.lookupAccountPassword(account, this._onPasswordReady.bind(this));
}
_onPasswordReady(password) {
@@ -69,7 +67,7 @@ class SASLAuthHandler {
else
this._proxy.AbortSASLRemote(SASLAbortReason.USER_ABORT,
'Password not available',
- Lang.bind(this, this._resetPrompt));
+ this._resetPrompt.bind(this));
}
_onSASLStatusChanged(proxy, sender, [status]) {
@@ -131,28 +129,28 @@ class TelepathyClient extends Tp.BaseClient {
this._roomManager.connect('room-added', (mgr, room) => {
if (room.account.connection)
this._connectRoom(room);
- room.connect('identify-sent', Lang.bind(this, this._onIdentifySent));
+ room.connect('identify-sent', this._onIdentifySent.bind(this));
});
this._accountsMonitor = AccountsMonitor.getDefault();
- this._accountsMonitor.prepare(Lang.bind(this, this._onPrepared));
+ this._accountsMonitor.prepare(this._onPrepared.bind(this));
}
_onPrepared() {
let actions = [
{ name: 'message-user',
- handler: Lang.bind(this, this._onQueryActivated) },
+ handler: this._onQueryActivated.bind(this) },
{ name: 'leave-room',
- handler: Lang.bind(this, this._onLeaveActivated) },
+ handler: this._onLeaveActivated.bind(this) },
{ name: 'connect-account',
- handler: Lang.bind(this, this._onConnectAccountActivated) },
+ handler: this._onConnectAccountActivated.bind(this) },
{ name: 'reconnect-account',
- handler: Lang.bind(this, this._onReconnectAccountActivated) },
+ handler: this._onReconnectAccountActivated.bind(this) },
{ name: 'authenticate-account',
- handler: Lang.bind(this, this._onAuthenticateAccountActivated) },
+ handler: this._onAuthenticateAccountActivated.bind(this) },
{ name: 'save-identify-password',
- handler: Lang.bind(this, this._onSaveIdentifyPasswordActivated) },
+ handler: this._onSaveIdentifyPasswordActivated.bind(this) },
{ name: 'discard-identify-password',
- handler: Lang.bind(this, this._onDiscardIdentifyPasswordActivated) }
+ handler: this._onDiscardIdentifyPasswordActivated.bind(this) }
];
actions.forEach(a => {
this._app.lookup_action(a.name).connect('activate', a.handler);
@@ -182,7 +180,7 @@ class TelepathyClient extends Tp.BaseClient {
this.register();
this._accountsMonitor.connect('account-status-changed',
- Lang.bind(this ,this._onAccountStatusChanged));
+ this._onAccountStatusChanged.bind(this));
this._accountsMonitor.connect('account-added', (mon, account) => {
this._connectAccount(account);
});
@@ -194,7 +192,7 @@ class TelepathyClient extends Tp.BaseClient {
});
this._networkMonitor.connect('network-changed',
- Lang.bind(this, this._onNetworkChanged));
+ this._onNetworkChanged.bind(this));
this._onNetworkChanged(this._networkMonitor,
this._networkMonitor.network_available);
}
@@ -369,8 +367,9 @@ class TelepathyClient extends Tp.BaseClient {
if (!account || !account.enabled)
return;
- this._requestChannel(account, Tp.HandleType.CONTACT, channelName,
- Lang.bind(this, this._sendMessage, message));
+ this._requestChannel(account, Tp.HandleType.CONTACT, channelName, c => {
+ this._sendMessage(c, message);
+ });
}
_onLeaveActivated(action, parameter) {
@@ -492,9 +491,9 @@ class TelepathyClient extends Tp.BaseClient {
}
channel.connect('message-received',
- Lang.bind(this, this._onMessageReceived));
+ this._onMessageReceived.bind(this));
channel.connect('pending-message-removed',
- Lang.bind(this, this._onPendingMessageRemoved));
+ this._onPendingMessageRemoved.bind(this));
this._roomManager.ensureRoomForChannel(channel, 0);
});
diff --git a/src/userList.js b/src/userList.js
index cca11e0..afe9ca4 100644
--- a/src/userList.js
+++ b/src/userList.js
@@ -2,7 +2,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 Mainloop = imports.mainloop;
const Pango = imports.gi.Pango;
const Polari = imports.gi.Polari;
@@ -35,7 +34,7 @@ class UserListPopover extends Gtk.Popover {
let toplevel = this.get_toplevel();
toplevel.connect('notify::active-room',
- Lang.bind(this, this._activeRoomChanged));
+ this._activeRoomChanged.bind(this));
}
_createWidget() {
@@ -50,8 +49,7 @@ class UserListPopover extends Gtk.Popover {
this._box.add(this._userListBin);
this._entry = new Gtk.SearchEntry({ primary_icon_name: 'avatar-default-symbolic' });
- this._entry.connect('search-changed',
- Lang.bind(this, this._updateFilter));
+ this._entry.connect('search-changed', this._updateFilter.bind(this));
this._revealer.add(this._entry);
this._box.show_all();
@@ -77,7 +75,7 @@ class UserListPopover extends Gtk.Popover {
this._userListBin.add(this._userList);
this._userList.vadjustment.connect('changed',
- Lang.bind(this, this._updateEntryVisibility));
+ this._updateEntryVisibility.bind(this));
this._updateEntryVisibility();
}
@@ -131,7 +129,7 @@ var UserDetails = GObject.registerClass({
this.user = user;
this._messageButton.connect('clicked',
- Lang.bind(this, this._onMessageButtonClicked));
+ this._onMessageButtonClicked.bind(this));
this._updateButtonVisibility();
this._detailsGrid.hide();
@@ -164,8 +162,9 @@ var UserDetails = GObject.registerClass({
this._user = user;
if (this._user)
- this._selfContactChangedId = this._user.connection.connect('notify::self-contact',
- Lang.bind(this, this._updateButtonVisibility));
+ this._selfContactChangedId =
+ this._user.connection.connect('notify::self-contact',
+ this._updateButtonVisibility.bind(this));
if (this.expanded)
this._expand();
@@ -212,7 +211,7 @@ var UserDetails = GObject.registerClass({
if (this._user)
this._user.request_contact_info_async(this._cancellable,
- Lang.bind(this, this._onContactInfoReady));
+ this._onContactInfoReady.bind(this));
//TODO: else use this._nickname to query tracker
else
this._revealDetails();
@@ -380,11 +379,13 @@ var UserPopover = GObject.registerClass({
this._userTracker.unwatchRoomStatus(this._room, this._roomStatusChangedId);
this._roomStatusChangedId =
this._userTracker.watchRoomStatus(this._room, this._basenick,
- Lang.bind(this, this._onNickStatusChanged));
+ this._onNickStatusChanged.bind(this));
if (this._globalStatusChangedId > 0)
this._userTracker.disconnect(this._globalStatusChangedId);
- this._globalStatusChangedId = this._userTracker.connect("status-changed::" + basenick,
Lang.bind(this, this._onStatusChanged));
+ this._globalStatusChangedId =
+ this._userTracker.connect("status-changed::" + basenick,
+ this._onStatusChanged.bind(this));
if (this._contactsChangedId > 0)
this._userTracker.disconnect(this._contactsChangedId);
@@ -439,10 +440,10 @@ class UserListRow extends Gtk.ListBoxRow {
this._revealer.reveal_child = false;
});
this.connect('state-flags-changed',
- Lang.bind(this, this._updateArrowVisibility));
+ this._updateArrowVisibility.bind(this));
this._revealer.connect('notify::reveal-child',
- Lang.bind(this, this._onExpandedChanged));
+ this._onExpandedChanged.bind(this));
}
get user() {
@@ -567,19 +568,17 @@ class UserList extends Gtk.ScrolledWindow {
this._updateHeightId = 0;
this._list.connect('size-allocate',
- Lang.bind(this, this._updateContentHeight));
+ this._updateContentHeight.bind(this));
this._list.set_selection_mode(Gtk.SelectionMode.NONE);
/* see https://bugzilla.gnome.org/show_bug.cgi?id=725403 */
- //this._list.set_header_func(Lang.bind(this, this._updateHeader));
+ //this._list.set_header_func(this._updateHeader.bind(this));
this._filter = '';
- this._list.set_filter_func(Lang.bind(this, this._filterRows));
- this._list.set_sort_func(Lang.bind(this, this._sort));
+ this._list.set_filter_func(this._filterRows.bind(this));
+ this._list.set_sort_func(this._sort.bind(this));
- this._list.connect('row-activated',
- Lang.bind(this, this._onRowActivated));
- this.connect('destroy',
- Lang.bind(this, this._onDestroy));
+ this._list.connect('row-activated', this._onRowActivated.bind(this));
+ this.connect('destroy', this._onDestroy.bind(this));
this._room = room;
this._rows = new Map();
@@ -587,24 +586,24 @@ class UserList extends Gtk.ScrolledWindow {
let roomSignals = [
{ name: 'member-renamed',
- handler: Lang.bind(this, this._onMemberRenamed) },
+ handler: this._onMemberRenamed.bind(this) },
{ name: 'member-disconnected',
- handler: Lang.bind(this, this._onMemberRemoved) },
+ handler: this._onMemberRemoved.bind(this) },
{ name: 'member-kicked',
- handler: Lang.bind(this, this._onMemberRemoved) },
+ handler: this._onMemberRemoved.bind(this) },
{ name: 'member-banned',
- handler: Lang.bind(this, this._onMemberRemoved) },
+ handler: this._onMemberRemoved.bind(this) },
{ name: 'member-left',
- handler: Lang.bind(this, this._onMemberRemoved) },
+ handler: this._onMemberRemoved.bind(this) },
{ name: 'member-joined',
- handler: Lang.bind(this, this._onMemberJoined) },
+ handler: this._onMemberJoined.bind(this) },
/*
// see https://bugzilla.gnome.org/show_bug.cgi?id=725403
{ name: 'members-changed',
- handler: Lang.bind(this, this._onMembersChanged) },
+ handler: this._onMembersChanged.bind(this) },
*/
{ name: 'notify::channel',
- handler: Lang.bind(this, this._onChannelChanged) }
+ handler: this._onChannelChanged.bind(this) }
];
this._roomSignals = [];
roomSignals.forEach(signal => {
diff --git a/src/userTracker.js b/src/userTracker.js
index ebd8fd1..aeb0cee 100644
--- a/src/userTracker.js
+++ b/src/userTracker.js
@@ -1,7 +1,6 @@
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
-const Lang = imports.lang;
const Polari = imports.gi.Polari;
const Tp = imports.gi.TelepathyGLib;
@@ -21,9 +20,9 @@ var UserStatusMonitor = class {
this._accountsMonitor = AccountsMonitor.getDefault();
this._accountsMonitor.connect('account-added',
- Lang.bind(this, this._onAccountAdded));
+ this._onAccountAdded.bind(this));
this._accountsMonitor.connect('account-removed',
- Lang.bind(this, this._onAccountRemoved));
+ this._onAccountRemoved.bind(this));
this._accountsMonitor.accounts.forEach(
a => { this._onAccountAdded(this._accountsMonitor, a); });
@@ -68,11 +67,11 @@ var UserTracker = GObject.registerClass({
this._handlerCounter = 0;
this._app = Gio.Application.get_default();
- this._app.connect('prepare-shutdown', Lang.bind(this, this._onShutdown));
+ this._app.connect('prepare-shutdown', this._onShutdown.bind(this));
this._roomManager = RoomManager.getDefault();
- this._roomManager.connect('room-added', Lang.bind(this, this._onRoomAdded));
- this._roomManager.connect('room-removed', Lang.bind(this, this._onRoomRemoved));
+ this._roomManager.connect('room-added', this._onRoomAdded.bind(this));
+ this._roomManager.connect('room-removed', this._onRoomRemoved.bind(this));
}
_onShutdown() {
@@ -100,19 +99,19 @@ var UserTracker = GObject.registerClass({
let roomSignals = [
{ name: 'notify::channel',
- handler: Lang.bind(this, this._onChannelChanged) },
+ handler: this._onChannelChanged.bind(this) },
{ name: 'member-renamed',
- handler: Lang.bind(this, this._onMemberRenamed) },
+ handler: this._onMemberRenamed.bind(this) },
{ name: 'member-disconnected',
- handler: Lang.bind(this, this._onMemberLeft) },
+ handler: this._onMemberLeft.bind(this) },
{ name: 'member-kicked',
- handler: Lang.bind(this, this._onMemberLeft) },
+ handler: this._onMemberLeft.bind(this) },
{ name: 'member-banned',
- handler: Lang.bind(this, this._onMemberLeft) },
+ handler: this._onMemberLeft.bind(this) },
{ name: 'member-joined',
- handler: Lang.bind(this, this._onMemberJoined) },
+ handler: this._onMemberJoined.bind(this) },
{ name: 'member-left',
- handler: Lang.bind(this, this._onMemberLeft) }
+ handler: this._onMemberLeft.bind(this) }
];
let signalIds = this._getRoomSignals(room);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]