[gnome-documents] Stop using Lang.bind()
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] Stop using Lang.bind()
- Date: Mon, 5 Aug 2019 14:03:31 +0000 (UTC)
commit 26a9e9a74c39ea3ec9aff6c70abc1c01617a2d02
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sat Aug 3 12:28:10 2019 +0200
Stop using Lang.bind()
Instead, use arrow functions and bind().
src/application.js | 156 ++++-----
src/changeMonitor.js | 88 +++--
src/documents.js | 832 +++++++++++++++++++++------------------------
src/edit.js | 7 +-
src/embed.js | 18 +-
src/evinceview.js | 84 ++---
src/fullscreenAction.js | 5 +-
src/lokview.js | 20 +-
src/mainToolbar.js | 30 +-
src/mainWindow.js | 22 +-
src/manager.js | 5 +-
src/notifications.js | 69 ++--
src/overview.js | 405 ++++++++++------------
src/password.js | 31 +-
src/places.js | 16 +-
src/presentation.js | 46 ++-
src/preview.js | 184 +++++-----
src/properties.js | 30 +-
src/query.js | 24 +-
src/search.js | 138 ++++----
src/searchbar.js | 17 +-
src/selections.js | 511 +++++++++++++---------------
src/sharing.js | 247 +++++++-------
src/shellSearchProvider.js | 181 +++++-----
src/trackerController.js | 62 ++--
src/trackerUtils.js | 21 +-
src/utils.js | 8 +-
27 files changed, 1502 insertions(+), 1755 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index ea4311e4..d6ab5173 100644
--- a/src/application.js
+++ b/src/application.js
@@ -19,7 +19,6 @@
*
*/
-const Lang = imports.lang;
const Mainloop = imports.mainloop;
const _ = imports.gettext.gettext;
@@ -154,15 +153,14 @@ var Application = GObject.registerClass({
}
_nightModeCreateHook(action) {
- settings.connect('changed::night-mode', Lang.bind(this,
- function() {
- let state = settings.get_value('night-mode');
- if (state.get_boolean() != action.state.get_boolean())
- action.change_state(state);
+ settings.connect('changed::night-mode', () => {
+ let state = settings.get_value('night-mode');
+ if (state.get_boolean() != action.state.get_boolean())
+ action.change_state(state);
- let gtkSettings = Gtk.Settings.get_default();
- gtkSettings.gtk_application_prefer_dark_theme = state.get_boolean();
- }));
+ let gtkSettings = Gtk.Settings.get_default();
+ gtkSettings.gtk_application_prefer_dark_theme = state.get_boolean();
+ });
let state = settings.get_value('night-mode');
let gtkSettings = Gtk.Settings.get_default();
@@ -195,26 +193,23 @@ var Application = GObject.registerClass({
_createMiners(callback) {
let count = 3;
- this.gdataMiner = new Miners.GDataMiner(Lang.bind(this,
- function() {
- count--;
- if (count == 0)
- callback();
- }));
-
- this.owncloudMiner = new Miners.OwncloudMiner(Lang.bind(this,
- function() {
- count--;
- if (count == 0)
- callback();
- }));
-
- this.zpjMiner = new Miners.ZpjMiner(Lang.bind(this,
- function() {
- count--;
- if (count == 0)
- callback();
- }));
+ this.gdataMiner = new Miners.GDataMiner(() => {
+ count--;
+ if (count == 0)
+ callback();
+ });
+
+ this.owncloudMiner = new Miners.OwncloudMiner(() => {
+ count--;
+ if (count == 0)
+ callback();
+ });
+
+ this.zpjMiner = new Miners.ZpjMiner(() => {
+ count--;
+ if (count == 0)
+ callback();
+ });
}
_refreshMinerNow(miner) {
@@ -229,26 +224,25 @@ var Application = GObject.registerClass({
this.emit('miners-changed');
miner._cancellable = new Gio.Cancellable();
- miner.RefreshDBRemote(['documents'], miner._cancellable, Lang.bind(this,
- function(res, error) {
- this.minersRunning = this.minersRunning.filter(
- function(element) {
- return element != miner;
- });
- this.emit('miners-changed');
-
- if (error) {
- if (!error.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
- logError(error, 'Error updating the cache');
-
- return;
- }
+ miner.RefreshDBRemote(['documents'], miner._cancellable, (res, error) => {
+ this.minersRunning = this.minersRunning.filter(
+ function(element) {
+ return element != miner;
+ });
+ this.emit('miners-changed');
+
+ if (error) {
+ if (!error.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
+ logError(error, 'Error updating the cache');
+
+ return;
+ }
- Mainloop.timeout_add_seconds(MINER_REFRESH_TIMEOUT,
- Lang.bind(this, function() {
- this._refreshMinerNow(miner);
- }));
- }));
+ Mainloop.timeout_add_seconds(MINER_REFRESH_TIMEOUT, () => {
+ this._refreshMinerNow(miner);
+ return false;
+ });
+ });
return false;
}
@@ -283,15 +277,12 @@ var Application = GObject.registerClass({
}
_startMiners() {
- this._createMiners(Lang.bind(this,
- function() {
- this._refreshMiners();
-
- this._sourceAddedId = sourceManager.connect('item-added',
- Lang.bind(this, this._refreshMiners));
- this._sourceRemovedId = sourceManager.connect('item-removed',
- Lang.bind(this, this._refreshMiners));
- }));
+ this._createMiners(() => {
+ this._refreshMiners();
+
+ this._sourceAddedId = sourceManager.connect('item-added', this._refreshMiners.bind(this));
+ this._sourceRemovedId = sourceManager.connect('item-removed', this._refreshMiners.bind(this));
+ });
}
_stopMiners() {
@@ -305,10 +296,9 @@ var Application = GObject.registerClass({
this._sourceRemovedId = 0;
}
- this.minersRunning.forEach(Lang.bind(this,
- function(miner) {
- miner._cancellable.cancel();
- }));
+ this.minersRunning.forEach(() => {
+ miner._cancellable.cancel();
+ });
this.minersRunning = [];
this.gdataMiner = null;
@@ -344,7 +334,7 @@ var Application = GObject.registerClass({
settings = new Gio.Settings({ schema_id: 'org.gnome.documents' });
let gtkSettings = Gtk.Settings.get_default();
- gtkSettings.connect('notify::gtk-theme-name', Lang.bind(this, this._themeChanged));
+ gtkSettings.connect('notify::gtk-theme-name', this._themeChanged.bind(this));
this._themeChanged(gtkSettings);
// connect to tracker
@@ -380,16 +370,16 @@ var Application = GObject.registerClass({
let actionEntries = [
{ name: 'quit',
- callback: Lang.bind(this, this._onActionQuit),
+ callback: this._onActionQuit.bind(this),
accels: ['<Primary>q'] },
{ name: 'about',
- callback: Lang.bind(this, this._onActionAbout) },
+ callback: this._onActionAbout.bind(this) },
{ name: 'help',
- callback: Lang.bind(this, this._onActionHelp),
+ callback: this._onActionHelp.bind(this),
accels: ['F1'] },
{ name: 'night-mode',
- callback: Lang.bind(this, this._onActionNightMode),
- create_hook: Lang.bind(this, this._nightModeCreateHook),
+ callback: this._onActionNightMode.bind(this),
+ create_hook: this._nightModeCreateHook.bind(this),
state: settings.get_value('night-mode') },
];
@@ -404,7 +394,7 @@ var Application = GObject.registerClass({
notificationManager = new Notifications.NotificationManager();
this._mainWindow = new MainWindow.MainWindow(this);
- this._mainWindow.connect('destroy', Lang.bind(this, this._onWindowDestroy));
+ this._mainWindow.connect('destroy', this._onWindowDestroy.bind(this));
try {
this._extractPriority = TrackerExtractPriority();
@@ -424,8 +414,8 @@ var Application = GObject.registerClass({
throw(new Error('ShellSearchProvider already instantiated - dbus_register called twice?'));
this._searchProvider = new ShellSearchProvider.ShellSearchProvider();
- this._searchProvider.connect('activate-result', Lang.bind(this, this._onActivateResult));
- this._searchProvider.connect('launch-search', Lang.bind(this, this._onLaunchSearch));
+ this._searchProvider.connect('activate-result', this._onActivateResult.bind(this));
+ this._searchProvider.connect('launch-search', this._onLaunchSearch.bind(this));
try {
this._searchProvider.export(connection);
@@ -497,7 +487,7 @@ var Application = GObject.registerClass({
// clear our state in an idle, so other handlers connected
// to 'destroy' have the chance to perform their cleanups first
- Mainloop.idle_add(Lang.bind(this, this._clearState));
+ Mainloop.idle_add(this._clearState.bind(this));
}
_onActivateResult(provider, urn, terms, timestamp) {
@@ -508,13 +498,12 @@ var Application = GObject.registerClass({
doActivate.apply(this, [doc]);
} else {
let job = new TrackerUtils.SingleItemJob(urn, queryBuilder);
- job.run(Query.QueryFlags.UNFILTERED, Lang.bind(this,
- function(cursor) {
- if (cursor)
- doc = documentManager.addDocumentFromCursor(cursor);
+ job.run(Query.QueryFlags.UNFILTERED, (cursor) => {
+ if (cursor)
+ doc = documentManager.addDocumentFromCursor(cursor);
- doActivate.apply(this, [doc]);
- }));
+ doActivate.apply(this, [doc]);
+ });
}
function doActivate(doc) {
@@ -524,13 +513,12 @@ var Application = GObject.registerClass({
this.activate();
// forward the search terms next time we enter the overview
- let modeChangeId = modeController.connect('window-mode-changed', Lang.bind(this,
- function(object, newMode) {
- if (newMode == WindowMode.WindowMode.DOCUMENTS) {
- modeController.disconnect(modeChangeId);
- searchController.setString(terms.join(' '));
- }
- }));
+ let modeChangeId = modeController.connect('window-mode-changed', (object, newMode) => {
+ if (newMode == WindowMode.WindowMode.DOCUMENTS) {
+ modeController.disconnect(modeChangeId);
+ searchController.setString(terms.join(' '));
+ }
+ });
}
}
diff --git a/src/changeMonitor.js b/src/changeMonitor.js
index 20ab907a..5308b042 100644
--- a/src/changeMonitor.js
+++ b/src/changeMonitor.js
@@ -20,7 +20,6 @@
*/
const Gio = imports.gi.Gio;
-const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Signals = imports.signals;
@@ -91,19 +90,17 @@ var TrackerChangeMonitor = class TrackerChangeMonitor {
this._pendingEventsId = 0;
this._resourceService = new TrackerResourcesService();
- this._resourceService.connectSignal('GraphUpdated', Lang.bind(this, this._onGraphUpdated));
+ this._resourceService.connectSignal('GraphUpdated', this._onGraphUpdated.bind(this));
}
_onGraphUpdated(proxy, senderName, [className, deleteEvents, insertEvents]) {
- deleteEvents.forEach(Lang.bind(this,
- function(event) {
- this._addPendingEvent(event, true);
- }));
-
- insertEvents.forEach(Lang.bind(this,
- function(event) {
- this._addPendingEvent(event, false);
- }));
+ deleteEvents.forEach((event) => {
+ this._addPendingEvent(event, true);
+ });
+
+ insertEvents.forEach((event) => {
+ this._addPendingEvent(event, false);
+ });
}
_addPendingEvent(event, isDelete) {
@@ -118,7 +115,7 @@ var TrackerChangeMonitor = class TrackerChangeMonitor {
this._processEvents();
else
this._pendingEventsId =
- Mainloop.timeout_add(CHANGE_MONITOR_TIMEOUT, Lang.bind(this, this._processEvents));
+ Mainloop.timeout_add(CHANGE_MONITOR_TIMEOUT, this._processEvents.bind(this));
}
_processEvents() {
@@ -130,40 +127,36 @@ var TrackerChangeMonitor = class TrackerChangeMonitor {
this._unresolvedIds = {};
let sparql = 'SELECT';
- Object.keys(idTable).forEach(Lang.bind(this,
- function(unresolvedId) {
- sparql += (' tracker:uri(%d)').format(unresolvedId);
- }));
+ Object.keys(idTable).forEach((unresolvedId) => {
+ sparql += (' tracker:uri(%d)').format(unresolvedId);
+ });
sparql += ' {}';
// resolve all the unresolved IDs we got so far
- Application.connectionQueue.add(sparql, null, Lang.bind(this,
- function(object, res) {
- let cursor = object.query_finish(res);
-
- cursor.next_async(null, Lang.bind(this,
- function(object, res) {
- let valid = false;
- try {
- valid = cursor.next_finish(res);
- } catch(e) {
- logError(e, 'Unable to resolve item URNs for graph changes');
- }
-
- if (valid) {
- let idx = 0;
- Object.keys(idTable).forEach(Lang.bind(this,
- function(unresolvedId) {
- idTable[unresolvedId] = cursor.get_string(idx)[0];
- idx++;
- }));
-
- this._sendEvents(events, idTable);
- }
-
- cursor.close();
- }));
- }));
+ Application.connectionQueue.add(sparql, null, (object, res) => {
+ let cursor = object.query_finish(res);
+
+ cursor.next_async(null, (object, res) => {
+ let valid = false;
+ try {
+ valid = cursor.next_finish(res);
+ } catch(e) {
+ logError(e, 'Unable to resolve item URNs for graph changes');
+ }
+
+ if (valid) {
+ let idx = 0;
+ Object.keys(idTable).forEach((unresolvedId) => {
+ idTable[unresolvedId] = cursor.get_string(idx)[0];
+ idx++;
+ });
+
+ this._sendEvents(events, idTable);
+ }
+
+ cursor.close();
+ });
+ });
return false;
}
@@ -181,11 +174,10 @@ var TrackerChangeMonitor = class TrackerChangeMonitor {
}
_sendEvents(events, idTable) {
- events.forEach(Lang.bind(this,
- function(event) {
- event.setResolvedValues(idTable[event.urnId], idTable[event.predicateId]);
- this._addEvent(event);
- }));
+ events.forEach((event) => {
+ event.setResolvedValues(idTable[event.urnId], idTable[event.predicateId]);
+ this._addEvent(event);
+ });
this.emit('changes-pending', this._pendingChanges);
this._pendingChanges = {};
diff --git a/src/documents.js b/src/documents.js
index 7a10c97b..05be854f 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -34,7 +34,6 @@ const Gtk = imports.gi.Gtk;
const Zpj = imports.gi.Zpj;
const _ = imports.gettext.gettext;
-const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Signals = imports.signals;
@@ -58,17 +57,16 @@ const DeleteItemJob = class DeleteItemJob {
this._callback = callback;
let query = Application.queryBuilder.buildDeleteResourceQuery(this._urn);
- Application.connectionQueue.update(query.sparql, null, Lang.bind(this,
- function(object, res) {
- try {
- object.update_finish(res);
- } catch (e) {
- logError(e, 'Failed to delete resource ' + this._urn);
- }
+ Application.connectionQueue.update(query.sparql, null, (object, res) => {
+ try {
+ object.update_finish(res);
+ } catch (e) {
+ logError(e, 'Failed to delete resource ' + this._urn);
+ }
- if (this._callback)
- this._callback();
- }));
+ if (this._callback)
+ this._callback();
+ });
}
}
@@ -90,18 +88,17 @@ const CollectionIconWatcher = class CollectionIconWatcher {
this._clear();
let query = Application.queryBuilder.buildCollectionIconQuery(this._collection.id);
- Application.connectionQueue.add(query.sparql, null, Lang.bind(this,
- function(object, res) {
- let cursor = null;
- try {
- cursor = object.query_finish(res);
- } catch (e) {
- logError(e, 'Unable to query collection items');
- return;
- }
+ Application.connectionQueue.add(query.sparql, null, (object, res) => {
+ let cursor = null;
+ try {
+ cursor = object.query_finish(res);
+ } catch (e) {
+ logError(e, 'Unable to query collection items');
+ return;
+ }
- cursor.next_async(null, Lang.bind(this, this._onCursorNext));
- }));
+ cursor.next_async(null, this._onCursorNext.bind(this));
+ });
}
_onCursorNext(cursor, res) {
@@ -125,7 +122,7 @@ const CollectionIconWatcher = class CollectionIconWatcher {
let urn = cursor.get_string(0)[0];
this._urns.push(urn);
- cursor.next_async(null, Lang.bind(this, this._onCursorNext));
+ cursor.next_async(null, this._onCursorNext.bind(this));
}
_onCollectionIconFinished() {
@@ -135,14 +132,13 @@ const CollectionIconWatcher = class CollectionIconWatcher {
// now this._urns has all the URNs of items contained in the collection
let toQuery = [];
- this._urns.forEach(Lang.bind(this,
- function(urn) {
- let doc = Application.documentManager.getItemById(urn);
- if (doc)
- this._docs.push(doc);
- else
- toQuery.push(urn);
- }));
+ this._urns.forEach((urn) => {
+ let doc = Application.documentManager.getItemById(urn);
+ if (doc)
+ this._docs.push(doc);
+ else
+ toQuery.push(urn);
+ });
this._toQueryRemaining = toQuery.length;
if (!this._toQueryRemaining) {
@@ -150,19 +146,17 @@ const CollectionIconWatcher = class CollectionIconWatcher {
return;
}
- toQuery.forEach(Lang.bind(this,
- function(urn) {
- let job = new TrackerUtils.SingleItemJob(urn, Application.queryBuilder);
- job.run(Query.QueryFlags.UNFILTERED, Lang.bind(this,
- function(cursor) {
- if (cursor) {
- let doc = Application.documentManager.createDocumentFromCursor(cursor);
- this._docs.push(doc);
- }
+ toQuery.forEach((urn) => {
+ let job = new TrackerUtils.SingleItemJob(urn, Application.queryBuilder);
+ job.run(Query.QueryFlags.UNFILTERED, (cursor) => {
+ if (cursor) {
+ let doc = Application.documentManager.createDocumentFromCursor(cursor);
+ this._docs.push(doc);
+ }
- this._toQueryCollector();
- }));
- }));
+ this._toQueryCollector();
+ });
+ });
}
_toQueryCollector() {
@@ -173,12 +167,10 @@ const CollectionIconWatcher = class CollectionIconWatcher {
}
_allDocsReady() {
- this._docs.forEach(Lang.bind(this,
- function(doc) {
- let updateId = doc.connect('info-updated',
- Lang.bind(this, this._createCollectionIcon));
- this._docConnections[updateId] = doc;
- }));
+ this._docs.forEach((doc) => {
+ let updateId = doc.connect('info-updated', this._createCollectionIcon.bind(this));
+ this._docConnections[updateId] = doc;
+ });
this._createCollectionIcon();
}
@@ -188,16 +180,15 @@ const CollectionIconWatcher = class CollectionIconWatcher {
// collection icon
let pixbufs = [];
- this._docs.forEach(
- function(doc) {
- if (doc.origPixbuf) {
- if (doc._thumbPath && !doc._failedThumbnailing)
- doc.origPixbuf.set_option('-documents-has-thumb', 'true');
- else
- doc.origPixbuf.remove_option('-documents-has-thumb');
- pixbufs.push(doc.origPixbuf);
- }
- });
+ this._docs.forEach((doc) => {
+ if (doc.origPixbuf) {
+ if (doc._thumbPath && !doc._failedThumbnailing)
+ doc.origPixbuf.set_option('-documents-has-thumb', 'true');
+ else
+ doc.origPixbuf.remove_option('-documents-has-thumb');
+ pixbufs.push(doc.origPixbuf);
+ }
+ });
this._pixbuf = GdPrivate.create_collection_icon(
Utils.getIconSize() * Application.application.getScaleFactor(),
@@ -255,19 +246,17 @@ const DocCommon = class DocCommon {
this.populateFromCursor(cursor);
this._refreshIconId =
- Application.settings.connect('changed::view-as',
- Lang.bind(this, this.refreshIcon));
+ Application.settings.connect('changed::view-as', this.refreshIcon.bind(this));
}
refresh() {
let job = new TrackerUtils.SingleItemJob(this.id, Application.queryBuilder);
- job.run(Query.QueryFlags.NONE, Lang.bind(this,
- function(cursor) {
- if (!cursor)
- return;
+ job.run(Query.QueryFlags.NONE, (cursor) => {
+ if (!cursor)
+ return;
- this.populateFromCursor(cursor);
- }));
+ this.populateFromCursor(cursor);
+ });
}
_sanitizeTitle() {
@@ -349,10 +338,9 @@ const DocCommon = class DocCommon {
if (!this._collectionIconWatcher) {
this._collectionIconWatcher = new CollectionIconWatcher(this);
- this._collectionIconWatcher.connect('icon-updated', Lang.bind(this,
- function(watcher, pixbuf) {
- this._setOrigPixbuf(pixbuf);
- }));
+ this._collectionIconWatcher.connect('icon-updated', (watcher, pixbuf) => {
+ this._setOrigPixbuf(pixbuf);
+ });
} else {
this._collectionIconWatcher.refresh();
}
@@ -371,12 +359,12 @@ const DocCommon = class DocCommon {
return;
}
- localFile.query_info_async(Gio.FILE_ATTRIBUTE_TIME_MODIFIED,
- Gio.FileQueryInfoFlags.NONE,
- GLib.PRIORITY_DEFAULT,
- cancellable,
- Lang.bind(this,
- function(object, res) {
+ localFile.query_info_async(
+ Gio.FILE_ATTRIBUTE_TIME_MODIFIED,
+ Gio.FileQueryInfoFlags.NONE,
+ GLib.PRIORITY_DEFAULT,
+ cancellable,
+ (object, res) => {
let info;
try {
@@ -397,7 +385,7 @@ const DocCommon = class DocCommon {
Utils.debug('Downloading ' + this.constructor.name + ' ' + this.id + ' to ' + this.uriToLoad
+
': cache stale (' + this.mtime + ' > ' + cacheMtime + ')');
this.downloadImpl(localFile, cancellable, callback);
- }));
+ });
}
downloadImpl(localFile, cancellable, callback) {
@@ -408,49 +396,45 @@ const DocCommon = class DocCommon {
Utils.debug('Loading ' + this.constructor.name + ' ' + this.id);
if (this.collection) {
- Mainloop.idle_add(Lang.bind(this,
- function() {
- let error = new GLib.Error(Gio.IOErrorEnum,
- Gio.IOErrorEnum.NOT_SUPPORTED,
- "Collections can't be loaded");
- callback(this, null, error);
- return GLib.SOURCE_REMOVE;
- }));
+ Mainloop.idle_add(() => {
+ let error = new GLib.Error(Gio.IOErrorEnum,
+ Gio.IOErrorEnum.NOT_SUPPORTED,
+ "Collections can't be loaded");
+ callback(this, null, error);
+ return GLib.SOURCE_REMOVE;
+ });
return;
}
- this.download(true, cancellable, Lang.bind(this,
- function(fromCache, error) {
- if (error) {
- callback(this, null, error);
- return;
- }
+ this.download(true, cancellable, (fromCache, error) => {
+ if (error) {
+ callback(this, null, error);
+ return;
+ }
- this.loadLocal(passwd, cancellable, Lang.bind(this,
- function(doc, docModel, error) {
- if (error) {
- if (fromCache &&
- !error.matches(EvDocument.DocumentError,
EvDocument.DocumentError.ENCRYPTED)) {
- this.download(false, cancellable, Lang.bind(this,
- function(fromCache, error) {
- if (error) {
- callback(this, null, error);
- return;
- }
-
- this.loadLocal(passwd, cancellable, callback);
- }));
- } else {
+ this.loadLocal(passwd, cancellable, (doc, docModel, error) => {
+ if (error) {
+ if (fromCache &&
+ !error.matches(EvDocument.DocumentError, EvDocument.DocumentError.ENCRYPTED)) {
+ this.download(false, cancellable, (fromCache, error) => {
+ if (error) {
callback(this, null, error);
+ return;
}
- return;
- }
+ this.loadLocal(passwd, cancellable, callback);
+ });
+ } else {
+ callback(this, null, error);
+ }
+
+ return;
+ }
- callback(this, docModel, null);
- }));
- }));
+ callback(this, docModel, null);
+ });
+ });
}
canEdit() {
@@ -518,7 +502,7 @@ const DocCommon = class DocCommon {
Gio.FileQueryInfoFlags.NONE,
GLib.PRIORITY_DEFAULT,
null,
- Lang.bind(this, this._onFileQueryInfo));
+ this._onFileQueryInfo.bind(this));
}
_onFileQueryInfo(object, res) {
@@ -537,7 +521,7 @@ const DocCommon = class DocCommon {
if (this._thumbPath) {
this._refreshThumbPath();
} else {
- this.createThumbnail(Lang.bind(this, this._onCreateThumbnail));
+ this.createThumbnail(this._onCreateThumbnail.bind(this));
}
}
@@ -552,7 +536,7 @@ const DocCommon = class DocCommon {
Gio.FileQueryInfoFlags.NONE,
GLib.PRIORITY_DEFAULT,
null,
- Lang.bind(this, this._onThumbnailPathInfo));
+ this._onThumbnailPathInfo.bind(this));
}
_onThumbnailPathInfo(object, res) {
@@ -576,45 +560,44 @@ const DocCommon = class DocCommon {
_refreshThumbPath() {
let thumbFile = Gio.file_new_for_path(this._thumbPath);
- thumbFile.read_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this,
- function(object, res) {
- let stream;
+ thumbFile.read_async(GLib.PRIORITY_DEFAULT, null, (object, res) => {
+ let stream;
- try {
- stream = object.read_finish(res);
- } catch (e) {
- logError(e, 'Unable to read file at ' + thumbFile.get_uri());
- this._failedThumbnailing = true;
- this._thumbPath = null;
- thumbFile.delete_async(GLib.PRIORITY_DEFAULT, null, null);
- return;
- }
-
- let scale = Application.application.getScaleFactor();
- GdkPixbuf.Pixbuf.new_from_stream_at_scale_async(stream,
- Utils.getIconSize() * scale, Utils.getIconSize() * scale,
- true, null, Lang.bind(this,
- function(object, res) {
- // close the underlying stream immediately
- stream.close_async(0, null, null);
-
- let pixbuf;
-
- try {
- pixbuf = GdkPixbuf.Pixbuf.new_from_stream_finish(res);
- } catch (e) {
- if (!e.matches(GdkPixbuf.PixbufError, GdkPixbuf.PixbufError.UNKNOWN_TYPE))
- logError(e, 'Unable to create pixbuf from ' + thumbFile.get_uri());
+ try {
+ stream = object.read_finish(res);
+ } catch (e) {
+ logError(e, 'Unable to read file at ' + thumbFile.get_uri());
+ this._failedThumbnailing = true;
+ this._thumbPath = null;
+ thumbFile.delete_async(GLib.PRIORITY_DEFAULT, null, null);
+ return;
+ }
- this._failedThumbnailing = true;
- this._thumbPath = null;
- thumbFile.delete_async(GLib.PRIORITY_DEFAULT, null, null);
- return;
- }
+ let scale = Application.application.getScaleFactor();
+ GdkPixbuf.Pixbuf.new_from_stream_at_scale_async(
+ stream,
+ Utils.getIconSize() * scale, Utils.getIconSize() * scale,
+ true, null, (object, res) => {
+ // close the underlying stream immediately
+ stream.close_async(0, null, null);
+
+ let pixbuf;
+
+ try {
+ pixbuf = GdkPixbuf.Pixbuf.new_from_stream_finish(res);
+ } catch (e) {
+ if (!e.matches(GdkPixbuf.PixbufError, GdkPixbuf.PixbufError.UNKNOWN_TYPE))
+ logError(e, 'Unable to create pixbuf from ' + thumbFile.get_uri());
+
+ this._failedThumbnailing = true;
+ this._thumbPath = null;
+ thumbFile.delete_async(GLib.PRIORITY_DEFAULT, null, null);
+ return;
+ }
- this._setOrigPixbuf(pixbuf);
- }));
- }));
+ this._setOrigPixbuf(pixbuf);
+ });
+ });
}
_updateInfoFromType() {
@@ -716,15 +699,14 @@ const DocCommon = class DocCommon {
return;
}
- GdPrivate.pdf_loader_load_uri_async(this.uriToLoad, passwd, cancellable, Lang.bind(this,
- function(source, res) {
- try {
- let docModel = GdPrivate.pdf_loader_load_uri_finish(res);
- callback(this, docModel, null);
- } catch (e) {
- callback(this, null, e);
- }
- }));
+ GdPrivate.pdf_loader_load_uri_async(this.uriToLoad, passwd, cancellable, (source, res) => {
+ try {
+ let docModel = GdPrivate.pdf_loader_load_uri_finish(res);
+ callback(this, docModel, null);
+ } catch (e) {
+ callback(this, null, e);
+ }
+ });
}
open(parent, timestamp) {
@@ -744,49 +726,45 @@ const DocCommon = class DocCommon {
}
print(toplevel) {
- this.load(null, null, Lang.bind(this,
- function(doc, docModel, error) {
- if (error) {
- logError(error, 'Unable to print document ' + this.uri);
- return;
- }
+ this.load(null, null, (doc, docModel, error) => {
+ if (error) {
+ logError(error, 'Unable to print document ' + this.uri);
+ return;
+ }
- if (!this.canPrint(docModel))
- return;
+ if (!this.canPrint(docModel))
+ return;
- let printOp = EvView.PrintOperation.new(docModel.get_document());
+ let printOp = EvView.PrintOperation.new(docModel.get_document());
- printOp.connect('begin-print', Lang.bind(this,
- function() {
- this.emit('begin-print');
- }));
+ printOp.connect('begin-print', () => {
+ this.emit('begin-print');
+ });
- printOp.connect('done', Lang.bind(this,
- function(op, res) {
- if (res == Gtk.PrintOperationResult.ERROR) {
- try {
- printOp.get_error();
- } catch (e) {
- let errorDialog = new Gtk.MessageDialog ({ transient_for: toplevel,
- modal: true,
- destroy_with_parent: true,
- buttons: Gtk.ButtonsType.OK,
- message_type:
Gtk.MessageType.ERROR,
- text: _("Failed to print
document"),
- secondary_text: e.message });
- errorDialog.connect ('response', Lang.bind(this,
- function() {
- errorDialog.destroy();
- }));
- errorDialog.show();
- }
- }
- }));
+ printOp.connect('done', (op, res) => {
+ if (res == Gtk.PrintOperationResult.ERROR) {
+ try {
+ printOp.get_error();
+ } catch (e) {
+ let errorDialog = new Gtk.MessageDialog ({ transient_for: toplevel,
+ modal: true,
+ destroy_with_parent: true,
+ buttons: Gtk.ButtonsType.OK,
+ message_type: Gtk.MessageType.ERROR,
+ text: _("Failed to print document"),
+ secondary_text: e.message });
+ errorDialog.connect ('response', () => {
+ errorDialog.destroy();
+ });
+ errorDialog.show();
+ }
+ }
+ });
- let printNotification = new Notifications.PrintNotification(printOp, doc);
+ let printNotification = new Notifications.PrintNotification(printOp, doc);
- printOp.run(toplevel);
- }));
+ printOp.run(toplevel);
+ });
}
getSourceLink() {
@@ -859,20 +837,19 @@ var LocalDocument = class LocalDocument extends DocCommon {
}
createThumbnail(callback) {
- GdPrivate.queue_thumbnail_job_for_file_async(this._file, Lang.bind(this,
- function(object, res) {
- let thumbnailed = false;
+ GdPrivate.queue_thumbnail_job_for_file_async(this._file, (object, res) => {
+ let thumbnailed = false;
- try {
- thumbnailed = GdPrivate.queue_thumbnail_job_for_file_finish(res);
- } catch (e) {
- /* We don't care about reporting errors here, just fail the
- * thumbnail.
- */
- }
+ try {
+ thumbnailed = GdPrivate.queue_thumbnail_job_for_file_finish(res);
+ } catch (e) {
+ /* We don't care about reporting errors here, just fail the
+ * thumbnail.
+ */
+ }
- callback(thumbnailed);
- }));
+ callback(thumbnailed);
+ });
}
updateTypeDescription() {
@@ -894,14 +871,13 @@ var LocalDocument = class LocalDocument extends DocCommon {
Utils.debug('Loading ' + this.constructor.name + ' ' + this.id);
if (this.collection) {
- Mainloop.idle_add(Lang.bind(this,
- function() {
- let error = new GLib.Error(Gio.IOErrorEnum,
- Gio.IOErrorEnum.NOT_SUPPORTED,
- "Collections can't be loaded");
- callback(this, null, error);
- return GLib.SOURCE_REMOVE;
- }));
+ Mainloop.idle_add(() => {
+ let error = new GLib.Error(Gio.IOErrorEnum,
+ Gio.IOErrorEnum.NOT_SUPPORTED,
+ "Collections can't be loaded");
+ callback(this, null, error);
+ return GLib.SOURCE_REMOVE;
+ });
return;
}
@@ -930,14 +906,13 @@ var LocalDocument = class LocalDocument extends DocCommon {
return;
let file = Gio.file_new_for_uri(this.uri);
- file.trash_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this,
- function(source, res) {
- try {
- file.trash_finish(res);
- } catch(e) {
- logError(e, 'Unable to trash ' + this.uri);
- }
- }));
+ file.trash_async(GLib.PRIORITY_DEFAULT, null, (source, res) => {
+ try {
+ file.trash_finish(res);
+ } catch(e) {
+ logError(e, 'Unable to trash ' + this.uri);
+ }
+ });
}
getSourceLink() {
@@ -976,128 +951,121 @@ const GoogleDocument = class GoogleDocument extends DocCommon {
(GData.DocumentsService.get_primary_authorization_domain(),
gdata_id, null,
GData.DocumentsText,
- cancellable, Lang.bind(this,
- function(object, res) {
- let entry = null;
- let exception = null;
+ cancellable,
+ (object, res) => {
+ let entry = null;
+ let exception = null;
- try {
- entry = object.query_single_entry_finish(res);
- } catch (e) {
- exception = e;
- }
+ try {
+ entry = object.query_single_entry_finish(res);
+ } catch (e) {
+ exception = e;
+ }
- callback(entry, service, exception);
- }));
+ callback(entry, service, exception);
+ });
}
downloadImpl(localFile, cancellable, callback) {
- this.createGDataEntry(cancellable, Lang.bind(this,
- function(entry, service, error) {
- if (error) {
- callback(false, error);
- return;
- }
-
- Utils.debug('Created GDataEntry for ' + this.id);
+ this.createGDataEntry(cancellable, (entry, service, error) => {
+ if (error) {
+ callback(false, error);
+ return;
+ }
- let inputStream;
+ Utils.debug('Created GDataEntry for ' + this.id);
- try {
- inputStream = entry.download(service, 'pdf', cancellable);
- } catch(e) {
- callback(false, e);
- return;
- }
+ let inputStream;
- localFile.replace_async(null,
- false,
- Gio.FileCreateFlags.PRIVATE,
- GLib.PRIORITY_DEFAULT,
- cancellable,
- Lang.bind(this,
- function(object, res) {
- let outputStream;
+ try {
+ inputStream = entry.download(service, 'pdf', cancellable);
+ } catch(e) {
+ callback(false, e);
+ return;
+ }
- try {
- outputStream = object.replace_finish(res);
- } catch (e) {
- callback(false, e);
- return;
- }
+ localFile.replace_async(
+ null, false, Gio.FileCreateFlags.PRIVATE,
+ GLib.PRIORITY_DEFAULT, cancellable,
+ (object, res) => {
+ let outputStream;
+
+ try {
+ outputStream = object.replace_finish(res);
+ } catch (e) {
+ callback(false, e);
+ return;
+ }
- outputStream.splice_async(inputStream,
- Gio.OutputStreamSpliceFlags.CLOSE_SOURCE |
- Gio.OutputStreamSpliceFlags.CLOSE_TARGET,
- GLib.PRIORITY_DEFAULT,
- cancellable,
- Lang.bind(this,
- function(object, res) {
- try {
- object.splice_finish(res);
- } catch (e) {
- callback(false, e);
- return;
- }
+ outputStream.splice_async(
+ inputStream,
+ Gio.OutputStreamSpliceFlags.CLOSE_SOURCE | Gio.OutputStreamSpliceFlags.CLOSE_TARGET,
+ GLib.PRIORITY_DEFAULT, cancellable,
+ (object, res) => {
+ try {
+ object.splice_finish(res);
+ } catch (e) {
+ callback(false, e);
+ return;
+ }
- callback(false, null);
- }));
- }));
- }))
+ callback(false, null);
+ });
+ });
+ });
}
createThumbnail(callback) {
- this.createGDataEntry(null, Lang.bind(this,
- function(entry, service, exception) {
- if (exception) {
- callback(false);
- return;
- }
-
- let uri = entry.get_thumbnail_uri();
- if (!uri) {
- callback(false);
- return;
- }
-
- let authorizationDomain = GData.DocumentsService.get_primary_authorization_domain();
- let inputStream = new GData.DownloadStream({ service: service,
- authorization_domain: authorizationDomain,
- download_uri: uri });
+ this.createGDataEntry(null, (entry, service, exception) => {
+ if (exception) {
+ callback(false);
+ return;
+ }
- let path = GnomeDesktop.desktop_thumbnail_path_for_uri (this.uri,
-
GnomeDesktop.DesktopThumbnailSize.NORMAL);
- let dirPath = GLib.path_get_dirname(path);
- GLib.mkdir_with_parents(dirPath, 448);
+ let uri = entry.get_thumbnail_uri();
+ if (!uri) {
+ callback(false);
+ return;
+ }
- let downloadFile = Gio.File.new_for_path(path);
- downloadFile.replace_async
- (null, false, Gio.FileCreateFlags.PRIVATE, GLib.PRIORITY_DEFAULT, null, Lang.bind(this,
- function(source, res) {
- let outputStream;
+ let authorizationDomain = GData.DocumentsService.get_primary_authorization_domain();
+ let inputStream = new GData.DownloadStream({ service: service,
+ authorization_domain: authorizationDomain,
+ download_uri: uri });
+
+ let path = GnomeDesktop.desktop_thumbnail_path_for_uri (this.uri,
+
GnomeDesktop.DesktopThumbnailSize.NORMAL);
+ let dirPath = GLib.path_get_dirname(path);
+ GLib.mkdir_with_parents(dirPath, 448);
+
+ let downloadFile = Gio.File.new_for_path(path);
+ downloadFile.replace_async(
+ null, false, Gio.FileCreateFlags.PRIVATE, GLib.PRIORITY_DEFAULT, null, (source, res) => {
+ let outputStream;
+
+ try {
+ outputStream = downloadFile.replace_finish(res);
+ } catch (e) {
+ callback(false);
+ return;
+ }
+ outputStream.splice_async(
+ inputStream,
+ Gio.OutputStreamSpliceFlags.CLOSE_SOURCE | Gio.OutputStreamSpliceFlags.CLOSE_TARGET,
+ GLib.PRIORITY_DEFAULT, null,
+ (source, res) => {
try {
- outputStream = downloadFile.replace_finish(res);
+ outputStream.splice_finish(res);
} catch (e) {
callback(false);
return;
}
- outputStream.splice_async(inputStream,
- Gio.OutputStreamSpliceFlags.CLOSE_SOURCE |
Gio.OutputStreamSpliceFlags.CLOSE_TARGET,
- GLib.PRIORITY_DEFAULT, null, Lang.bind(this,
- function(source, res) {
- try {
- outputStream.splice_finish(res);
- } catch (e) {
- callback(false);
- return;
- }
-
- callback(true);
- }));
- }));
- }));
+ callback(true);
+ });
+ });
+ });
}
updateTypeDescription() {
@@ -1182,20 +1150,19 @@ const OwncloudDocument = class OwncloudDocument extends DocCommon {
}
createThumbnail(callback) {
- GdPrivate.queue_thumbnail_job_for_file_async(this._file, Lang.bind(this,
- function(object, res) {
- let thumbnailed = false;
+ GdPrivate.queue_thumbnail_job_for_file_async(this._file, (object, res) => {
+ let thumbnailed = false;
- try {
- thumbnailed = GdPrivate.queue_thumbnail_job_for_file_finish(res);
- } catch (e) {
- /* We don't care about reporting errors here, just fail the
- * thumbnail.
- */
- }
+ try {
+ thumbnailed = GdPrivate.queue_thumbnail_job_for_file_finish(res);
+ } catch (e) {
+ /* We don't care about reporting errors here, just fail the
+ * thumbnail.
+ */
+ }
- callback(thumbnailed);
- }));
+ callback(thumbnailed);
+ });
}
updateTypeDescription() {
@@ -1211,51 +1178,49 @@ const OwncloudDocument = class OwncloudDocument extends DocCommon {
downloadImpl(localFile, cancellable, callback) {
let remoteFile = Gio.File.new_for_uri(this.uri);
- remoteFile.read_async(GLib.PRIORITY_DEFAULT, cancellable, Lang.bind(this,
- function(object, res) {
- let inputStream;
-
- try {
- inputStream = object.read_finish(res);
- } catch (e) {
- callback(false, e);
- return;
- }
+ remoteFile.read_async(GLib.PRIORITY_DEFAULT, cancellable, (object, res) => {
+ let inputStream;
- localFile.replace_async(null,
- false,
- Gio.FileCreateFlags.PRIVATE,
- GLib.PRIORITY_DEFAULT,
- cancellable,
- Lang.bind(this,
- function(object, res) {
- let outputStream;
+ try {
+ inputStream = object.read_finish(res);
+ } catch (e) {
+ callback(false, e);
+ return;
+ }
- try {
- outputStream = object.replace_finish(res);
- } catch (e) {
- callback(false, e);
- return;
- }
+ localFile.replace_async(
+ null,
+ false,
+ Gio.FileCreateFlags.PRIVATE,
+ GLib.PRIORITY_DEFAULT,
+ cancellable,
+ (object, res) => {
+ let outputStream;
+
+ try {
+ outputStream = object.replace_finish(res);
+ } catch (e) {
+ callback(false, e);
+ return;
+ }
- outputStream.splice_async(inputStream,
- Gio.OutputStreamSpliceFlags.CLOSE_SOURCE |
- Gio.OutputStreamSpliceFlags.CLOSE_TARGET,
- GLib.PRIORITY_DEFAULT,
- cancellable,
- Lang.bind(this,
- function(object, res) {
- try {
- object.splice_finish(res);
- } catch (e) {
- callback(false, e);
- return;
- }
+ outputStream.splice_async(
+ inputStream,
+ Gio.OutputStreamSpliceFlags.CLOSE_SOURCE | Gio.OutputStreamSpliceFlags.CLOSE_TARGET,
+ GLib.PRIORITY_DEFAULT,
+ cancellable,
+ (object, res) => {
+ try {
+ object.splice_finish(res);
+ } catch (e) {
+ callback(false, e);
+ return;
+ }
- callback(false, null);
- }));
- }));
- }));
+ callback(false, null);
+ });
+ });
+ });
}
canEdit() {
@@ -1315,78 +1280,73 @@ const SkydriveDocument = class SkydriveDocument extends DocCommon {
let zpj_id = this.identifier.substring(SKYDRIVE_PREFIX.length);
service.query_info_from_id_async
- (zpj_id, cancellable,
- Lang.bind(this,
- function(object, res) {
- let entry = null;
- let exception = null;
+ (zpj_id, cancellable, (object, res) => {
+ let entry = null;
+ let exception = null;
- try {
- entry = object.query_info_from_id_finish(res);
- } catch (e) {
- exception = e;
- }
+ try {
+ entry = object.query_info_from_id_finish(res);
+ } catch (e) {
+ exception = e;
+ }
- callback(entry, service, exception);
- }));
+ callback(entry, service, exception);
+ });
}
downloadImpl(localFile, cancellable, callback) {
- this._createZpjEntry(cancellable, Lang.bind(this,
- function(entry, service, error) {
- if (error) {
- callback(false, error);
+ this._createZpjEntry(cancellable, (entry, service, error) => {
+ if (error) {
+ callback(false, error);
+ return;
+ }
+
+ Utils.debug('Created ZpjEntry for ' + this.id);
+
+ service.download_file_to_stream_async(entry, cancellable, (object, res) => {
+ let inputStream;
+
+ try {
+ inputStream = object.download_file_to_stream_finish(res);
+ } catch (e) {
+ callback(false, e);
return;
}
- Utils.debug('Created ZpjEntry for ' + this.id);
-
- service.download_file_to_stream_async(entry, cancellable, Lang.bind(this,
- function(object, res) {
- let inputStream;
+ localFile.replace_async(
+ null,
+ false,
+ Gio.FileCreateFlags.PRIVATE,
+ GLib.PRIORITY_DEFAULT,
+ cancellable,
+ (object, res) => {
+ let outputStream;
try {
- inputStream = object.download_file_to_stream_finish(res);
+ outputStream = object.replace_finish(res);
} catch (e) {
callback(false, e);
return;
}
- localFile.replace_async(null,
- false,
- Gio.FileCreateFlags.PRIVATE,
- GLib.PRIORITY_DEFAULT,
- cancellable,
- Lang.bind(this,
- function(object, res) {
- let outputStream;
-
+ outputStream.splice_async(
+ inputStream,
+ Gio.OutputStreamSpliceFlags.CLOSE_SOURCE |
Gio.OutputStreamSpliceFlags.CLOSE_TARGET,
+ GLib.PRIORITY_DEFAULT,
+ cancellable,
+ (object, res) => {
try {
- outputStream = object.replace_finish(res);
+ object.splice_finish(res);
} catch (e) {
callback(false, e);
return;
}
- outputStream.splice_async(inputStream,
- Gio.OutputStreamSpliceFlags.CLOSE_SOURCE |
- Gio.OutputStreamSpliceFlags.CLOSE_TARGET,
- GLib.PRIORITY_DEFAULT,
- cancellable,
- Lang.bind(this,
- function(object, res) {
- try {
- object.splice_finish(res);
- } catch (e) {
- callback(false, e);
- return;
- }
-
- callback(false, null);
- }));
- }));
- }));
- }));
+ callback(false, null);
+ });
+ });
+ });
+ });
}
updateTypeDescription() {
@@ -1435,8 +1395,7 @@ var DocumentManager = class DocumentManager extends Manager.BaseManager {
// navigate to the active document or collection
this._collectionPath = [];
- Application.changeMonitor.connect('changes-pending',
- Lang.bind(this, this._onChangesPending));
+ Application.changeMonitor.connect('changes-pending', this._onChangesPending.bind(this));
}
_onChangesPending(monitor, changes) {
@@ -1463,13 +1422,12 @@ var DocumentManager = class DocumentManager extends Manager.BaseManager {
_onDocumentCreated(urn) {
let job = new TrackerUtils.SingleItemJob(urn, Application.queryBuilder);
- job.run(Query.QueryFlags.NONE, Lang.bind(this,
- function(cursor) {
- if (!cursor)
- return;
+ job.run(Query.QueryFlags.NONE, (cursor) => {
+ if (!cursor)
+ return;
- this.addDocumentFromCursor(cursor);
- }));
+ this.addDocumentFromCursor(cursor);
+ });
}
_identifierIsGoogle(identifier) {
@@ -1644,7 +1602,7 @@ var DocumentManager = class DocumentManager extends Manager.BaseManager {
this._loaderCancellable = new Gio.Cancellable();
this._requestPreview(doc);
this.emit('load-started', doc);
- doc.load(passwd, this._loaderCancellable, Lang.bind(this, this._onDocumentLoaded));
+ doc.load(passwd, this._loaderCancellable, this._onDocumentLoaded.bind(this));
}
reloadActiveItem(passwd) {
diff --git a/src/edit.js b/src/edit.js
index 15601aa9..aff608d6 100644
--- a/src/edit.js
+++ b/src/edit.js
@@ -23,7 +23,6 @@ const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const _ = imports.gettext.gettext;
-const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Application = imports.application;
@@ -44,7 +43,7 @@ var EditView = GObject.registerClass(class EditView extends Preview.Preview {
createActions() {
return [
{ name: 'view-current',
- callback: Lang.bind(this, this._viewCurrent) }
+ callback: this._viewCurrent.bind(this) }
];
}
@@ -54,7 +53,7 @@ var EditView = GObject.registerClass(class EditView extends Preview.Preview {
this._webView = new WebKit.WebView();
overlay.add(this._webView);
this._webView.show();
- this._webView.connect('notify::estimated-load-progress', Lang.bind(this, this._onProgressChanged));
+ this._webView.connect('notify::estimated-load-progress', this._onProgressChangedbind(this));
this._progressBar = new Gtk.ProgressBar({ halign: Gtk.Align.FILL,
valign: Gtk.Align.START });
@@ -105,7 +104,7 @@ var EditView = GObject.registerClass(class EditView extends Preview.Preview {
if (progress == 1.0 || !loading) {
if (!this._timeoutId)
- this._timeoutId = Mainloop.timeout_add(500, Lang.bind(this, this._onTimeoutExpired));
+ this._timeoutId = Mainloop.timeout_add(500, this._onTimeoutExpiredbind(this));
} else {
if (this._timeoutId) {
Mainloop.source_remove(this._timeoutId);
diff --git a/src/embed.js b/src/embed.js
index 399ae0ba..92bf3694 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -19,7 +19,6 @@
*
*/
-const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Application = imports.application;
@@ -130,8 +129,7 @@ const View = GObject.registerClass(class View extends Gtk.Overlay {
this._toolbar = this.view.createToolbar(this._stack);
if (this._toolbar.searchbar)
- this._toolbar.searchbar.connect('activate-result',
- Lang.bind(this, this._onActivateResult));
+ this._toolbar.searchbar.connect('activate-result', this._onActivateResult.bind(this));
this._window.get_titlebar().add(this._toolbar);
}
}
@@ -156,16 +154,10 @@ var Embed = GObject.registerClass(class Embed extends Gtk.Box {
this._view = new View(mainWindow);
this.pack_end(this._view, true, true, 0);
- Application.modeController.connect('window-mode-changed',
- Lang.bind(this, this._onWindowModeChanged));
-
- Application.searchTypeManager.connect('active-changed',
- Lang.bind(this, this._onSearchChanged));
- Application.sourceManager.connect('active-changed',
- Lang.bind(this, this._onSearchChanged));
-
- Application.searchController.connect('search-string-changed',
- Lang.bind(this, this._onSearchChanged));
+ Application.modeController.connect('window-mode-changed', this._onWindowModeChanged.bind(this));
+ Application.searchTypeManager.connect('active-changed', this._onSearchChanged.bind(this));
+ Application.sourceManager.connect('active-changed', this._onSearchChanged.bind(this));
+ Application.searchController.connect('search-string-changed', this._onSearchChanged.bind(this));
this._view.windowMode = Application.modeController.getWindowMode();
}
diff --git a/src/evinceview.js b/src/evinceview.js
index 6d82c730..44c7ec2b 100644
--- a/src/evinceview.js
+++ b/src/evinceview.js
@@ -28,7 +28,6 @@ const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const _ = imports.gettext.gettext;
-const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Application = imports.application;
@@ -90,9 +89,9 @@ var EvinceView = GObject.registerClass(class EvinceView extends Preview.Preview
_places() {
let dialog = new Places.PlacesDialog(this._model, this._bookmarks);
- dialog.connect('response', Lang.bind(this, function(widget, response) {
+ dialog.connect('response', (widget, response) => {
widget.destroy();
- }));
+ });
}
_findStateChanged(action) {
@@ -150,56 +149,56 @@ var EvinceView = GObject.registerClass(class EvinceView extends Preview.Preview
createActions() {
let actions = [
{ name: 'zoom-in',
- callback: Lang.bind(this, this._zoomIn),
+ callback: this._zoomIn.bind(this),
accels: ['<Primary>plus', '<Primary>equal'] },
{ name: 'zoom-out',
- callback: Lang.bind(this, this._zoomOut),
+ callback: this._zoomOut.bind(this),
accels: ['<Primary>minus'] },
{ name: 'copy',
- callback: Lang.bind(this, this._copy),
+ callback: this._copy.bind(this),
accels: ['<Primary>c'] },
{ name: 'rotate-left',
- callback: Lang.bind(this, this._rotateLeft),
+ callback: this._rotateLeft.bind(this),
accels: ['<Primary>Left'] },
{ name: 'rotate-right',
- callback: Lang.bind(this, this._rotateRight),
+ callback: this._rotateRight.bind(this),
accels: ['<Primary>Right'] },
{ name: 'find',
callback: Utils.actionToggleCallback,
state: GLib.Variant.new('b', false),
- stateChanged: Lang.bind(this, this._findStateChanged),
+ stateChanged: this._findStateChanged.bind(this),
accels: ['<Primary>f'] },
{ name: 'find-prev',
- callback: Lang.bind(this, this.findPrev),
+ callback: this.findPrev.bind(this),
accels: ['<Shift><Primary>g'] },
{ name: 'find-next',
- callback: Lang.bind(this, this.findNext),
+ callback: this.findNext.bind(this),
accels: ['<Primary>g'] },
{ name: 'places',
- callback: Lang.bind(this, this._places),
+ callback: this._places.bind(this),
accels: ['<Primary>b'] },
{ name: 'bookmark-page',
callback: Utils.actionToggleCallback,
state: GLib.Variant.new('b', false),
- stateChanged: Lang.bind(this, this._bookmarkStateChanged),
+ stateChanged: this._bookmarkStateChanged.bind(this),
accels: ['<Primary>d'] },
{ name: 'edit-current',
- callback: Lang.bind(this, this._edit) },
+ callback: this._edit.bind(this) },
{ name: 'print-current',
- callback: Lang.bind(this, this._print),
+ callback: this._print.bind(this),
accels: ['<Primary>p'] },
{ name: 'scroll-up',
- callback: Lang.bind(this, this._scrollUp),
+ callback: this._scrollUp.bind(this),
accels: ['Page_Up'] },
{ name: 'scroll-down',
- callback: Lang.bind(this, this._scrollDown),
+ callback: this._scrollDown.bind(this),
accels: ['Page_Down'] }
];
actions.push({ name: 'present-current',
callback: Utils.actionToggleCallback,
state: GLib.Variant.new('b', false),
- stateChanged: Lang.bind(this, this._presentStateChanged),
+ stateChanged: this._presentStateChanged.bind(this),
accels: ['F5'] });
return actions;
@@ -217,27 +216,21 @@ var EvinceView = GObject.registerClass(class EvinceView extends Preview.Preview
let sw = new Gtk.ScrolledWindow({ hexpand: true,
vexpand: true });
sw.get_style_context().add_class('documents-scrolledwin');
- sw.get_hscrollbar().connect('button-press-event', Lang.bind(this, this._onScrollbarClick));
- sw.get_vscrollbar().connect('button-press-event', Lang.bind(this, this._onScrollbarClick));
- sw.get_hadjustment().connect('value-changed', Lang.bind(this, this._onAdjustmentChanged));
- sw.get_vadjustment().connect('value-changed', Lang.bind(this, this._onAdjustmentChanged));
+ sw.get_hscrollbar().connect('button-press-event', this._onScrollbarClick.bind(this));
+ sw.get_vscrollbar().connect('button-press-event', this._onScrollbarClick.bind(this));
+ sw.get_hadjustment().connect('value-changed', this._onAdjustmentChanged.bind(this));
+ sw.get_vadjustment().connect('value-changed', this._onAdjustmentChanged.bind(this));
this._evView = EvView.View.new();
sw.add(this._evView);
this._evView.show();
- this._evView.connect('notify::can-zoom-in', Lang.bind(this,
- this._onCanZoomInChanged));
- this._evView.connect('notify::can-zoom-out', Lang.bind(this,
- this._onCanZoomOutChanged));
- this._evView.connect('button-press-event', Lang.bind(this,
- this._onButtonPressEvent));
- this._evView.connect('button-release-event', Lang.bind(this,
- this._onButtonReleaseEvent));
- this._evView.connect('selection-changed', Lang.bind(this,
- this._onViewSelectionChanged));
- this._evView.connect('external-link', Lang.bind(this,
- this._handleExternalLink));
+ this._evView.connect('notify::can-zoom-in', this._onCanZoomInChanged.bind(this));
+ this._evView.connect('notify::can-zoom-out', this._onCanZoomOutChanged.bind(this));
+ this._evView.connect('button-press-event', this._onButtonPressEvent.bind(this));
+ this._evView.connect('button-release-event', this._onButtonReleaseEvent.bind(this));
+ this._evView.connect('selection-changed', this._onViewSelectionChanged.bind(this));
+ this._evView.connect('external-link', this._handleExternalLink.bind(this));
return sw;
}
@@ -263,7 +256,7 @@ var EvinceView = GObject.registerClass(class EvinceView extends Preview.Preview
docModel.set_continuous(false);
docModel.set_page_layout(EvView.PageLayout.AUTOMATIC);
- this._model.connect('page-changed', Lang.bind(this, this._onPageChanged));
+ this._model.connect('page-changed', this._onPageChanged.bind(this));
this._metadata = this._loadMetadata();
if (this._metadata)
@@ -344,7 +337,7 @@ var EvinceView = GObject.registerClass(class EvinceView extends Preview.Preview
_showPresentation(output) {
this._presentation = new Presentation.PresentationWindow(this._model);
- this._presentation.connect('destroy', Lang.bind(this, this._hidePresentation));
+ this._presentation.connect('destroy', this._hidePresentation.bind(this));
if (output)
this._presentation.setOutput(output);
}
@@ -355,15 +348,12 @@ var EvinceView = GObject.registerClass(class EvinceView extends Preview.Preview
this._showPresentation();
} else {
let chooser = new Presentation.PresentationOutputChooser(outputs);
- chooser.connect('output-activated', Lang.bind(this,
- function(chooser, output) {
- if (output) {
- this._showPresentation(output);
- } else {
- this._hidePresentation();
- }
- }));
-
+ chooser.connect('output-activated', (chooser, output) => {
+ if (output)
+ this._showPresentation(output);
+ else
+ this._hidePresentation();
+ });
}
}
@@ -509,7 +499,7 @@ var EvinceView = GObject.registerClass(class EvinceView extends Preview.Preview
let evDoc = this._model.get_document();
this._jobFind = EvView.JobFind.new(evDoc, this._model.get_page(), evDoc.get_n_pages(),
str, false);
- this._jobFind.connect('updated', Lang.bind(this, this._onSearchJobUpdated));
+ this._jobFind.connect('updated', this._onSearchJobUpdated.bind(this));
this._evView.find_started(this._jobFind);
this._jobFind.scheduler_push_job(EvView.JobPriority.PRIORITY_NONE);
@@ -593,7 +583,7 @@ const EvinceViewNavControls = class EvinceViewNavControls extends Preview.Previe
setModel(model) {
this.barWidget.document_model = model;
- model.connect('page-changed', Lang.bind(this, this._updateVisibility));
+ model.connect('page-changed', this._updateVisibility.bind(this));
}
}
diff --git a/src/fullscreenAction.js b/src/fullscreenAction.js
index d5b89913..1a978ef4 100644
--- a/src/fullscreenAction.js
+++ b/src/fullscreenAction.js
@@ -25,8 +25,6 @@ const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
-
var FullscreenAction = GObject.registerClass({
Implements: [Gio.Action],
Properties: {
@@ -60,8 +58,7 @@ var FullscreenAction = GObject.registerClass({
_connectToWindow() {
if (this._window) {
- this._windowStateId = this._window.connect('window-state-event',
- Lang.bind(this, this._onWindowStateEvent));
+ this._windowStateId = this._window.connect('window-state-event',
this._onWindowStateEvent.bind(this));
this._onWindowStateEvent();
}
}
diff --git a/src/lokview.js b/src/lokview.js
index ba363903..d0d3afa6 100644
--- a/src/lokview.js
+++ b/src/lokview.js
@@ -34,8 +34,6 @@ const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const _ = imports.gettext.gettext;
-const Lang = imports.lang;
-
const Documents = imports.documents;
const Preview = imports.preview;
const Utils = imports.utils;
@@ -111,13 +109,13 @@ var LOKView = GObject.registerClass(class LOKView extends Preview.Preview {
createActions() {
return [
{ name: 'zoom-in',
- callback: Lang.bind(this, this._zoomIn),
+ callback: this._zoomIn.bind(this),
accels: ['<Primary>plus', '<Primary>equal'] },
{ name: 'zoom-out',
- callback: Lang.bind(this, this._zoomOut),
+ callback: this._zoomOut.bind(this),
accels: ['<Primary>minus'] },
{ name: 'copy',
- callback: Lang.bind(this, this._copy),
+ callback: this._copy.bind(this),
accels: ['<Primary>c'] }
];
}
@@ -132,11 +130,11 @@ var LOKView = GObject.registerClass(class LOKView extends Preview.Preview {
sw.add(this._lokview);
this._lokview.show();
- this._lokview.connect('button-press-event', Lang.bind(this, this._onButtonPressEvent));
- this._lokview.connect('load-changed', Lang.bind(this, this._onProgressChanged));
- this._lokview.connect('text-selection', Lang.bind(this, this._onTextSelection));
- this._lokview.connect('notify::can-zoom-in', Lang.bind(this, this._onCanZoomInChanged));
- this._lokview.connect('notify::can-zoom-out', Lang.bind(this, this._onCanZoomOutChanged));
+ this._lokview.connect('button-press-event', this._onButtonPressEvent.bind(this));
+ this._lokview.connect('load-changed', this._onProgressChanged.bind(this));
+ this._lokview.connect('text-selection', this._onTextSelection.bind(this));
+ this._lokview.connect('notify::can-zoom-in', this._onCanZoomInChanged.bind(this));
+ this._lokview.connect('notify::can-zoom-out', this._onCanZoomOutChanged.bind(this));
}
return sw;
@@ -148,7 +146,7 @@ var LOKView = GObject.registerClass(class LOKView extends Preview.Preview {
if (!isAvailable())
return;
this._doc = doc;
- this._lokview.open_document(doc.uriToLoad, '{}', null, Lang.bind(this, this._onDocumentOpened));
+ this._lokview.open_document(doc.uriToLoad, '{}', null, this._onDocumentOpened.bind(this));
this._progressBar.show();
}
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index 7da80b3e..e2974ca9 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -28,8 +28,6 @@ const Gtk = imports.gi.Gtk;
const Gettext = imports.gettext;
const _ = imports.gettext.gettext;
-const Lang = imports.lang;
-
const Application = imports.application;
const Searchbar = imports.searchbar;
@@ -50,22 +48,18 @@ var MainToolbar = GObject.registerClass(class MainToolbar extends Gtk.Box {
if (this.searchbar)
this.add(this.searchbar);
- let loadStartedId = Application.documentManager.connect('load-started', Lang.bind(this,
- function() {
- this._handleEvent = true;
- }));
-
- let loadErrorId = Application.documentManager.connect('load-error',
- Lang.bind(this, this._onLoadErrorOrPassword));
- let passwordNeededId = Application.documentManager.connect('password-needed',
- Lang.bind(this, this._onLoadErrorOrPassword));
-
- this.connect('destroy', Lang.bind(this,
- function() {
- Application.documentManager.disconnect(loadStartedId);
- Application.documentManager.disconnect(loadErrorId);
- Application.documentManager.disconnect(passwordNeededId);
- }));
+ let loadStartedId = Application.documentManager.connect('load-started', () => {
+ this._handleEvent = true;
+ });
+
+ let loadErrorId = Application.documentManager.connect('load-error',
this._onLoadErrorOrPassword.bind(this));
+ let passwordNeededId = Application.documentManager.connect('password-needed',
this._onLoadErrorOrPassword.bind(this));
+
+ this.connect('destroy', () => {
+ Application.documentManager.disconnect(loadStartedId);
+ Application.documentManager.disconnect(loadErrorId);
+ Application.documentManager.disconnect(passwordNeededId);
+ });
}
createSearchbar() {
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 74b49709..3a52b776 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -25,7 +25,6 @@ const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Application = imports.application;
@@ -68,11 +67,11 @@ var MainWindow = GObject.registerClass(class MainWindow extends Gtk.ApplicationW
if (Application.settings.get_boolean('window-maximized'))
this.maximize();
- this.connect('delete-event', Lang.bind(this, this._quit));
- this.connect('button-press-event', Lang.bind(this, this._onButtonPressEvent));
- this.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
- this.connect('configure-event', Lang.bind(this, this._onConfigureEvent));
- this.connect('window-state-event', Lang.bind(this, this._onWindowStateEvent));
+ this.connect('delete-event', this._quit.bind(this));
+ this.connect('button-press-event', this._onButtonPressEvent.bind(this));
+ this.connect('key-press-event', this._onKeyPressEvent.bind(this));
+ this.connect('configure-event', this._onConfigureEvent.bind(this));
+ this.connect('window-state-event', this._onWindowStateEvent.bind(this));
this._embed = new Embed.Embed(this);
this.add(this._embed);
@@ -107,12 +106,11 @@ var MainWindow = GObject.registerClass(class MainWindow extends Gtk.ApplicationW
this._configureId = 0;
}
- this._configureId = Mainloop.timeout_add(_CONFIGURE_ID_TIMEOUT, Lang.bind(this,
- function() {
- this._configureId = 0;
- this._saveWindowGeometry();
- return false;
- }));
+ this._configureId = Mainloop.timeout_add(_CONFIGURE_ID_TIMEOUT, () => {
+ this._configureId = 0;
+ this._saveWindowGeometry();
+ return false;
+ });
}
_onWindowStateEvent(widget, event) {
diff --git a/src/manager.js b/src/manager.js
index b9b3ea2d..81dc3ace 100644
--- a/src/manager.js
+++ b/src/manager.js
@@ -23,7 +23,6 @@ const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
-const Lang = imports.lang;
const Signals = imports.signals;
var BaseManager = class BaseManager {
@@ -177,8 +176,8 @@ var BaseModel = GObject.registerClass(class BaseModel extends Gio.Menu {
_init(manager) {
super._init();
this._manager = manager;
- this._manager.connect('item-added', Lang.bind(this, this._refreshModel));
- this._manager.connect('item-removed', Lang.bind(this, this._refreshModel));
+ this._manager.connect('item-added', this._refreshModel.bind(this));
+ this._manager.connect('item-removed', this._refreshModel.bind(this));
this._refreshModel();
}
diff --git a/src/notifications.js b/src/notifications.js
index 02838e8f..4629b832 100644
--- a/src/notifications.js
+++ b/src/notifications.js
@@ -29,7 +29,6 @@ const _ = imports.gettext.gettext;
const Application = imports.application;
const WindowMode = imports.windowMode;
-const Lang = imports.lang;
const Mainloop = imports.mainloop;
var DELETE_TIMEOUT = 10; // seconds
@@ -60,16 +59,14 @@ var DeleteNotification = class DeleteNotification {
let undo = new Gtk.Button({ label: _("Undo"),
valign: Gtk.Align.CENTER });
this.widget.add(undo);
- undo.connect('clicked', Lang.bind(this,
- function() {
- this._docs.forEach(Lang.bind(this,
- function(doc) {
- Application.documentManager.addItem(doc);
- }));
+ undo.connect('clicked', () => {
+ this._docs.forEach((doc) => {
+ Application.documentManager.addItem(doc);
+ });
- this._removeTimeout();
- this.widget.destroy();
- }));
+ this._removeTimeout();
+ this.widget.destroy();
+ });
let close = new Gtk.Button({ image: new Gtk.Image({ icon_name: 'window-close-symbolic',
pixel_size: 16,
@@ -79,22 +76,20 @@ var DeleteNotification = class DeleteNotification {
focus_on_click: false,
relief: Gtk.ReliefStyle.NONE });
this.widget.add(close);
- close.connect('clicked', Lang.bind(this, this._deleteItems));
+ close.connect('clicked', this._deleteItems.bind(this));
Application.notificationManager.addNotification(this);
- this._timeoutId = Mainloop.timeout_add_seconds(DELETE_TIMEOUT, Lang.bind(this,
- function() {
- this._timeoutId = 0;
- this._deleteItems();
- return false;
- }));
+ this._timeoutId = Mainloop.timeout_add_seconds(DELETE_TIMEOUT, () => {
+ this._timeoutId = 0;
+ this._deleteItems();
+ return false;
+ });
}
_deleteItems() {
- this._docs.forEach(Lang.bind(this,
- function(doc) {
- doc.trash();
- }))
+ this._docs.forEach((doc) => {
+ doc.trash();
+ });
this._removeTimeout();
this.widget.destroy();
@@ -114,10 +109,8 @@ var PrintNotification = class PrintNotification {
this._printOp = printOp;
this._doc = doc;
- this._printOp.connect('begin-print',
- Lang.bind(this, this._onPrintBegin));
- this._printOp.connect('status-changed',
- Lang.bind(this, this._onPrintStatus));
+ this._printOp.connect('begin-print', this._onPrintBegin.bind(this));
+ this._printOp.connect('status-changed', this._onPrintStatus.bind(this));
}
_onPrintBegin() {
@@ -138,11 +131,10 @@ var PrintNotification = class PrintNotification {
});
this.widget.attach_next_to(this._stopButton, this._statusLabel,
Gtk.PositionType.RIGHT, 1, 2);
- this._stopButton.connect('clicked', Lang.bind(this,
- function() {
- this._printOp.cancel();
- this.widget.destroy();
- }));
+ this._stopButton.connect('clicked', () => {
+ this._printOp.cancel();
+ this.widget.destroy();
+ });
Application.notificationManager.addNotification(this);
}
@@ -173,15 +165,15 @@ const IndexingNotification = class IndexingNotification {
try {
this._manager = TrackerControl.MinerManager.new_full(false);
- this._manager.connect('miner-progress', Lang.bind(this, this._checkNotification));
+ this._manager.connect('miner-progress', this._checkNotification.bind(this));
} catch(e) {
logError(e, 'Unable to create a TrackerMinerManager, indexing progress ' +
'notification won\'t work');
return;
}
- Application.application.connect('miners-changed', Lang.bind(this, this._checkNotification));
- Application.modeController.connect('window-mode-changed', Lang.bind(this, this._checkNotification));
+ Application.application.connect('miners-changed', this._checkNotification.bind(this));
+ Application.modeController.connect('window-mode-changed', this._checkNotification.bind(this));
}
_checkNotification() {
@@ -211,7 +203,7 @@ const IndexingNotification = class IndexingNotification {
_("Some documents might not be available during this process"));
} else if (isIndexingRemote) {
this._removeTimeout();
- this._timeoutId = Mainloop.timeout_add_seconds(REMOTE_MINER_TIMEOUT, Lang.bind(this,
this._onTimeoutExpired));
+ this._timeoutId = Mainloop.timeout_add_seconds(REMOTE_MINER_TIMEOUT,
this._onTimeoutExpired.bind(this));
} else {
this._destroy(false);
}
@@ -274,10 +266,9 @@ const IndexingNotification = class IndexingNotification {
valign: Gtk.Align.CENTER,
focus_on_click: false,
relief: Gtk.ReliefStyle.NONE });
- close.connect('clicked', Lang.bind(this,
- function() {
- this._destroy(true);
- }));
+ close.connect('clicked', () => {
+ this._destroy(true);
+ });
this.widget.add(close);
Application.notificationManager.addNotification(this);
@@ -339,7 +330,7 @@ var NotificationManager = GObject.registerClass(class NotificationManager extend
addNotification(notification) {
this._grid.add(notification.widget);
- notification.widget.connect('destroy', Lang.bind(this, this._onWidgetDestroy));
+ notification.widget.connect('destroy', this._onWidgetDestroy.bind(this));
this.show_all();
this.reveal_child = true;
diff --git a/src/overview.js b/src/overview.js
index 328fe7ee..968da9e2 100644
--- a/src/overview.js
+++ b/src/overview.js
@@ -29,7 +29,6 @@ const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const _ = imports.gettext.gettext;
-const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Application = imports.application;
@@ -89,18 +88,15 @@ const ViewModel = GObject.registerClass(class ViewModel extends Gtk.ListStore {
this._mode = windowMode;
this._rowRefKey = "row-ref-" + this._mode;
- Application.documentManager.connect('item-added',
- Lang.bind(this, this._onItemAdded));
- Application.documentManager.connect('item-removed',
- Lang.bind(this, this._onItemRemoved));
+ Application.documentManager.connect('item-added', this._onItemAdded.bind(this));
+ Application.documentManager.connect('item-removed', this._onItemRemoved.bind(this));
[ this._offsetController, this._trackerController ] = getController(this._mode);
- this._trackerController.connect('query-status-changed', Lang.bind(this,
- function(o, status) {
- if (!status)
- return;
- this._clear();
- }));
+ this._trackerController.connect('query-status-changed', (o, status) => {
+ if (!status)
+ return;
+ this._clear();
+ });
// populate with the initial items
let items = Application.documentManager.getItems();
@@ -142,17 +138,16 @@ const ViewModel = GObject.registerClass(class ViewModel extends Gtk.ListStore {
// Results" page will not work correctly.
this._resetCount();
- this.foreach(Lang.bind(this,
- function(model, path, iter) {
- let id = model.get_value(iter, Gd.MainColumns.ID);
+ this.foreach((model, path, iter) => {
+ let id = model.get_value(iter, Gd.MainColumns.ID);
- if (id == doc.id) {
- this.remove(iter);
- return true;
- }
+ if (id == doc.id) {
+ this.remove(iter);
+ return true;
+ }
- return false;
- }));
+ return false;
+ });
doc.rowRefs[this._rowRefKey] = null;
}
@@ -206,13 +201,13 @@ const ViewModel = GObject.registerClass(class ViewModel extends Gtk.ListStore {
if (!activeCollection || this._mode != windowMode) {
if (this._mode == WindowMode.WindowMode.COLLECTIONS && !doc.collection
|| this._mode == WindowMode.WindowMode.DOCUMENTS && doc.collection) {
- this._infoUpdatedIds[doc.id] = doc.connect('info-updated', Lang.bind(this,
this._onInfoUpdated));
+ this._infoUpdatedIds[doc.id] = doc.connect('info-updated', this._onInfoUpdated.bind(this));
return;
}
}
this._addItem(doc);
- this._infoUpdatedIds[doc.id] = doc.connect('info-updated', Lang.bind(this, this._onInfoUpdated));
+ this._infoUpdatedIds[doc.id] = doc.connect('info-updated', this._onInfoUpdated.bind(this));
}
_onItemRemoved(source, doc) {
@@ -223,12 +218,11 @@ const ViewModel = GObject.registerClass(class ViewModel extends Gtk.ListStore {
_resetCount() {
if (this._resetCountId == 0) {
- this._resetCountId = Mainloop.timeout_add(_RESET_COUNT_TIMEOUT, Lang.bind(this,
- function() {
- this._resetCountId = 0;
- this._offsetController.resetItemCount();
- return false;
- }));
+ this._resetCountId = Mainloop.timeout_add(_RESET_COUNT_TIMEOUT, () => {
+ this._resetCountId = 0;
+ this._offsetController.resetItemCount();
+ return false;
+ });
}
}
});
@@ -293,29 +287,28 @@ const EmptyResultsBox = GObject.registerClass(class EmptyResultsBox extends Gtk.
use_markup: true });
this.add(details);
- details.connect('activate-link', Lang.bind(this,
- function(label, uri) {
- if (uri != 'system-settings')
- return false;
+ details.connect('activate-link', (label, uri) => {
+ if (uri != 'system-settings')
+ return false;
- try {
- let app = Gio.AppInfo.create_from_commandline(
- 'gnome-control-center online-accounts', null, 0);
+ try {
+ let app = Gio.AppInfo.create_from_commandline(
+ 'gnome-control-center online-accounts', null, 0);
- let screen = this.get_screen();
- let display = screen ? screen.get_display() : Gdk.Display.get_default();
- let ctx = display.get_app_launch_context();
+ let screen = this.get_screen();
+ let display = screen ? screen.get_display() : Gdk.Display.get_default();
+ let ctx = display.get_app_launch_context();
- if (screen)
- ctx.set_screen(screen);
+ if (screen)
+ ctx.set_screen(screen);
- app.launch([], ctx);
- } catch(e) {
- logError(e, 'Unable to launch gnome-control-center');
- }
+ app.launch([], ctx);
+ } catch(e) {
+ logError(e, 'Unable to launch gnome-control-center');
+ }
- return true;
- }));
+ return true;
+ });
}
});
@@ -325,61 +318,52 @@ const OverviewSearchbar = GObject.registerClass(class OverviewSearchbar extends
super._init();
- let sourcesId = Application.sourceManager.connect('active-changed',
- Lang.bind(this, this._onActiveSourceChanged));
- let searchTypeId = Application.searchTypeManager.connect('active-changed',
- Lang.bind(this, this._onActiveTypeChanged));
- let searchMatchId = Application.searchMatchManager.connect('active-changed',
- Lang.bind(this, this._onActiveMatchChanged));
- let collectionId = Application.documentManager.connect('active-collection-changed',
- Lang.bind(this, this._onActiveCollectionChanged));
+ let sourcesId = Application.sourceManager.connect('active-changed',
this._onActiveSourceChanged.bind(this));
+ let searchTypeId = Application.searchTypeManager.connect('active-changed',
this._onActiveTypeChanged.bind(this));
+ let searchMatchId = Application.searchMatchManager.connect('active-changed',
this._onActiveMatchChanged.bind(this));
+ let collectionId = Application.documentManager.connect('active-collection-changed',
this._onActiveCollectionChanged.bind(this));
this._onActiveSourceChanged();
this._onActiveTypeChanged();
this._onActiveMatchChanged();
let searchAction = this._view.getAction('search');
- this.connect('notify::search-mode-enabled', Lang.bind(this, function() {
+ this.connect('notify::search-mode-enabled', () => {
let searchEnabled = this.search_mode_enabled;
searchAction.change_state(GLib.Variant.new('b', searchEnabled));
- }));
+ });
// connect to the search action state for visibility
- let searchStateId = searchAction.connect('notify::state', Lang.bind(this,
this._onActionStateChanged));
+ let searchStateId = searchAction.connect('notify::state', this._onActionStateChanged.bind(this));
this._onActionStateChanged(searchAction);
this.searchEntry.set_text(Application.searchController.getString());
- this.connect('destroy', Lang.bind(this,
- function() {
- Application.sourceManager.disconnect(sourcesId);
- Application.searchTypeManager.disconnect(searchTypeId);
- Application.searchMatchManager.disconnect(searchMatchId);
- Application.documentManager.disconnect(collectionId);
+ this.connect('destroy', () => {
+ Application.sourceManager.disconnect(sourcesId);
+ Application.searchTypeManager.disconnect(searchTypeId);
+ Application.searchMatchManager.disconnect(searchMatchId);
+ Application.documentManager.disconnect(collectionId);
- searchAction.disconnect(searchStateId);
- }));
+ searchAction.disconnect(searchStateId);
+ });
}
createSearchWidget() {
// create the search entry
this.searchEntry = new Gd.TaggedEntry({ width_request: 500 });
- this.searchEntry.connect('tag-clicked',
- Lang.bind(this, this._onTagClicked));
- this.searchEntry.connect('tag-button-clicked',
- Lang.bind(this, this._onTagButtonClicked));
+ this.searchEntry.connect('tag-clicked', this._onTagClicked.bind(this));
+ this.searchEntry.connect('tag-button-clicked', this._onTagButtonClicked.bind(this));
this._sourceTag = new Gd.TaggedEntryTag();
this._typeTag = new Gd.TaggedEntryTag();
this._matchTag = new Gd.TaggedEntryTag();
// connect to search string changes in the controller
- this._searchChangedId = Application.searchController.connect('search-string-changed',
- Lang.bind(this, this._onSearchStringChanged));
+ this._searchChangedId = Application.searchController.connect('search-string-changed',
this._onSearchStringChanged.bind(this));
- this.searchEntry.connect('destroy', Lang.bind(this,
- function() {
- Application.searchController.disconnect(this._searchChangedId);
- }));
+ this.searchEntry.connect('destroy', () => {
+ Application.searchController.disconnect(this._searchChangedId);
+ });
// create the dropdown button
let dropdown = new Searchbar.Dropdown();
@@ -403,8 +387,7 @@ const OverviewSearchbar = GObject.registerClass(class OverviewSearchbar extends
Application.searchController.setString(currentText);
// connect to search string changes in the controller
- this._searchChangedId = Application.searchController.connect('search-string-changed',
- Lang.bind(this, this._onSearchStringChanged));
+ this._searchChangedId = Application.searchController.connect('search-string-changed',
this._onSearchStringChanged.bind(this));
}
_onSearchStringChanged(controller, string) {
@@ -514,22 +497,20 @@ const OverviewToolbar = GObject.registerClass(class OverviewToolbar extends Main
// setup listeners to mode changes that affect the toolbar layout
let selectionModeAction = this._view.getAction('selection-mode');
- let selectionModeStateId = selectionModeAction.connect('notify::state',
- Lang.bind(this, this._resetToolbarMode));
+ let selectionModeStateId = selectionModeAction.connect('notify::state',
this._resetToolbarMode.bind(this));
this._resetToolbarMode();
this._activeCollection = Application.documentManager.getActiveCollection();
if (this._activeCollection)
- this._activeCollection.connect('info-updated', Lang.bind(this, this._setToolbarTitle));
+ this._activeCollection.connect('info-updated', this._setToolbarTitle.bind(this));
- this.connect('destroy', Lang.bind(this,
- function() {
- if (this._infoUpdatedId != 0)
- this._activeCollection.disconnect(this._infoUpdatedId);
+ this.connect('destroy', () => {
+ if (this._infoUpdatedId != 0)
+ this._activeCollection.disconnect(this._infoUpdatedId);
- this._clearStateData();
- selectionModeAction.disconnect(selectionModeStateId);
- }));
+ this._clearStateData();
+ selectionModeAction.disconnect(selectionModeStateId);
+ });
}
_addViewMenuButton() {
@@ -542,8 +523,7 @@ const OverviewToolbar = GObject.registerClass(class OverviewToolbar extends Main
popover: viewMenu });
this.toolbar.pack_end(this._viewMenuButton);
- this._viewSettingsId = Application.settings.connect('changed::view-as',
- Lang.bind(this, this._updateViewMenuButton));
+ this._viewSettingsId = Application.settings.connect('changed::view-as',
this._updateViewMenuButton.bind(this));
this._updateViewMenuButton();
}
@@ -598,8 +578,7 @@ const OverviewToolbar = GObject.registerClass(class OverviewToolbar extends Main
// connect to selection changes while in this mode
this._selectionChangedId =
- Application.selectionController.connect('selection-changed',
- Lang.bind(this, this._setToolbarTitle));
+ Application.selectionController.connect('selection-changed', this._setToolbarTitle.bind(this));
this.addSearchButton('view.search');
}
@@ -628,7 +607,7 @@ const OverviewToolbar = GObject.registerClass(class OverviewToolbar extends Main
_onActiveCollectionChanged(manager, activeCollection) {
if (activeCollection) {
- this._infoUpdatedId = activeCollection.connect('info-updated', Lang.bind(this,
this._setToolbarTitle));
+ this._infoUpdatedId = activeCollection.connect('info-updated', this._setToolbarTitle.bind(this));
} else {
if (this._infoUpdatedId != 0) {
this._activeCollection.disconnect(this._infoUpdatedId);
@@ -657,8 +636,7 @@ const OverviewToolbar = GObject.registerClass(class OverviewToolbar extends Main
// connect to active collection changes while in this mode
this._collectionId =
- Application.documentManager.connect('active-collection-changed',
- Lang.bind(this, this._onActiveCollectionChanged));
+ Application.documentManager.connect('active-collection-changed',
this._onActiveCollectionChanged.bind(this));
}
_clearStateData() {
@@ -708,13 +686,11 @@ const OverviewToolbar = GObject.registerClass(class OverviewToolbar extends Main
this._setToolbarTitle();
this.toolbar.show_all();
- this._countChangedId = Application.offsetDocumentsController.connect('item-count-changed',
Lang.bind(this,
- function(controller, count) {
- this.toolbar.foreach(Lang.bind(this,
- function(child) {
- child.set_sensitive(count != 0);
- }));
- }));
+ this._countChangedId = Application.offsetDocumentsController.connect('item-count-changed',
(controller, count) => {
+ this.toolbar.foreach((child) => {
+ child.set_sensitive(count != 0);
+ });
+ });
if (Application.searchController.getString() != '')
this._view.getAction('search').change_state(GLib.Variant.new('b', true));
@@ -753,40 +729,31 @@ const ViewContainer = GObject.registerClass(class ViewContainer extends Gtk.Stac
this.show_all();
this.set_visible_child_full('view', Gtk.StackTransitionType.NONE);
- this.view.connect('item-activated',
- Lang.bind(this, this._onItemActivated));
- this.view.connect('selection-mode-request',
- Lang.bind(this, this._onSelectionModeRequest));
- this.view.connect('view-selection-changed',
- Lang.bind(this, this._onViewSelectionChanged));
- this.view.connect('notify::view-type',
- Lang.bind(this, this._onViewTypeChanged));
- this.view.connect('size_allocate',
- Lang.bind(this, this._onSizeAllocate));
+ this.view.connect('item-activated', this._onItemActivated.bind(this));
+ this.view.connect('selection-mode-request', this._onSelectionModeRequest.bind(this));
+ this.view.connect('view-selection-changed', this._onViewSelectionChanged.bind(this));
+ this.view.connect('notify::view-type', this._onViewTypeChanged.bind(this));
+ this.view.connect('size_allocate', this._onSizeAllocate.bind(this));
this._selectionModeAction = overview.getAction('selection-mode');
- this._selectionModeAction.connect('notify::state', Lang.bind(this, this._onSelectionModeChanged));
+ this._selectionModeAction.connect('notify::state', this._onSelectionModeChanged.bind(this));
this._onSelectionModeChanged();
- Application.modeController.connect('window-mode-changed',
- Lang.bind(this, this._onWindowModeChanged));
+ Application.modeController.connect('window-mode-changed', this._onWindowModeChanged.bind(this));
this._onWindowModeChanged();
[ this._offsetController, this._trackerController ] = getController(this._mode);
- this._offsetController.connect('item-count-changed', Lang.bind(this,
- function(controller, count) {
- if (count == 0)
- this.set_visible_child_name('no-results');
- else
- this.set_visible_child_name('view');
- }));
-
- this._trackerController.connect('query-error',
- Lang.bind(this, this._onQueryError));
- this._trackerController.connect('query-status-changed',
- Lang.bind(this, this._onQueryStatusChanged));
+ this._offsetController.connect('item-count-changed', (controller, count) => {
+ if (count == 0)
+ this.set_visible_child_name('no-results');
+ else
+ this.set_visible_child_name('view');
+ });
+
+ this._trackerController.connect('query-error', this._onQueryError.bind(this));
+ this._trackerController.connect('query-status-changed', this._onQueryStatusChanged.bind(this));
// ensure the tracker controller is started
this._trackerController.start();
@@ -828,69 +795,66 @@ const ViewContainer = GObject.registerClass(class ViewContainer extends Gtk.Stac
let typeRenderer =
new Gd.StyledTextRenderer({ xpad: 16 });
typeRenderer.add_class('dim-label');
- listWidget.add_renderer(typeRenderer, Lang.bind(this,
- function(col, cell, model, iter) {
- let id = model.get_value(iter, Gd.MainColumns.ID);
- let doc = Application.documentManager.getItemById(id);
+ listWidget.add_renderer(typeRenderer, (col, cell, model, iter) => {
+ let id = model.get_value(iter, Gd.MainColumns.ID);
+ let doc = Application.documentManager.getItemById(id);
- typeRenderer.text = doc.typeDescription;
- }));
+ typeRenderer.text = doc.typeDescription;
+ });
let whereRenderer =
new Gd.StyledTextRenderer({ xpad: 16 });
whereRenderer.add_class('dim-label');
- listWidget.add_renderer(whereRenderer, Lang.bind(this,
- function(col, cell, model, iter) {
- let id = model.get_value(iter, Gd.MainColumns.ID);
- let doc = Application.documentManager.getItemById(id);
+ listWidget.add_renderer(whereRenderer, (col, cell, model, iter) => {
+ let id = model.get_value(iter, Gd.MainColumns.ID);
+ let doc = Application.documentManager.getItemById(id);
- whereRenderer.text = doc.sourceName;
- }));
+ whereRenderer.text = doc.sourceName;
+ });
let dateRenderer =
new Gtk.CellRendererText({ xpad: 32 });
- listWidget.add_renderer(dateRenderer, Lang.bind(this,
- function(col, cell, model, iter) {
- let id = model.get_value(iter, Gd.MainColumns.ID);
- let doc = Application.documentManager.getItemById(id);
- let DAY = 86400000000;
-
- let now = GLib.DateTime.new_now_local();
- let mtime = GLib.DateTime.new_from_unix_local(doc.mtime);
- let difference = now.difference(mtime);
- let days = Math.floor(difference / DAY);
- let weeks = Math.floor(difference / (7 * DAY));
- let months = Math.floor(difference / (30 * DAY));
- let years = Math.floor(difference / (365 * DAY));
-
- if (difference < DAY) {
- dateRenderer.text = mtime.format('%X');
- } else if (difference < 2 * DAY) {
- dateRenderer.text = _("Yesterday");
- } else if (difference < 7 * DAY) {
- dateRenderer.text = Gettext.ngettext("%d day ago",
- "%d days ago",
- days).format(days);
- } else if (difference < 14 * DAY) {
- dateRenderer.text = _("Last week");
- } else if (difference < 28 * DAY) {
- dateRenderer.text = Gettext.ngettext("%d week ago",
- "%d weeks ago",
- weeks).format(weeks);
- } else if (difference < 60 * DAY) {
- dateRenderer.text = _("Last month");
- } else if (difference < 360 * DAY) {
- dateRenderer.text = Gettext.ngettext("%d month ago",
- "%d months ago",
- months).format(months);
- } else if (difference < 730 * DAY) {
- dateRenderer.text = _("Last year");
- } else {
- dateRenderer.text = Gettext.ngettext("%d year ago",
- "%d years ago",
- years).format(years);
- }
- }));
+ listWidget.add_renderer(dateRenderer, (col, cell, model, iter) => {
+ let id = model.get_value(iter, Gd.MainColumns.ID);
+ let doc = Application.documentManager.getItemById(id);
+ let DAY = 86400000000;
+
+ let now = GLib.DateTime.new_now_local();
+ let mtime = GLib.DateTime.new_from_unix_local(doc.mtime);
+ let difference = now.difference(mtime);
+ let days = Math.floor(difference / DAY);
+ let weeks = Math.floor(difference / (7 * DAY));
+ let months = Math.floor(difference / (30 * DAY));
+ let years = Math.floor(difference / (365 * DAY));
+
+ if (difference < DAY) {
+ dateRenderer.text = mtime.format('%X');
+ } else if (difference < 2 * DAY) {
+ dateRenderer.text = _("Yesterday");
+ } else if (difference < 7 * DAY) {
+ dateRenderer.text = Gettext.ngettext("%d day ago",
+ "%d days ago",
+ days).format(days);
+ } else if (difference < 14 * DAY) {
+ dateRenderer.text = _("Last week");
+ } else if (difference < 28 * DAY) {
+ dateRenderer.text = Gettext.ngettext("%d week ago",
+ "%d weeks ago",
+ weeks).format(weeks);
+ } else if (difference < 60 * DAY) {
+ dateRenderer.text = _("Last month");
+ } else if (difference < 360 * DAY) {
+ dateRenderer.text = Gettext.ngettext("%d month ago",
+ "%d months ago",
+ months).format(months);
+ } else if (difference < 730 * DAY) {
+ dateRenderer.text = _("Last year");
+ } else {
+ dateRenderer.text = Gettext.ngettext("%d year ago",
+ "%d years ago",
+ years).format(years);
+ }
+ });
}
_onSelectionModeRequest() {
@@ -947,26 +911,25 @@ const ViewContainer = GObject.registerClass(class ViewContainer extends Gtk.Stac
let generic = this.view.get_generic_view();
let first = true;
- this._model.foreach(Lang.bind(this,
- function(model, path, iter) {
- let id = this._model.get_value(iter, Gd.MainColumns.ID);
- let idIndex = selected.indexOf(id);
-
- if (idIndex != -1) {
- this._model.set_value(iter, Gd.MainColumns.SELECTED, true);
- newSelection.push(id);
-
- if (first) {
- generic.scroll_to_path(path);
- first = false;
- }
+ this._model.foreach((model, path, iter) => {
+ let id = this._model.get_value(iter, Gd.MainColumns.ID);
+ let idIndex = selected.indexOf(id);
+
+ if (idIndex != -1) {
+ this._model.set_value(iter, Gd.MainColumns.SELECTED, true);
+ newSelection.push(id);
+
+ if (first) {
+ generic.scroll_to_path(path);
+ first = false;
}
+ }
- if (newSelection.length == selected.length)
- return true;
+ if (newSelection.length == selected.length)
+ return true;
- return false;
- }));
+ return false;
+ });
Application.selectionController.setSelection(newSelection);
}
@@ -996,11 +959,10 @@ const ViewContainer = GObject.registerClass(class ViewContainer extends Gtk.Stac
}
_connectView() {
- this._edgeHitId = this.view.connect('edge-reached', Lang.bind(this,
- function (view, pos) {
- if (pos == Gtk.PositionType.BOTTOM)
- this._offsetController.increaseOffset();
- }));
+ this._edgeHitId = this.view.connect('edge-reached', (view, pos) => {
+ if (pos == Gtk.PositionType.BOTTOM)
+ this._offsetController.increaseOffset();
+ });
}
_disconnectView() {
@@ -1047,8 +1009,7 @@ var OverviewStack = GObject.registerClass(class OverviewStack extends Gtk.Box {
this._search = new ViewContainer(this, WindowMode.WindowMode.SEARCH);
this._stack.add_named(this._search, 'search');
- this._stack.connect('notify::visible-child',
- Lang.bind(this, this._onVisibleChildChanged));
+ this._stack.connect('notify::visible-child', this._onVisibleChildChanged.bind(this));
}
_getDefaultActions() {
@@ -1060,21 +1021,21 @@ var OverviewStack = GObject.registerClass(class OverviewStack extends Gtk.Box {
return [
{ name: 'go-back',
- callback: Lang.bind(this, this._goBack),
+ callback: this._goBack.bind(this),
accels: backAccels },
{ name: 'selection-mode',
callback: Utils.actionToggleCallback,
state: GLib.Variant.new('b', false),
- stateChanged: Lang.bind(this, this._updateSelectionMode) },
+ stateChanged: this._updateSelectionMode.bind(this) },
{ name: 'select-all',
- callback: Lang.bind(this, this._selectAll),
+ callback: this._selectAll.bind(this),
accels: ['<Primary>a'] },
{ name: 'select-none',
- callback: Lang.bind(this, this._selectNone) },
+ callback: this._selectNone.bind(this) },
{ settingsKey: 'view-as',
- stateChanged: Lang.bind(this, this._updateTypeForSettings) },
+ stateChanged: this._updateTypeForSettings.bind(this) },
{ settingsKey: 'sort-by',
- stateChanged: Lang.bind(this, this._updateSortForSettings) },
+ stateChanged: this._updateSortForSettings.bind(this) },
{ name: 'search',
callback: Utils.actionToggleCallback,
state: GLib.Variant.new('b', false),
@@ -1082,18 +1043,18 @@ var OverviewStack = GObject.registerClass(class OverviewStack extends Gtk.Box {
{ name: 'search-source',
parameter_type: 's',
state: GLib.Variant.new('s', Search.SearchSourceStock.ALL),
- stateChanged: Lang.bind(this, this._updateSearchSource),
- create_hook: Lang.bind(this, this._initSearchSource) },
+ stateChanged: this._updateSearchSource.bind(this),
+ create_hook: this._initSearchSource.bind(this) },
{ name: 'search-type',
parameter_type: 's',
state: GLib.Variant.new('s', Search.SearchTypeStock.ALL),
- stateChanged: Lang.bind(this, this._updateSearchType),
- create_hook: Lang.bind(this, this._initSearchType) },
+ stateChanged: this._updateSearchType.bind(this),
+ create_hook: this._initSearchType.bind(this) },
{ name: 'search-match',
parameter_type: 's',
state: GLib.Variant.new('s', Search.SearchMatchStock.ALL),
- stateChanged: Lang.bind(this, this._updateSearchMatch),
- create_hook: Lang.bind(this, this._initSearchMatch) }
+ stateChanged: this._updateSearchMatch.bind(this),
+ create_hook: this._initSearchMatch.bind(this) }
];
}
@@ -1151,21 +1112,21 @@ var OverviewStack = GObject.registerClass(class OverviewStack extends Gtk.Box {
}
_initSearchSource(action) {
- Application.sourceManager.connect('active-changed', Lang.bind(this, function(manager, activeItem) {
+ Application.sourceManager.connect('active-changed', (manager, activeItem) => {
action.state = GLib.Variant.new('s', activeItem.id);
- }));
+ });
}
_initSearchType(action) {
- Application.searchTypeManager.connect('active-changed', Lang.bind(this, function(manager,
activeItem) {
+ Application.searchTypeManager.connect('active-changed', (manager, activeItem) => {
action.state = GLib.Variant.new('s', activeItem.id);
- }));
+ });
}
_initSearchMatch(action) {
- Application.searchMatchManager.connect('active-changed', Lang.bind(this, function(manager,
activeItem) {
+ Application.searchMatchManager.connect('active-changed', (manager, activeItem) => {
action.state = GLib.Variant.new('s', activeItem.id);
- }));
+ });
}
_updateSearchSource(action) {
diff --git a/src/password.js b/src/password.js
index ee125be1..e8c47351 100644
--- a/src/password.js
+++ b/src/password.js
@@ -25,8 +25,6 @@ const _ = imports.gettext.gettext;
const Application = imports.application;
-const Lang = imports.lang;
-
var PasswordDialog = GObject.registerClass(class PasswordDialog extends Gtk.Dialog {
_init(doc) {
let toplevel = Application.application.get_windows()[0];
@@ -77,23 +75,20 @@ var PasswordDialog = GObject.registerClass(class PasswordDialog extends Gtk.Dial
grid.attach(label, 0, 1, 1, 1);
grid.attach(entry, 1, 1, 1, 1);
- entry.connect('realize', Lang.bind(this,
- function() {
- entry.grab_focus();
- }));
- entry.connect('changed', Lang.bind(this,
- function() {
- let length = entry.get_text_length();
- this.set_response_sensitive(Gtk.ResponseType.OK, (length != 0));
- }));
+ entry.connect('realize', () => {
+ entry.grab_focus();
+ });
+ entry.connect('changed', () => {
+ let length = entry.get_text_length();
+ this.set_response_sensitive(Gtk.ResponseType.OK, (length != 0));
+ });
- this.connect('response', Lang.bind(this,
- function(widget, response) {
- if (response != Gtk.ResponseType.OK)
- return;
- let passwd = entry.get_text();
- Application.documentManager.reloadActiveItem(passwd);
- }));
+ this.connect('response', (widget, response) => {
+ if (response != Gtk.ResponseType.OK)
+ return;
+ let passwd = entry.get_text();
+ Application.documentManager.reloadActiveItem(passwd);
+ });
this.show_all();
}
diff --git a/src/places.js b/src/places.js
index 14458971..6518e2ef 100644
--- a/src/places.js
+++ b/src/places.js
@@ -24,8 +24,6 @@ const EvDocument = imports.gi.EvinceDocument;
const GdPrivate = imports.gi.GdPrivate;
const Application = imports.application;
-const Lang = imports.lang;
-
var PlacesDialog = GObject.registerClass(class PlacesDialog extends Gtk.Dialog {
_init(model, bookmarks) {
let toplevel = Application.application.get_windows()[0];
@@ -63,19 +61,17 @@ var PlacesDialog = GObject.registerClass(class PlacesDialog extends Gtk.Dialog {
if (docHasLinks) {
this._linksPage = new GdPrivate.PlacesLinks();
- this._linksPage.connect('link-activated', Lang.bind(this,
- function(widget, link) {
- this._handleLink(link);
- }));
+ this._linksPage.connect('link-activated', (widget, link) => {
+ this._handleLink(link);
+ });
this._addPage(this._linksPage);
}
if (this._bookmarks) {
this._bookmarksPage = new GdPrivate.PlacesBookmarks({ bookmarks: this._bookmarks });
- this._bookmarksPage.connect('bookmark-activated', Lang.bind(this,
- function(widget, link) {
- this._handleBookmark(link);
- }));
+ this._bookmarksPage.connect('bookmark-activated', (widget, link) => {
+ this._handleBookmark(link);
+ });
this._addPage(this._bookmarksPage);
}
diff --git a/src/presentation.js b/src/presentation.js
index f1577b64..39e2e4b7 100644
--- a/src/presentation.js
+++ b/src/presentation.js
@@ -25,8 +25,6 @@ const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const _ = imports.gettext.gettext;
-const Lang = imports.lang;
-
const Application = imports.application;
var PresentationWindow = GObject.registerClass(class PresentationWindow extends Gtk.Window {
@@ -40,11 +38,9 @@ var PresentationWindow = GObject.registerClass(class PresentationWindow extends
destroy_with_parent: true,
title: _("Presentation"),
hexpand: true });
- this.connect('key-press-event',
- Lang.bind(this, this._onKeyPressEvent));
+ this.connect('key-press-event', this._onKeyPressEvent.bind(this));
- this._model.connect('page-changed',
- Lang.bind(this, this._onPageChanged));
+ this._model.connect('page-changed', this._onPageChanged.bind(this));
this._createView();
this.fullscreen();
@@ -79,8 +75,8 @@ var PresentationWindow = GObject.registerClass(class PresentationWindow extends
current_page: page,
rotation: rotation,
inverted_colors: inverted });
- this.view.connect('finished', Lang.bind(this, this.close));
- this.view.connect('notify::current-page', Lang.bind(this, this._onPresentationPageChanged));
+ this.view.connect('finished', this.close.bind(this));
+ this.view.connect('notify::current-page', this._onPresentationPageChanged.bind(this));
this.add(this.view);
this.view.show();
@@ -194,10 +190,9 @@ var PresentationOutputChooser = GObject.registerClass({
}
_createWindow() {
- this.connect('response', Lang.bind(this,
- function(widget, response) {
- this.emit('output-activated', null);
- }));
+ this.connect('response', (widget, response) => {
+ this.emit('output-activated', null);
+ });
let frame = new Gtk.Frame({ shadow_type: Gtk.ShadowType.IN });
@@ -205,19 +200,18 @@ var PresentationOutputChooser = GObject.registerClass({
valign: Gtk.Align.CENTER,
selection_mode: Gtk.SelectionMode.NONE });
frame.add(this._box);
- this._box.connect('row-activated', Lang.bind(this, this._onActivated));
- this._box.set_header_func(Lang.bind(this,
- function(row, before) {
- if (!before)
- return;
-
- let current = row.get_header();
- if (!current) {
- current = new Gtk.Separator({ orientation: Gtk.Orientation.HORIZONTAL });
- current.show();
- row.set_header(current);
- }
- }));
+ this._box.connect('row-activated', this._onActivated.bind(this));
+ this._box.set_header_func((row, before) => {
+ if (!before)
+ return;
+
+ let current = row.get_header();
+ if (!current) {
+ current = new Gtk.Separator({ orientation: Gtk.Orientation.HORIZONTAL });
+ current.show();
+ row.set_header(current);
+ }
+ });
let contentArea = this.get_content_area();
contentArea.pack_start(frame, true, false, 0);
@@ -230,7 +224,7 @@ var PresentationOutputs = class PresentationOutputs {
let gdkscreen = Gdk.Screen.get_default();
this._screen = GnomeDesktop.RRScreen.new(gdkscreen);
- this._screen.connect('changed', Lang.bind(this, this._onScreenChanged));
+ this._screen.connect('changed', this._onScreenChanged.bind(this));
this._config = GnomeDesktop.RRConfig.new_current(this._screen);
this.clone = this._config.get_clone();
diff --git a/src/preview.js b/src/preview.js
index 3910e078..2fb44f86 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -5,7 +5,6 @@ const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Application = imports.application;
@@ -60,56 +59,50 @@ var Preview = GObject.registerClass(class Preview extends Gtk.Stack {
this.navControls.show();
this.show_all();
- this._loadStartedId = Application.documentManager.connect('load-started',
- Lang.bind(this, this.onLoadStarted));
- this._loadFinishedId = Application.documentManager.connect('load-finished',
- Lang.bind(this, this.onLoadFinished));
- this._loadErrorId = Application.documentManager.connect('load-error',
- Lang.bind(this, this.onLoadError));
- this._passwordNeededId = Application.documentManager.connect('password-needed',
- Lang.bind(this, this.onPasswordNeeded));
-
- this._nightModeId = Application.application.connect('action-state-changed::night-mode',
- Lang.bind(this, this._updateNightMode));
-
- this.connect('destroy', Lang.bind(this,
- function() {
- if (this._loadStartedId > 0) {
- Application.documentManager.disconnect(this._loadStartedId);
- this._loadStartedId = 0;
- }
- if (this._loadFinishedId > 0) {
- Application.documentManager.disconnect(this._loadFinishedId);
- this._loadFinishedId = 0;
- }
- if (this._loadErrorId > 0) {
- Application.documentManager.disconnect(this._loadErrorId);
- this._loadErrorId = 0;
- }
- if (this._passwordNeededId > 0) {
- Application.documentManager.disconnect(this._passwordNeededId);
- this._passwordNeededId = 0;
- }
- if (this.navControls) {
- this.navControls.destroy();
- this.navControls = null;
- }
-
- if (this._fsToolbar) {
- this._fsToolbar.destroy();
- this._fsToolbar = null;
- }
-
- if (this._fullscreenAction) {
- this._fullscreenAction.change_state(new GLib.Variant('b', false));
- this._fullscreenAction.disconnect(this._fsStateId);
- }
-
- if (this._nightModeId > 0) {
- Application.application.disconnect(this._nightModeId);
- this._nightModeId = 0;
- }
- }));
+ this._loadStartedId = Application.documentManager.connect('load-started',
this.onLoadStarted.bind(this));
+ this._loadFinishedId = Application.documentManager.connect('load-finished',
this.onLoadFinished.bind(this));
+ this._loadErrorId = Application.documentManager.connect('load-error', this.onLoadError.bind(this));
+ this._passwordNeededId = Application.documentManager.connect('password-needed',
this.onPasswordNeeded.bind(this));
+
+ this._nightModeId = Application.application.connect('action-state-changed::night-mode',
this._updateNightMode.bind(this));
+
+ this.connect('destroy', () => {
+ if (this._loadStartedId > 0) {
+ Application.documentManager.disconnect(this._loadStartedId);
+ this._loadStartedId = 0;
+ }
+ if (this._loadFinishedId > 0) {
+ Application.documentManager.disconnect(this._loadFinishedId);
+ this._loadFinishedId = 0;
+ }
+ if (this._loadErrorId > 0) {
+ Application.documentManager.disconnect(this._loadErrorId);
+ this._loadErrorId = 0;
+ }
+ if (this._passwordNeededId > 0) {
+ Application.documentManager.disconnect(this._passwordNeededId);
+ this._passwordNeededId = 0;
+ }
+ if (this.navControls) {
+ this.navControls.destroy();
+ this.navControls = null;
+ }
+
+ if (this._fsToolbar) {
+ this._fsToolbar.destroy();
+ this._fsToolbar = null;
+ }
+
+ if (this._fullscreenAction) {
+ this._fullscreenAction.change_state(new GLib.Variant('b', false));
+ this._fullscreenAction.disconnect(this._fsStateId);
+ }
+
+ if (this._nightModeId > 0) {
+ Application.application.disconnect(this._nightModeId);
+ this._nightModeId = 0;
+ }
+ });
}
_getDefaultActions() {
@@ -125,17 +118,17 @@ var Preview = GObject.registerClass(class Preview extends Gtk.Stack {
state: GLib.Variant.new('b', false),
accels: ['F10'] },
{ name: 'properties',
- callback: Lang.bind(this, this._properties) },
+ callback: this._properties.bind(this) },
{ name: 'open-current',
- callback: Lang.bind(this, this._openCurrent) },
+ callback: this._openCurrent.bind(this) },
{ name: 'prev-page',
- callback: Lang.bind(this, this.goPrev),
+ callback: this.goPrev.bind(this),
accels: ['<Primary>Page_Up', 'Left'] },
{ name: 'next-page',
- callback: Lang.bind(this, this.goNext),
+ callback: this.goNext.bind(this),
accels: ['<Primary>Page_Down', 'Right'] },
{ name: 'go-back',
- callback: Lang.bind(this, this.goBack),
+ callback: this.goBack.bind(this),
accels: backAccels }
];
}
@@ -146,9 +139,9 @@ var Preview = GObject.registerClass(class Preview extends Gtk.Stack {
return;
let dialog = new Properties.PropertiesDialog(doc.id);
- dialog.connect('response', Lang.bind(this, function(widget, response) {
+ dialog.connect('response', (widget, response) => {
widget.destroy();
- }));
+ });
}
_openCurrent() {
@@ -172,9 +165,9 @@ var Preview = GObject.registerClass(class Preview extends Gtk.Stack {
this._fsToolbar = this.createFullscreenToolbar();
this.overlay.add_overlay(this._fsToolbar);
- this._fsToolbar.connect('show-controls', Lang.bind(this, function() {
+ this._fsToolbar.connect('show-controls', () => {
this.controlsVisible = true;
- }));
+ });
Application.application.set_accels_for_action('view.fullscreen',
['F11', 'Escape']);
@@ -222,7 +215,7 @@ var Preview = GObject.registerClass(class Preview extends Gtk.Stack {
let settings = Gtk.Settings.get_default();
let doubleClick = settings.gtk_double_click_time;
- this._controlsFlipId = Mainloop.timeout_add(doubleClick, Lang.bind(this,
this._flipControlsTimeout));
+ this._controlsFlipId = Mainloop.timeout_add(doubleClick, this._flipControlsTimeout.bind(this));
}
cancelControlsFlip() {
@@ -249,7 +242,7 @@ var Preview = GObject.registerClass(class Preview extends Gtk.Stack {
if (this.canFullscreen) {
this._fullscreenAction = new FullscreenAction.FullscreenAction({ window: this.mainWindow });
- this._fsStateId = this._fullscreenAction.connect('notify::state', Lang.bind(this,
this._onFullscreenChanged));
+ this._fsStateId = this._fullscreenAction.connect('notify::state',
this._onFullscreenChanged.bind(this));
actionGroup.add_action(this._fullscreenAction);
Application.application.set_accels_for_action('view.fullscreen', ['F11']);
}
@@ -300,22 +293,22 @@ var Preview = GObject.registerClass(class Preview extends Gtk.Stack {
this._spinner.stop();
let dialog = new Password.PasswordDialog(doc);
- dialog.connect('response', Lang.bind(this, function(widget, response) {
+ dialog.connect('response', (widget, response) => {
dialog.destroy();
if (response == Gtk.ResponseType.CANCEL || response == Gtk.ResponseType.DELETE_EVENT)
Application.documentManager.setActiveItem(null);
- }));
+ });
}
onLoadStarted(manager, doc) {
this._clearLoadTimer();
- this._loadShowId = Mainloop.timeout_add(_PDF_LOADER_TIMEOUT, Lang.bind(this, function() {
+ this._loadShowId = Mainloop.timeout_add(_PDF_LOADER_TIMEOUT, () => {
this._loadShowId = 0;
this.set_visible_child_name('spinner');
this._spinner.start();
return false;
- }));
+ });
}
onLoadFinished(manager, doc) {
@@ -416,10 +409,10 @@ var PreviewToolbar = GObject.registerClass(class PreviewToolbar extends MainTool
this.updateTitle();
this.toolbar.show_all();
- this.connect('destroy', Lang.bind(this, function() {
+ this.connect('destroy', () => {
if (this._fsStateId > 0)
this.preview.getAction('fullscreen').disconnect(this._fsStateId);
- }));
+ });
}
_getPreviewMenu() {
@@ -454,7 +447,7 @@ var PreviewToolbar = GObject.registerClass(class PreviewToolbar extends MainTool
this.toolbar.pack_end(this._fullscreenButton);
let action = this.preview.getAction('fullscreen');
- this._fsStateId = action.connect('notify::state', Lang.bind(this, this._fullscreenStateChanged));
+ this._fsStateId = action.connect('notify::state', this._fullscreenStateChanged.bind(this));
this._fullscreenStateChanged();
}
@@ -500,23 +493,22 @@ const PreviewFullscreenToolbar = GObject.registerClass({
let actionNames = ['gear-menu', 'find'];
let signalIds = [];
- actionNames.forEach(Lang.bind(this, function(actionName) {
+ actionNames.forEach((actionName) => {
let signalName = 'action-state-changed::' + actionName;
- let signalId = preview.actionGroup.connect(signalName, Lang.bind(this,
- function(actionGroup, actionName, value) {
- let state = value.get_boolean();
- if (state)
- this.emit('show-controls');
- }));
+ let signalId = preview.actionGroup.connect(signalName, (actionGroup, actionName, value) => {
+ let state = value.get_boolean();
+ if (state)
+ this.emit('show-controls');
+ });
signalIds.push(signalId);
- }));
+ });
- this.toolbar.connect('destroy', Lang.bind(this, function() {
+ this.toolbar.connect('destroy', () => {
signalIds.forEach(function(signalId) {
preview.actionGroup.disconnect(signalId);
});
- }));
+ });
}
handleEvent(event) {
@@ -556,12 +548,12 @@ var PreviewNavControls = class PreviewNavControls {
this.barWidget.get_style_context().add_class('osd');
this._barRevealer.add(this.barWidget);
- this.barWidget.connect('notify::hover', Lang.bind(this, function() {
+ this.barWidget.connect('notify::hover', () => {
if (this.barWidget.hover)
this._onEnterNotify();
else
this._onLeaveNotify();
- }));
+ });
this._barRevealer.show_all();
}
@@ -577,9 +569,9 @@ var PreviewNavControls = class PreviewNavControls {
pixel_size: 16 }), });
prevButton.get_style_context().add_class('osd');
this._prevRevealer.add(prevButton);
- prevButton.connect('clicked', Lang.bind(this, this._onPrevClicked));
- prevButton.connect('enter-notify-event', Lang.bind(this, this._onEnterNotify));
- prevButton.connect('leave-notify-event', Lang.bind(this, this._onLeaveNotify));
+ prevButton.connect('clicked', this._onPrevClicked.bind(this));
+ prevButton.connect('enter-notify-event', this._onEnterNotify.bind(this));
+ prevButton.connect('leave-notify-event', this._onLeaveNotify.bind(this));
this._nextRevealer = new Gtk.Revealer({ transition_type: Gtk.RevealerTransitionType.CROSSFADE,
margin_start: PREVIEW_NAVBAR_MARGIN,
@@ -592,20 +584,20 @@ var PreviewNavControls = class PreviewNavControls {
pixel_size: 16 }) });
nextButton.get_style_context().add_class('osd');
this._nextRevealer.add(nextButton);
- nextButton.connect('clicked', Lang.bind(this, this._onNextClicked));
- nextButton.connect('enter-notify-event', Lang.bind(this, this._onEnterNotify));
- nextButton.connect('leave-notify-event', Lang.bind(this, this._onLeaveNotify));
+ nextButton.connect('clicked', this._onNextClicked.bind(this));
+ nextButton.connect('enter-notify-event', this._onEnterNotify.bind(this));
+ nextButton.connect('leave-notify-event', this._onLeaveNotify.bind(this));
this._prevRevealer.show_all();
this._nextRevealer.show_all();
- this._overlay.connect('motion-notify-event', Lang.bind(this, this._onMotion));
+ this._overlay.connect('motion-notify-event', this._onMotion.bind(this));
this._tapGesture = new Gtk.GestureMultiPress({ propagation_phase: Gtk.PropagationPhase.CAPTURE,
touch_only: true,
widget: this.preview.view });
- this._tapGesture.connect('released', Lang.bind(this, this._onMultiPressReleased));
- this._tapGesture.connect('stopped', Lang.bind(this, this._onMultiPressStopped));
+ this._tapGesture.connect('released', this._onMultiPressReleased.bind(this));
+ this._tapGesture.connect('stopped', this._onMultiPressStopped.bind(this));
}
createBarWidget() {
@@ -639,7 +631,7 @@ var PreviewNavControls = class PreviewNavControls {
if (device.input_source == Gdk.InputSource.TOUCHSCREEN)
return false;
- this._motionId = Mainloop.idle_add(Lang.bind(this, this._motionTimeout));
+ this._motionId = Mainloop.idle_add(this._motionTimeout.bind(this));
return false;
}
@@ -679,7 +671,7 @@ var PreviewNavControls = class PreviewNavControls {
_queueAutoHide() {
this._unqueueAutoHide();
- this._autoHideId = Mainloop.timeout_add_seconds(_AUTO_HIDE_TIMEOUT, Lang.bind(this, this._autoHide));
+ this._autoHideId = Mainloop.timeout_add_seconds(_AUTO_HIDE_TIMEOUT, this._autoHide.bind(this));
}
_updateVisibility() {
@@ -729,10 +721,10 @@ var PreviewSearchbar = GObject.registerClass(class PreviewSearchbar extends Sear
super._init();
- this.connect('notify::search-mode-enabled', Lang.bind(this, function() {
+ this.connect('notify::search-mode-enabled', () => {
let action = this.preview.getAction('find');
action.change_state(GLib.Variant.new('b', this.search_mode_enabled));
- }));
+ });
}
createSearchWidget() {
@@ -741,9 +733,9 @@ var PreviewSearchbar = GObject.registerClass(class PreviewSearchbar extends Sear
box.get_style_context().add_class('linked');
this.searchEntry = new Gtk.SearchEntry({ width_request: 500 });
- this.searchEntry.connect('activate', Lang.bind(this, function() {
+ this.searchEntry.connect('activate', () => {
this.preview.activateResult();
- }));
+ });
box.add(this.searchEntry);
this._prev = new Gtk.Button({ action_name: 'view.find-prev' });
diff --git a/src/properties.js b/src/properties.js
index 319f94cf..dbedcd75 100644
--- a/src/properties.js
+++ b/src/properties.js
@@ -31,8 +31,6 @@ const Application = imports.application;
const Mainloop = imports.mainloop;
const TrackerUtils = imports.trackerUtils;
-const Lang = imports.lang;
-
const _TITLE_ENTRY_TIMEOUT = 200;
var PropertiesDialog = GObject.registerClass(class PropertiesDialog extends Gtk.Dialog {
@@ -131,21 +129,19 @@ var PropertiesDialog = GObject.registerClass(class PropertiesDialog extends Gtk.
let docId = doc.id;
this._titleEntryTimeout = 0;
- this._titleEntry.connect('changed', Lang.bind (this,
- function() {
- if (this._titleEntryTimeout != 0) {
- Mainloop.source_remove(this._titleEntryTimeout);
- this._titleEntryTimeout = 0;
- }
-
- this._titleEntryTimeout = Mainloop.timeout_add(_TITLE_ENTRY_TIMEOUT, Lang.bind(this,
- function() {
- this._titleEntryTimeout = 0;
- let newTitle = this._titleEntry.get_text();
- TrackerUtils.setEditedName(newTitle, docId, null);
- return false;
- }));
- }));
+ this._titleEntry.connect('changed', () => {
+ if (this._titleEntryTimeout != 0) {
+ Mainloop.source_remove(this._titleEntryTimeout);
+ this._titleEntryTimeout = 0;
+ }
+
+ this._titleEntryTimeout = Mainloop.timeout_add(_TITLE_ENTRY_TIMEOUT, () => {
+ this._titleEntryTimeout = 0;
+ let newTitle = this._titleEntry.get_text();
+ TrackerUtils.setEditedName(newTitle, docId, null);
+ return false;
+ });
+ });
} else {
this._titleEntry = new Gtk.Label({ label: doc.name,
halign: Gtk.Align.START });
diff --git a/src/query.js b/src/query.js
index 0dcc75d5..6ab1a462 100644
--- a/src/query.js
+++ b/src/query.js
@@ -23,7 +23,6 @@ const Gd = imports.gi.Gd;
const GdPrivate = imports.gi.GdPrivate;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
-const Lang = imports.lang;
const Search = imports.search;
var QueryColumns = {
@@ -86,21 +85,20 @@ var QueryBuilder = class QueryBuilder {
_addWhereClauses(partsList, global, flags, searchTypes, ftsQuery) {
// build an array of WHERE clauses; each clause maps to one
// type of resource we're looking for.
- searchTypes.forEach(Lang.bind(this,
- function(currentType) {
- let part = '{ ' + currentType.getWhere() + ftsQuery;
- part += this._buildOptional();
+ searchTypes.forEach((currentType) => {
+ let part = '{ ' + currentType.getWhere() + ftsQuery;
+ part += this._buildOptional();
- if ((flags & QueryFlags.UNFILTERED) == 0) {
- if (global)
- part += this._context.documentManager.getWhere();
+ if ((flags & QueryFlags.UNFILTERED) == 0) {
+ if (global)
+ part += this._context.documentManager.getWhere();
- part += this._buildFilterString(currentType, flags, ftsQuery.length > 0);
- }
+ part += this._buildFilterString(currentType, flags, ftsQuery.length > 0);
+ }
- part += ' }';
- partsList.push(part);
- }));
+ part += ' }';
+ partsList.push(part);
+ });
}
_buildWhere(global, flags) {
diff --git a/src/search.js b/src/search.js
index 5bc461a6..f48cd4db 100644
--- a/src/search.js
+++ b/src/search.js
@@ -24,7 +24,6 @@ const Documents = imports.documents;
const Manager = imports.manager;
const Query = imports.query;
-const Lang = imports.lang;
const Signals = imports.signals;
const Gio = imports.gi.Gio;
@@ -316,27 +315,26 @@ const Source = class Source {
let locations = settings.get_strv(TRACKER_KEY_RECURSIVE_DIRECTORIES);
let files = [];
- locations.forEach(Lang.bind(this,
- function(location) {
- // ignore special XDG placeholders, since we handle those internally
- if (location[0] == '&' || location[0] == '$')
- return;
+ locations.forEach((location) => {
+ // ignore special XDG placeholders, since we handle those internally
+ if (location[0] == '&' || location[0] == '$')
+ return;
- let trackerFile = Gio.file_new_for_commandline_arg(location);
+ let trackerFile = Gio.file_new_for_commandline_arg(location);
- // also ignore XDG locations if they are present with their full path
- for (let idx = 0; idx < GLib.UserDirectory.N_DIRECTORIES; idx++) {
- let path = GLib.get_user_special_dir(idx);
- if (!path)
- continue;
+ // also ignore XDG locations if they are present with their full path
+ for (let idx = 0; idx < GLib.UserDirectory.N_DIRECTORIES; idx++) {
+ let path = GLib.get_user_special_dir(idx);
+ if (!path)
+ continue;
- let file = Gio.file_new_for_path(path);
- if (trackerFile.equal(file))
- return;
- }
+ let file = Gio.file_new_for_path(path);
+ if (trackerFile.equal(file))
+ return;
+ }
- files.push(trackerFile);
- }));
+ files.push(trackerFile);
+ });
return files;
}
@@ -347,12 +345,11 @@ const Source = class Source {
GLib.UserDirectory.DIRECTORY_DOCUMENTS,
GLib.UserDirectory.DIRECTORY_DOWNLOAD];
- xdgDirs.forEach(Lang.bind(this,
- function(dir) {
- let path = GLib.get_user_special_dir(dir);
- if (path)
- files.push(Gio.file_new_for_path(path));
- }));
+ xdgDirs.forEach((dir) => {
+ let path = GLib.get_user_special_dir(dir);
+ if (path)
+ files.push(Gio.file_new_for_path(path));
+ });
return files;
}
@@ -364,10 +361,9 @@ const Source = class Source {
this._getGettingStartedLocations());
let filters = [];
- locations.forEach(Lang.bind(this,
- function(location) {
- filters.push('(fn:contains (nie:url(?urn), "%s"))'.format(location.get_uri()));
- }));
+ locations.forEach((location) => {
+ filters.push('(fn:contains (nie:url(?urn), "%s"))'.format(location.get_uri()));
+ });
filters.push('(fn:starts-with (nao:identifier(?urn), "gd:collection:local:"))');
@@ -415,9 +411,9 @@ const SourceManager = class SourceManager extends Manager.BaseManager {
builtin: true });
this.addItem(source);
- Application.goaClient.connect('account-added', Lang.bind(this, this._refreshGoaAccounts));
- Application.goaClient.connect('account-changed', Lang.bind(this, this._refreshGoaAccounts));
- Application.goaClient.connect('account-removed', Lang.bind(this, this._refreshGoaAccounts));
+ Application.goaClient.connect('account-added', this._refreshGoaAccounts.bind(this));
+ Application.goaClient.connect('account-changed', this._refreshGoaAccounts.bind(this));
+ Application.goaClient.connect('account-removed', this._refreshGoaAccounts.bind(this));
this._refreshGoaAccounts();
@@ -429,24 +425,23 @@ const SourceManager = class SourceManager extends Manager.BaseManager {
let newSources = new Map();
let accounts = Application.goaClient.get_accounts();
- accounts.forEach(Lang.bind(this,
- function(object) {
- if (!object.get_account())
- return;
+ accounts.forEach((object) => {
+ if (!object.get_account())
+ return;
- if (!object.get_documents())
- return;
+ if (!object.get_documents())
+ return;
- let source = new Source({ object: object });
+ let source = new Source({ object: object });
- let otherSources = newSources.get(source.name);
- if (!otherSources)
- otherSources = [];
+ let otherSources = newSources.get(source.name);
+ if (!otherSources)
+ otherSources = [];
- otherSources.push(source);
- newSources.set(source.name, otherSources);
- newItems[source.id] = source;
- }));
+ otherSources.push(source);
+ newSources.set(source.name, otherSources);
+ newItems[source.id] = source;
+ });
// Ensure an unique name for GOA accounts from the same provider
newSources.forEach(function(sources, name) {
@@ -518,15 +513,14 @@ const SourceManager = class SourceManager extends Manager.BaseManager {
getForProviderType(providerType) {
let items = [];
- this.forEachItem(Lang.bind(this,
- function(source) {
- if (!source.object)
- return;
+ this.forEachItem((source) => {
+ if (!source.object)
+ return;
- let account = source.object.get_account();
- if (account.provider_type == providerType)
- items.push(source);
- }));
+ let account = source.object.get_account();
+ if (account.provider_type == providerType)
+ items.push(source);
+ });
return items;
}
@@ -550,29 +544,27 @@ const OffsetController = class OffsetController {
resetItemCount() {
let query = this.getQuery();
- Application.connectionQueue.add
- (query.sparql, null, Lang.bind(this,
- function(object, res) {
- let cursor = null;
- try {
- cursor = object.query_finish(res);
- } catch (e) {
- logError(e, 'Unable to execute count query');
- return;
- }
+ Application.connectionQueue.add(
+ query.sparql, null, (object, res) => {
+ let cursor = null;
+ try {
+ cursor = object.query_finish(res);
+ } catch (e) {
+ logError(e, 'Unable to execute count query');
+ return;
+ }
- cursor.next_async(null, Lang.bind(this,
- function(object, res) {
- let valid = object.next_finish(res);
+ cursor.next_async(null, (object, res) => {
+ let valid = object.next_finish(res);
- if (valid) {
- this._itemCount = cursor.get_integer(0);
- this.emit('item-count-changed', this._itemCount);
- }
+ if (valid) {
+ this._itemCount = cursor.get_integer(0);
+ this.emit('item-count-changed', this._itemCount);
+ }
- cursor.close();
- }));
- }));
+ cursor.close();
+ });
+ });
}
getQuery() {
diff --git a/src/searchbar.js b/src/searchbar.js
index 45793c3c..168e21ca 100644
--- a/src/searchbar.js
+++ b/src/searchbar.js
@@ -24,8 +24,6 @@ const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
-
const Application = imports.application;
const Manager = imports.manager;
@@ -45,13 +43,12 @@ var Searchbar = GObject.registerClass({
this.add(searchWidget);
this.connect_entry(this.searchEntry);
- this.searchEntry.connect('search-changed', Lang.bind(this,
- function() {
- if (this.searchChangeBlocked)
- return;
+ this.searchEntry.connect('search-changed', () => {
+ if (this.searchChangeBlocked)
+ return;
- this.entryChanged();
- }));
+ this.entryChanged();
+ });
this.show_all();
}
@@ -104,7 +101,7 @@ var Dropdown = GObject.registerClass(class Dropdown extends Gtk.Popover {
[Application.sourceManager,
Application.searchTypeManager,
- Application.searchMatchManager].forEach(Lang.bind(this, function(manager) {
+ Application.searchMatchManager].forEach((manager) => {
let model = new Manager.BaseModel(manager);
// HACK: see https://bugzilla.gnome.org/show_bug.cgi?id=733977
@@ -115,6 +112,6 @@ var Dropdown = GObject.registerClass(class Dropdown extends Gtk.Popover {
w.valign = Gtk.Align.START;
w.vexpand = true;
popover.destroy();
- }));
+ });
}
});
diff --git a/src/selections.js b/src/selections.js
index 1a4c1022..68d32560 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -38,7 +38,6 @@ const Sharing = imports.sharing;
const TrackerUtils = imports.trackerUtils;
const WindowMode = imports.windowMode;
-const Lang = imports.lang;
const Signals = imports.signals;
// fetch all the collections a given item is part of
@@ -52,18 +51,17 @@ const FetchCollectionsJob = class FetchCollectionsJob {
this._callback = callback;
let query = Application.queryBuilder.buildFetchCollectionsQuery(this._urn);
- Application.connectionQueue.add(query.sparql, null, Lang.bind(this,
- function(object, res) {
- let cursor = null;
-
- try {
- cursor = object.query_finish(res);
- cursor.next_async(null, Lang.bind(this, this._onCursorNext));
- } catch (e) {
- logError(e, 'Unable to run FetchCollectionsJob');
- this._emitCallback();
- }
- }));
+ Application.connectionQueue.add(query.sparql, null, (object, res) => {
+ let cursor = null;
+
+ try {
+ cursor = object.query_finish(res);
+ cursor.next_async(null, this._onCursorNext.bind(this));
+ } catch (e) {
+ logError(e, 'Unable to run FetchCollectionsJob');
+ this._emitCallback();
+ }
+ });
}
_onCursorNext(cursor, res) {
@@ -85,7 +83,7 @@ const FetchCollectionsJob = class FetchCollectionsJob {
let urn = cursor.get_string(0)[0];
this._collections.push(urn);
- cursor.next_async(null, Lang.bind(this, this._onCursorNext));
+ cursor.next_async(null, this._onCursorNext.bind(this));
}
_emitCallback() {
@@ -112,16 +110,15 @@ const FetchCollectionStateForSelectionJob = class FetchCollectionStateForSelecti
this._callback = callback;
let urns = Application.selectionController.getSelection();
- urns.forEach(Lang.bind(this,
- function(urn) {
- let job = new FetchCollectionsJob(urn);
+ urns.forEach((urn) => {
+ let job = new FetchCollectionsJob(urn);
- this._runningJobs++;
- job.run(Lang.bind(this, this._jobCollector, urn));
- }));
+ this._runningJobs++;
+ job.run(this._jobCollector.bind(this, urn));
+ });
}
- _jobCollector(collectionsForItem, urn) {
+ _jobCollector(urn, collectionsForItem) {
this._collectionsForItems[urn] = collectionsForItem;
this._runningJobs--;
@@ -197,17 +194,16 @@ const UpdateMtimeJob = class UpdateMtimeJob {
this._callback = callback;
let query = Application.queryBuilder.buildUpdateMtimeQuery(this._urn);
- Application.connectionQueue.update(query.sparql, null, Lang.bind(this,
- function(object, res) {
- try {
- object.update_finish(res);
- } catch (e) {
- logError(e, 'Unable to run UpdateMtimeJob');
- }
+ Application.connectionQueue.update(query.sparql, null, (object, res) => {
+ try {
+ object.update_finish(res);
+ } catch (e) {
+ logError(e, 'Unable to run UpdateMtimeJob');
+ }
- if (this._callback)
- this._callback();
- }));
+ if (this._callback)
+ this._callback();
+ });
}
}
@@ -223,27 +219,25 @@ const SetCollectionForSelectionJob = class SetCollectionForSelectionJob {
this._callback = callback;
let urns = Application.selectionController.getSelection();
- urns.forEach(Lang.bind(this,
- function(urn) {
- // never add a collection to itself!!
- if (urn == this._collectionUrn)
- return;
+ urns.forEach((urn) => {
+ // never add a collection to itself!!
+ if (urn == this._collectionUrn)
+ return;
+
+ let query = Application.queryBuilder.buildSetCollectionQuery(
+ urn, this._collectionUrn, this._setting);
+ this._runningJobs++;
- let query = Application.queryBuilder.buildSetCollectionQuery(urn,
- this._collectionUrn, this._setting);
- this._runningJobs++;
-
- Application.connectionQueue.update(query.sparql, null, Lang.bind(this,
- function(object, res) {
- try {
- object.update_finish(res);
- } catch (e) {
- logError(e, 'Unable to run SetCollectionForSelectionJob');
- }
-
- this._jobCollector();
- }));
- }));
+ Application.connectionQueue.update(query.sparql, null, (object, res) => {
+ try {
+ object.update_finish(res);
+ } catch (e) {
+ logError(e, 'Unable to run SetCollectionForSelectionJob');
+ }
+
+ this._jobCollector();
+ });
+ });
}
_jobCollector() {
@@ -251,12 +245,10 @@ const SetCollectionForSelectionJob = class SetCollectionForSelectionJob {
if (this._runningJobs == 0) {
let job = new UpdateMtimeJob(this._collectionUrn);
- job.run(Lang.bind(this,
- function() {
-
- if (this._callback)
- this._callback();
- }));
+ job.run(() => {
+ if (this._callback)
+ this._callback();
+ });
}
}
}
@@ -272,28 +264,27 @@ const CreateCollectionJob = class CreateCollectionJob {
this._callback = callback;
let query = Application.queryBuilder.buildCreateCollectionQuery(this._name);
- Application.connectionQueue.updateBlank(query.sparql, null, Lang.bind(this,
- function(object, res) {
- let variant = null;
- try {
- variant = object.update_blank_finish(res); // variant is aaa{ss}
- } catch (e) {
- logError(e, 'Unable to run CreateCollectionJob');
- }
+ Application.connectionQueue.updateBlank(query.sparql, null, (object, res) => {
+ let variant = null;
+ try {
+ variant = object.update_blank_finish(res); // variant is aaa{ss}
+ } catch (e) {
+ logError(e, 'Unable to run CreateCollectionJob');
+ }
- variant = variant.get_child_value(0); // variant is now aa{ss}
- variant = variant.get_child_value(0); // variant is now a{ss}
- variant = variant.get_child_value(0); // variant is now {ss}
+ variant = variant.get_child_value(0); // variant is now aa{ss}
+ variant = variant.get_child_value(0); // variant is now a{ss}
+ variant = variant.get_child_value(0); // variant is now {ss}
- let key = variant.get_child_value(0).get_string()[0];
- let val = variant.get_child_value(1).get_string()[0];
+ let key = variant.get_child_value(0).get_string()[0];
+ let val = variant.get_child_value(1).get_string()[0];
- if (key == 'res')
- this._createdUrn = val;
+ if (key == 'res')
+ this._createdUrn = val;
- if (this._callback)
- this._callback(this._createdUrn);
- }));
+ if (this._callback)
+ this._callback(this._createdUrn);
+ });
}
}
@@ -328,14 +319,13 @@ const CollectionRow = GObject.registerClass(class CollectionRow extends Gtk.List
active: isActive,
inconsistent: isInconsistent });
this.checkButton.get_child().set_ellipsize(Pango.EllipsizeMode.END);
- this.checkButton.connect('toggled', Lang.bind(this,
- function(checkButton) {
- let collId = this.collection.id;
- let state = checkButton.get_active();
-
- let job = new SetCollectionForSelectionJob(collId, state);
- job.run();
- }));
+ this.checkButton.connect('toggled', (checkButton) => {
+ let collId = this.collection.id;
+ let state = checkButton.get_active();
+
+ let job = new SetCollectionForSelectionJob(collId, state);
+ job.run();
+ });
let menu = new Gio.Menu();
if (this.collection.canEdit())
menu.append(_("Rename…"), 'dialog.rename-collection(\'' + this.collection.id + '\')');
@@ -366,13 +356,12 @@ const CollectionRow = GObject.registerClass(class CollectionRow extends Gtk.List
expand: true,
halign: Gtk.Align.START });
let undoButton = new Gtk.Button({ label: _("Undo") });
- undoButton.connect('clicked', Lang.bind(this,
- function() {
- this._resetTimeout()
- this.views.set_transition_type(Gtk.StackTransitionType.SLIDE_RIGHT);
- this.views.set_transition_duration(200);
- this.setDefaultView();
- }));
+ undoButton.connect('clicked', () => {
+ this._resetTimeout()
+ this.views.set_transition_type(Gtk.StackTransitionType.SLIDE_RIGHT);
+ this.views.set_transition_duration(200);
+ this.setDefaultView();
+ });
grid.add(deleteLabel);
grid.add(undoButton);
@@ -385,19 +374,17 @@ const CollectionRow = GObject.registerClass(class CollectionRow extends Gtk.List
expand: true,
text: this.collection.name,
secondary_icon_name: 'edit-clear-symbolic'});
- this.renameEntry.connect('icon-press', Lang.bind(this,
- function(renameEntry, iconPos) {
- if (iconPos == Gtk.EntryIconPosition.SECONDARY) {
- renameEntry.set_text("");
- }
- }));
- this.renameEntry.connect('changed', Lang.bind(this,
- function(renameEntry) {
- if (renameEntry.get_text() != "")
- renameEntry.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY,
'edit-clear-symbolic');
- else
- renameEntry.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, null);
- }));
+ this.renameEntry.connect('icon-press', (renameEntry, iconPos) => {
+ if (iconPos == Gtk.EntryIconPosition.SECONDARY) {
+ renameEntry.set_text("");
+ }
+ });
+ this.renameEntry.connect('changed', (renameEntry) => {
+ if (renameEntry.get_text() != "")
+ renameEntry.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, 'edit-clear-symbolic');
+ else
+ renameEntry.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, null);
+ });
this.renameEntry.show();
this.views.add_named(this.renameEntry, CollectionRowViews.RENAME);
}
@@ -424,7 +411,7 @@ const CollectionRow = GObject.registerClass(class CollectionRow extends Gtk.List
revealer.add(this.views);
this.add(revealer);
- revealer.connect("notify::child-revealed", Lang.bind(this, this.deleteCollection));
+ revealer.connect("notify::child-revealed", this.deleteCollection.bind(this));
revealer.reveal_child = false;
}
@@ -446,12 +433,11 @@ const CollectionRow = GObject.registerClass(class CollectionRow extends Gtk.List
if (!this.views.get_child_by_name(CollectionRowViews.DELETE))
this._initDeleteView();
- this._timeoutId = Mainloop.timeout_add_seconds(Notifications.DELETE_TIMEOUT, Lang.bind(this,
- function() {
- this._timeoutId = 0;
- this.conceal();
- return false;
- }));
+ this._timeoutId = Mainloop.timeout_add_seconds(Notifications.DELETE_TIMEOUT, () => {
+ this._timeoutId = 0;
+ this.conceal();
+ return false;
+ });
this.views.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT);
this.views.set_transition_duration(500);
this.get_style_context().add_class('delete-row');
@@ -479,45 +465,40 @@ const CollectionList = GObject.registerClass(class CollectionList extends Gtk.Li
margin: 0,
selection_mode: Gtk.SelectionMode.NONE });
- let collAddedId = Application.documentManager.connect('item-added',
- Lang.bind(this, this._onCollectionAdded));
- let collRemovedId = Application.documentManager.connect('item-removed',
- Lang.bind(this, this._onCollectionRemoved));
+ let collAddedId = Application.documentManager.connect('item-added',
this._onCollectionAdded.bind(this));
+ let collRemovedId = Application.documentManager.connect('item-removed',
this._onCollectionRemoved.bind(this));
- this.set_header_func(Lang.bind(this,
- function(row, before) {
- if (!before) {
- row.set_header(null);
- return;
- }
- let current = row.get_header();
- if (!current) {
- current = new Gtk.Separator({ orientation: Gtk.Orientation.HORIZONTAL });
- row.set_header(current);
+ this.set_header_func((row, before) => {
+ if (!before) {
+ row.set_header(null);
+ return;
+ }
+ let current = row.get_header();
+ if (!current) {
+ current = new Gtk.Separator({ orientation: Gtk.Orientation.HORIZONTAL });
+ row.set_header(current);
+ }
+ });
+
+ this.set_sort_func((row1, row2) => {
+ return row2.collection.mtime - row1.collection.mtime;
+ });
+
+ this.connect('destroy', () => {
+ let rows = this.get_children();
+ rows.forEach(function(row) {
+ let currentView = row.views.get_visible_child_name();
+ if (currentView == CollectionRowViews.DELETE) {
+ row.deleteCollection();
}
- }));
-
- this.set_sort_func(Lang.bind(this,
- function(row1, row2) {
- return row2.collection.mtime - row1.collection.mtime;
- }));
-
- this.connect('destroy', Lang.bind(this,
- function() {
- let rows = this.get_children();
- rows.forEach(function(row) {
- let currentView = row.views.get_visible_child_name();
- if (currentView == CollectionRowViews.DELETE) {
- row.deleteCollection();
- }
- });
- Application.documentManager.disconnect(collAddedId);
- Application.documentManager.disconnect(collRemovedId);
- }));
+ });
+ Application.documentManager.disconnect(collAddedId);
+ Application.documentManager.disconnect(collRemovedId);
+ });
// populate the list
let job = new FetchCollectionStateForSelectionJob();
- job.run(Lang.bind(this, this._onFetchCollectionStateForSelection));
+ job.run(this._onFetchCollectionStateForSelection.bind(this));
}
_onCollectionAdded(manager, itemAdded) {
@@ -596,11 +577,11 @@ const OrganizeCollectionDialog = GObject.registerClass({
this._renameMode = false;
- this._keyPressEventId = this.connect('key-press-event', Lang.bind(this, this._onKeyPressed));
- this._addButtonEmpty.connect('clicked', Lang.bind(this, this._onAddClicked));
- this._addButtonCollections.connect('clicked', Lang.bind(this, this._onAddClicked));
- this._addEntryEmpty.connect('changed', Lang.bind(this, this._onTextChanged));
- this._addEntryCollections.connect('changed', Lang.bind(this, this._onTextChanged));
+ this._keyPressEventId = this.connect('key-press-event', this._onKeyPressed.bind(this));
+ this._addButtonEmpty.connect('clicked', this._onAddClicked.bind(this));
+ this._addButtonCollections.connect('clicked', this._onAddClicked.bind(this));
+ this._addEntryEmpty.connect('changed', this._onTextChanged.bind(this));
+ this._addEntryCollections.connect('changed', this._onTextChanged.bind(this));
let actionGroup = new Gio.SimpleActionGroup();
let deleteAction = new Gio.SimpleAction({ name: 'delete-collection',
@@ -611,59 +592,55 @@ const OrganizeCollectionDialog = GObject.registerClass({
actionGroup.add_action(renameAction);
this.insert_action_group('dialog', actionGroup);
- renameAction.connect('activate', Lang.bind(this, this._renameModeStart));
- deleteAction.connect('activate', Lang.bind(this,
- function(action, parameter) {
- let collId = parameter.get_string()[0];
- let rows = this._collectionList.get_children();
- rows.forEach(function(row) {
- if (row.collection.id != collId)
- return;
+ renameAction.connect('activate', this._renameModeStart.bind(this));
+ deleteAction.connect('activate', (action, parameter) => {
+ let collId = parameter.get_string()[0];
+ let rows = this._collectionList.get_children();
+ rows.forEach(function(row) {
+ if (row.collection.id != collId)
+ return;
- row.setDeleteView();
- });
- }));
+ row.setDeleteView();
+ });
+ });
- this._cancelButton.connect('clicked', Lang.bind(this, function() { this._renameModeStop(false); }));
- this._doneButton.connect('clicked', Lang.bind(this, function() { this._renameModeStop(true); }));
+ this._cancelButton.connect('clicked', () => { this._renameModeStop(false); });
+ this._doneButton.connect('clicked', () => { this._renameModeStop(true); });
this._collectionList = new CollectionList();
- let addId = this._collectionList.connect('add', Lang.bind(this, this._onCollectionListChanged));
- let removeId = this._collectionList.connect('remove', Lang.bind(this,
this._onCollectionListChanged));
+ let addId = this._collectionList.connect('add', this._onCollectionListChanged.bind(this));
+ let removeId = this._collectionList.connect('remove', this._onCollectionListChanged.bind(this));
this._scrolledWindowCollections.add(this._collectionList);
this.show_all();
- this.connect('destroy', Lang.bind(this,
- function() {
- this._collectionList.disconnect(addId);
- this._collectionList.disconnect(removeId);
- }));
+ this.connect('destroy', () => {
+ this._collectionList.disconnect(addId);
+ this._collectionList.disconnect(removeId);
+ });
/* We want a CROSSFADE effect when switching from ViewEmpty to ViewCollections (and the other way
around)
* but when we create the dialog we don't want to see the effect, so for the first second we don't
use
* any effect and after that we use the CROSSFADE effect.
*/
- Mainloop.timeout_add_seconds(1, Lang.bind(this,
- function() {
- this._content.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
- return false;
- }));
+ Mainloop.timeout_add_seconds(1, () => {
+ this._content.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
+ return false;
+ });
}
_onAddClicked() {
let addEntry = this._collectionList.isEmpty() ? this._addEntryEmpty : this._addEntryCollections;
let newText = addEntry.get_text();
let job = new CreateCollectionJob(newText);
- job.run(Lang.bind(this,
- function(createdUrn) {
- if (!createdUrn)
- return;
+ job.run((createdUrn) => {
+ if (!createdUrn)
+ return;
- addEntry.set_text('');
- let job = new SetCollectionForSelectionJob(createdUrn, true);
- job.run(null);
- }));
+ addEntry.set_text('');
+ let job = new SetCollectionForSelectionJob(createdUrn, true);
+ job.run(null);
+ });
if (this._collectionList.isEmpty()) {
this._viewSpinner.start();
this._content.set_visible_child(this._viewSpinner);
@@ -700,21 +677,20 @@ const OrganizeCollectionDialog = GObject.registerClass({
this._setRenameMode(true);
let rows = this._collectionList.get_children();
- rows.forEach(Lang.bind(this,
- function(row) {
- let currentView = row.views.get_visible_child_name();
- if (currentView == CollectionRowViews.DELETE) {
- row.conceal();
- return;
- }
+ rows.forEach((row) => {
+ let currentView = row.views.get_visible_child_name();
+ if (currentView == CollectionRowViews.DELETE) {
+ row.conceal();
+ return;
+ }
- if (row.collection.id != collId) {
- row.set_sensitive(false);
- return;
- }
+ if (row.collection.id != collId) {
+ row.set_sensitive(false);
+ return;
+ }
- row.setRenameView(Lang.bind(this, this._onTextChanged));
- }));
+ row.setRenameView(this._onTextChanged.bind(this));
+ });
}
_renameModeStop(rename) {
@@ -773,19 +749,17 @@ var SelectionController = class SelectionController {
constructor() {
this._selection = [];
- Application.documentManager.connect('item-removed',
- Lang.bind(this, this._onDocumentRemoved));
+ Application.documentManager.connect('item-removed', this._onDocumentRemoved.bind(this));
}
_onDocumentRemoved(manager, item) {
let changed = false;
- let filtered = this._selection.filter(Lang.bind(this,
- function(value, index) {
- if (item.id == value)
- changed = true;
+ let filtered = this._selection.filter((value, index) => {
+ if (item.id == value)
+ changed = true;
- return (item.id != value);
- }));
+ return (item.id != value);
+ });
if (changed) {
this._selection = filtered;
this.emit('selection-changed', this._selection);
@@ -839,29 +813,25 @@ var SelectionToolbar = GObject.registerClass({
this._selectionModeAction = overview.getAction('selection-mode');
- this._toolbarOpen.connect('clicked', Lang.bind(this, this._onToolbarOpen));
- this._toolbarPrint.connect('clicked', Lang.bind(this, this._onToolbarPrint));
- this._toolbarTrash.connect('clicked', Lang.bind(this, this._onToolbarTrash));
+ this._toolbarOpen.connect('clicked', this._onToolbarOpen.bind(this));
+ this._toolbarPrint.connect('clicked', this._onToolbarPrint.bind(this));
+ this._toolbarTrash.connect('clicked', this._onToolbarTrash.bind(this));
- this._toolbarShare.connect('clicked', Lang.bind(this, this._onToolbarShare));
+ this._toolbarShare.connect('clicked', this._onToolbarShare.bind(this));
this._toolbarShare.show();
- this._toolbarProperties.connect('clicked', Lang.bind(this, this._onToolbarProperties));
- this._toolbarCollection.connect('clicked', Lang.bind(this, this._onToolbarCollection));
+ this._toolbarProperties.connect('clicked', this._onToolbarProperties.bind(this));
+ this._toolbarCollection.connect('clicked', this._onToolbarCollection.bind(this));
- Application.modeController.connect('window-mode-changed',
- Lang.bind(this, this._updateCollectionsButton));
- Application.documentManager.connect('active-collection-changed',
- Lang.bind(this, this._updateCollectionsButton));
+ Application.modeController.connect('window-mode-changed', this._updateCollectionsButton.bind(this));
+ Application.documentManager.connect('active-collection-changed',
this._updateCollectionsButton.bind(this));
- Application.selectionController.connect('selection-changed',
- Lang.bind(this, this._onSelectionChanged));
+ Application.selectionController.connect('selection-changed', this._onSelectionChanged.bind(this));
this._onSelectionChanged();
- this.connect('destroy', Lang.bind(this,
- function() {
- this._disconnectDocToPrint();
- }));
+ this.connect('destroy', () => {
+ this._disconnectDocToPrint();
+ });
}
vfunc_hide() {
@@ -900,12 +870,11 @@ var SelectionToolbar = GObject.registerClass({
delete this._itemListeners[idx];
}
- selection.forEach(Lang.bind(this,
- function(urn) {
- let doc = Application.documentManager.getItemById(urn);
- let id = doc.connect('info-updated', Lang.bind(this, this._setItemVisibility));
- this._itemListeners[id] = doc;
- }));
+ selection.forEach((urn) => {
+ let doc = Application.documentManager.getItemById(urn);
+ let id = doc.connect('info-updated', this._setItemVisibility.bind(this));
+ this._itemListeners[id] = doc;
+ });
}
_setItemVisibility() {
@@ -922,31 +891,29 @@ var SelectionToolbar = GObject.registerClass({
this._insideRefresh = true;
- selection.forEach(Lang.bind(this,
- function(urn) {
- let doc = Application.documentManager.getItemById(urn);
+ selection.forEach((urn) => {
+ let doc = Application.documentManager.getItemById(urn);
- if ((doc.defaultAppName) &&
- (apps.indexOf(doc.defaultAppName) == -1))
- apps.push(doc.defaultAppName);
- if (!doc.canShare() ||
- (doc.collection != false) ||
- (selection.length > 1))
- showShare = false;
+ if ((doc.defaultAppName) &&
+ (apps.indexOf(doc.defaultAppName) == -1))
+ apps.push(doc.defaultAppName);
+ if (!doc.canShare() ||
+ (doc.collection != false) ||
+ (selection.length > 1))
+ showShare = false;
- showTrash &= doc.canTrash();
- }));
+ showTrash &= doc.canTrash();
+ });
showOpen = (apps.length > 0);
if (selection.length == 1) {
let doc = Application.documentManager.getItemById(selection[0]);
if (!doc.collection) {
- doc.load(null, null, Lang.bind(this,
- function(doc, docModel, error) {
- showPrint = doc.canPrint(docModel);
- this._toolbarPrint.set_sensitive(showPrint);
- }));
+ doc.load(null, null, (doc, docModel, error) => {
+ showPrint = doc.canPrint(docModel);
+ this._toolbarPrint.set_sensitive(showPrint);
+ });
}
}
@@ -979,42 +946,39 @@ var SelectionToolbar = GObject.registerClass({
throw(new Error('Code should not be reached'));
let dialog = new OrganizeCollectionDialog(toplevel);
- dialog.connect('destroy', Lang.bind(this, function() {
+ dialog.connect('destroy', () => {
this._selectionModeAction.change_state(GLib.Variant.new('b', false));
- }));
+ });
}
_onToolbarOpen(widget) {
let selection = Application.selectionController.getSelection();
this._selectionModeAction.change_state(GLib.Variant.new('b', false));
- selection.forEach(Lang.bind(this,
- function(urn) {
- let doc = Application.documentManager.getItemById(urn);
- let toplevel = this.get_toplevel();
- if (!toplevel.is_toplevel())
- throw(new Error('Code should not be reached'));
+ selection.forEach((urn) => {
+ let doc = Application.documentManager.getItemById(urn);
+ let toplevel = this.get_toplevel();
+ if (!toplevel.is_toplevel())
+ throw(new Error('Code should not be reached'));
- doc.open(toplevel, Gtk.get_current_event_time());
- }));
+ doc.open(toplevel, Gtk.get_current_event_time());
+ });
}
_onToolbarTrash(widget) {
let selection = Application.selectionController.getSelection();
let docs = [];
- selection.forEach(Lang.bind(this,
- function(urn) {
- let doc = Application.documentManager.getItemById(urn);
- docs.push(doc);
- }));
+ selection.forEach((urn) => {
+ let doc = Application.documentManager.getItemById(urn);
+ docs.push(doc);
+ });
// Removing an item from DocumentManager changes the selection, so
// we can't use the selection while removing items.
- docs.forEach(Lang.bind(this,
- function(doc) {
- Application.documentManager.removeItem(doc);
- }));
+ docs.forEach((doc) => {
+ Application.documentManager.removeItem(doc);
+ });
let deleteNotification = new Notifications.DeleteNotification(docs);
this._selectionModeAction.change_state(GLib.Variant.new('b', false));
@@ -1024,21 +988,19 @@ var SelectionToolbar = GObject.registerClass({
let selection = Application.selectionController.getSelection();
let dialog = new Properties.PropertiesDialog(selection[0]);
- dialog.connect('response', Lang.bind(this,
- function(widget, response) {
- dialog.destroy();
- this._selectionModeAction.change_state(GLib.Variant.new('b', false));
- }));
+ dialog.connect('response', (widget, response) => {
+ dialog.destroy();
+ this._selectionModeAction.change_state(GLib.Variant.new('b', false));
+ });
}
_onToolbarShare(widget) {
let dialog = new Sharing.SharingDialog();
- dialog.connect('response', Lang.bind(this,
- function(widget, response) {
- dialog.destroy();
- this._selectionModeAction.change_state(GLib.Variant.new('b', false));
- }));
+ dialog.connect('response', (widget, response) => {
+ dialog.destroy();
+ this._selectionModeAction.change_state(GLib.Variant.new('b', false));
+ });
}
_onToolbarPrint(widget) {
@@ -1050,10 +1012,9 @@ var SelectionToolbar = GObject.registerClass({
this._disconnectDocToPrint();
this._docToPrint = Application.documentManager.getItemById(selection[0]);
- this._docBeginPrintId = this._docToPrint.connect('begin-print', Lang.bind(this,
- function(doc) {
- this._selectionModeAction.change_state(GLib.Variant.new('b', false));
- }));
+ this._docBeginPrintId = this._docToPrint.connect('begin-print', (doc) => {
+ this._selectionModeAction.change_state(GLib.Variant.new('b', false));
+ });
this._docToPrint.print(this.get_toplevel());
}
diff --git a/src/sharing.js b/src/sharing.js
index 182b8fac..a46a7bed 100644
--- a/src/sharing.js
+++ b/src/sharing.js
@@ -47,8 +47,6 @@ const _ = imports.gettext.gettext;
const Application = imports.application;
-const Lang = imports.lang;
-
const SharingDialogColumns = {
NAME: 0,
ROLE: 1
@@ -80,15 +78,14 @@ var SharingDialog = GObject.registerClass(class SharingDialog extends Gtk.Dialog
this._entry = null;
this._feed = null;
- this._doc.createGDataEntry(null, Lang.bind(this,
- function(entry, service, exception) {
- if (exception) {
- logError(exception, 'Error getting GData Entry');
- return;
- }
- this._entry = entry;
- this._refreshEntryACL();
- }));
+ this._doc.createGDataEntry(null, (entry, service, exception) => {
+ if (exception) {
+ logError(exception, 'Error getting GData Entry');
+ return;
+ }
+ this._entry = entry;
+ this._refreshEntryACL();
+ });
this._docShare = DocumentShareState.UNKNOWN;
this._pubEdit = false;
@@ -149,7 +146,7 @@ var SharingDialog = GObject.registerClass(class SharingDialog extends Gtk.Dialog
this._changeButton = new Gtk.Button({ label: _("Change"),
sensitive: false,
halign: Gtk.Align.END });
- this._changeButton.connect("clicked", Lang.bind(this, this._onPermissionsButtonClicked));
+ this._changeButton.connect("clicked", this._onPermissionsButtonClicked.bind(this));
this._grid.attach(this._changeButton, 2, 0, 1, 1);
let settingBox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL,
@@ -202,12 +199,11 @@ var SharingDialog = GObject.registerClass(class SharingDialog extends Gtk.Dialog
no_show_all: true,
hexpand: true,
halign: Gtk.Align.START });
- this._contactEntry.connect('changed', Lang.bind(this,
- function() {
- let hasText = !!this._isValidEmail();
- this._saveShare.sensitive = hasText;
- this._comboBoxText.sensitive = hasText;
- }));
+ this._contactEntry.connect('changed', () => {
+ let hasText = !!this._isValidEmail();
+ this._saveShare.sensitive = hasText;
+ this._comboBoxText.sensitive = hasText;
+ });
this._grid.add(this._contactEntry);
// Permission setting labels in combobox
@@ -223,7 +219,7 @@ var SharingDialog = GObject.registerClass(class SharingDialog extends Gtk.Dialog
this._saveShare = new Gtk.Button({ label: _("Add"),
no_show_all: true,
sensitive: false });
- this._saveShare.connect ('clicked', Lang.bind(this, this._onAddClicked));
+ this._saveShare.connect ('clicked', this._onAddClicked.bind(this));
this._grid.attach_next_to(this._saveShare, this._comboBoxText, Gtk.PositionType.RIGHT, 1, 1);
this._noPermission = new Gtk.Label({ halign: Gtk.Align.START,
@@ -335,26 +331,24 @@ var SharingDialog = GObject.registerClass(class SharingDialog extends Gtk.Dialog
// Return a feed containing the acl related to the entry
_refreshEntryACL() {
- this._entry.get_rules_async(this._service, null, null, Lang.bind(this,
- function(entry, result) {
- try {
- this._feed = this._service.query_finish(result);
- this._getScopeRulesEntry();
- } catch(e) {
- logError(e, 'Error getting ACL Feed');
- }
- }));
+ this._entry.get_rules_async(this._service, null, null, (entry, result) => {
+ try {
+ this._feed = this._service.query_finish(result);
+ this._getScopeRulesEntry();
+ } catch(e) {
+ logError(e, 'Error getting ACL Feed');
+ }
+ });
}
_getAccountNames() {
let retval = [];
let sources = Application.sourceManager.getForProviderType('google');
- sources.forEach(Lang.bind(this,
- function(source) {
- let account = source.object.get_account();
- retval.push(account.identity);
- }));
+ sources.forEach((source) => {
+ let account = source.object.get_account();
+ retval.push(account.identity);
+ });
return retval;
}
@@ -384,38 +378,36 @@ var SharingDialog = GObject.registerClass(class SharingDialog extends Gtk.Dialog
let pubEdit = false;
let docShare = DocumentShareState.PRIVATE;
- entries.forEach(Lang.bind(this,
- function(entry) {
- let [type, value] = entry.get_scope();
- let role = entry.get_role();
-
- if (value != null) {
- values.push({ name: value, role: this._getUserRoleString(role) });
-
- if ((accountNames.indexOf(value) != -1) &&
- (role == GData.DOCUMENTS_ACCESS_ROLE_WRITER || role ==
GData.DOCUMENTS_ACCESS_ROLE_OWNER))
- allowChanges = true;
- } else {
- if (role != GData.ACCESS_ROLE_NONE)
- docShare = DocumentShareState.PUBLIC;
- if (role == GData.DOCUMENTS_ACCESS_ROLE_WRITER)
- pubEdit = true;
- }
+ entries.forEach((entry) => {
+ let [type, value] = entry.get_scope();
+ let role = entry.get_role();
+
+ if (value != null) {
+ values.push({ name: value, role: this._getUserRoleString(role) });
- if (role == GData.DOCUMENTS_ACCESS_ROLE_OWNER)
- ownerId = value;
- }));
+ if ((accountNames.indexOf(value) != -1) &&
+ (role == GData.DOCUMENTS_ACCESS_ROLE_WRITER || role ==
GData.DOCUMENTS_ACCESS_ROLE_OWNER))
+ allowChanges = true;
+ } else {
+ if (role != GData.ACCESS_ROLE_NONE)
+ docShare = DocumentShareState.PUBLIC;
+ if (role == GData.DOCUMENTS_ACCESS_ROLE_WRITER)
+ pubEdit = true;
+ }
+
+ if (role == GData.DOCUMENTS_ACCESS_ROLE_OWNER)
+ ownerId = value;
+ });
this._ensureTreeview();
// Set values in the treemodel
- values.forEach(Lang.bind (this,
- function(value) {
- let iter = this._model.append();
- this._model.set(iter,
- [SharingDialogColumns.NAME, SharingDialogColumns.ROLE],
- [value.name, value.role]);
- }));
+ values.forEach((value) => {
+ let iter = this._model.append();
+ this._model.set(iter,
+ [SharingDialogColumns.NAME, SharingDialogColumns.ROLE],
+ [value.name, value.role]);
+ });
// Propagate new state
this._docShare = docShare;
@@ -457,20 +449,20 @@ var SharingDialog = GObject.registerClass(class SharingDialog extends Gtk.Dialog
this._contactEntry.set_sensitive(false);
- this._service.insert_entry_async(GData.DocumentsService.get_primary_authorization_domain(),
- aclLink.get_uri(), accessRule, null, Lang.bind(this,
- function(service, res) {
- this._contactEntry.set_sensitive(true);
- this._contactEntry.set_text('');
+ this._service.insert_entry_async(
+ GData.DocumentsService.get_primary_authorization_domain(),
+ aclLink.get_uri(), accessRule, null, (service, res) => {
+ this._contactEntry.set_sensitive(true);
+ this._contactEntry.set_text('');
- try {
- this._service.insert_entry_finish(res);
- this._refreshEntryACL();
- } catch(e) {
- logError(e, 'Error inserting new ACL rule');
- this._showErrorDialog(_("The document was not updated"));
- }
- }));
+ try {
+ this._service.insert_entry_finish(res);
+ this._refreshEntryACL();
+ } catch(e) {
+ logError(e, 'Error inserting new ACL rule');
+ this._showErrorDialog(_("The document was not updated"));
+ }
+ });
}
// Get the scope from the radiobuttons
@@ -496,19 +488,19 @@ var SharingDialog = GObject.registerClass(class SharingDialog extends Gtk.Dialog
let accessRule = new GData.AccessRule({ scope_type: scopeType,
role: role });
- this._service.insert_entry_async(GData.DocumentsService.get_primary_authorization_domain(),
- aclLink.get_uri(), accessRule, null, Lang.bind(this,
- function(service, res) {
- try {
- service.insert_entry_finish(res);
- this._refreshEntryACL();
- } catch(e) {
- logError(e, 'Error inserting new ACL scope for document');
- this._showErrorDialog(_("The document was not updated"));
- }
+ this._service.insert_entry_async(
+ GData.DocumentsService.get_primary_authorization_domain(),
+ aclLink.get_uri(), accessRule, null, (service, res) => {
+ try {
+ service.insert_entry_finish(res);
+ this._refreshEntryACL();
+ } catch(e) {
+ logError(e, 'Error inserting new ACL scope for document');
+ this._showErrorDialog(_("The document was not updated"));
+ }
- this._permissionChangeFinished();
- }));
+ this._permissionChangeFinished();
+ });
}
_sendNewDocumentRule() {
@@ -553,53 +545,53 @@ var SharingDialog = GObject.registerClass(class SharingDialog extends Gtk.Dialog
let accessRule = entries[idx];
accessRule.set_role(newRole);
- this._service.update_entry_async(GData.DocumentsService.get_primary_authorization_domain(),
- accessRule, null, Lang.bind(this,
- function(service, res) {
- try {
- service.update_entry_finish(res);
- this._refreshEntryACL();
- } catch(e) {
- logError(e, 'Error updating ACL scope for document');
- this._showErrorDialog(_("The document was not updated"));
- }
-
- this._permissionChangeFinished();
- }));
+ this._service.update_entry_async(
+ GData.DocumentsService.get_primary_authorization_domain(),
+ accessRule, null, (service, res) => {
+ try {
+ service.update_entry_finish(res);
+ this._refreshEntryACL();
+ } catch(e) {
+ logError(e, 'Error updating ACL scope for document');
+ this._showErrorDialog(_("The document was not updated"));
+ }
+
+ this._permissionChangeFinished();
+ });
} else if (updateType == DocumentUpdateType.DELETE_PUBLIC) {
// If we are changing the permission to private, delete the public entry.
let accessRule = entries[idx];
- this._service.delete_entry_async(GData.DocumentsService.get_primary_authorization_domain(),
- accessRule, null, Lang.bind(this,
- function(service, res) {
- try {
- service.delete_entry_finish(res);
- this._refreshEntryACL();
- } catch(e) {
- logError(e, 'Error deleting ACL scope for document');
- this._showErrorDialog(_("The document was not updated"));
- }
-
- this._permissionChangeFinished();
- }));
+ this._service.delete_entry_async(
+ GData.DocumentsService.get_primary_authorization_domain(),
+ accessRule, null, (service, res) => {
+ try {
+ service.delete_entry_finish(res);
+ this._refreshEntryACL();
+ } catch(e) {
+ logError(e, 'Error deleting ACL scope for document');
+ this._showErrorDialog(_("The document was not updated"));
+ }
+
+ this._permissionChangeFinished();
+ });
} else if (updateType == DocumentUpdateType.DELETE_SHARE_LINK) {
// Workaround if the doc is shared with link: step 1 delete shared with link permission.
let accessRule = entries[idx];
- this._service.delete_entry_async(GData.DocumentsService.get_primary_authorization_domain(),
- accessRule, null, Lang.bind(this,
- function(service, res) {
- try {
- service.delete_entry_finish(res);
-
- // Workaround if the doc is shared with link: step 2 add the new public
permisssion.
- this._insertNewPermission(newScopeType, newRole);
- } catch(e) {
- logError(e, 'Error deleting ACL scope for document');
- this._showErrorDialog(_("The document was not updated"));
- }
- }));
+ this._service.delete_entry_async(
+ GData.DocumentsService.get_primary_authorization_domain(),
+ accessRule, null, (service, res) => {
+ try {
+ service.delete_entry_finish(res);
+
+ // Workaround if the doc is shared with link: step 2 add the new public permisssion.
+ this._insertNewPermission(newScopeType, newRole);
+ } catch(e) {
+ logError(e, 'Error deleting ACL scope for document');
+ this._showErrorDialog(_("The document was not updated"));
+ }
+ });
}
}
@@ -617,10 +609,9 @@ var SharingDialog = GObject.registerClass(class SharingDialog extends Gtk.Dialog
message_type: Gtk.MessageType.WARNING,
text: errorStr });
- errorDialog.connect ('response', Lang.bind(this,
- function() {
- errorDialog.destroy();
- }));
+ errorDialog.connect ('response', () => {
+ errorDialog.destroy();
+ });
errorDialog.show();
}
});
diff --git a/src/shellSearchProvider.js b/src/shellSearchProvider.js
index f72e78b2..ea47d8b2 100644
--- a/src/shellSearchProvider.js
+++ b/src/shellSearchProvider.js
@@ -19,7 +19,6 @@
*
*/
-const Lang = imports.lang;
const Signals = imports.signals;
const GdPrivate = imports.gi.GdPrivate;
@@ -131,18 +130,17 @@ const CreateCollectionIconJob = class CreateCollectionIconJob {
this._callback = callback;
let query = queryBuilder.buildCollectionIconQuery(this._id);
- Application.connectionQueue.add(query.sparql, null, Lang.bind(this,
- function(object, res) {
- let cursor = null;
-
- try {
- cursor = object.query_finish(res);
- cursor.next_async(null, Lang.bind(this, this._onCursorNext));
- } catch (e) {
- logError(e, 'Unable to run CreateCollectionIconJob');
- this._hasItemIds();
- }
- }));
+ Application.connectionQueue.add(query.sparql, null, (object, res) => {
+ let cursor = null;
+
+ try {
+ cursor = object.query_finish(res);
+ cursor.next_async(null, this._onCursorNext.bind(this));
+ } catch (e) {
+ logError(e, 'Unable to run CreateCollectionIconJob');
+ this._hasItemIds();
+ }
+ });
}
_createItemIcon(cursor) {
@@ -188,7 +186,7 @@ const CreateCollectionIconJob = class CreateCollectionIconJob {
if (valid) {
this._itemIds.push(cursor.get_string(0)[0]);
- cursor.next_async(null, Lang.bind(this, this._onCursorNext));
+ cursor.next_async(null, this._onCursorNext.bind(this));
} else {
cursor.close();
this._hasItemIds();
@@ -201,18 +199,16 @@ const CreateCollectionIconJob = class CreateCollectionIconJob {
return;
}
- this._itemIds.forEach(Lang.bind(this,
- function(itemId) {
- let job = new TrackerUtils.SingleItemJob(itemId, queryBuilder);
- this._itemJobs++;
- job.run(Query.QueryFlags.UNFILTERED, Lang.bind(this,
- function(cursor) {
- let icon = this._createItemIcon(cursor);
- if (icon)
- this._itemIcons.push(icon);
- this._itemJobCollector();
- }));
- }));
+ this._itemIds.forEach((itemId) => {
+ let job = new TrackerUtils.SingleItemJob(itemId, queryBuilder);
+ this._itemJobs++;
+ job.run(Query.QueryFlags.UNFILTERED, (cursor) => {
+ let icon = this._createItemIcon(cursor);
+ if (icon)
+ this._itemIcons.push(icon);
+ this._itemJobCollector();
+ });
+ });
}
_itemJobCollector() {
@@ -242,54 +238,51 @@ const FetchMetasJob = class FetchMetasJob {
_createCollectionPixbuf(meta) {
let job = new CreateCollectionIconJob(meta.id);
- job.run(Lang.bind(this,
- function(icon) {
- if (icon)
- meta.icon = icon;
+ job.run((icon) => {
+ if (icon)
+ meta.icon = icon;
- this._metas.push(meta);
- this._jobCollector();
- }));
+ this._metas.push(meta);
+ this._jobCollector();
+ });
}
run(callback) {
this._callback = callback;
this._activeJobs = this._ids.length;
- this._ids.forEach(Lang.bind(this,
- function(id) {
- let single = new TrackerUtils.SingleItemJob(id, queryBuilder);
- single.run(Query.QueryFlags.UNFILTERED, Lang.bind(this,
- function(cursor) {
- let title = cursor.get_string(Query.QueryColumns.TITLE)[0];
- let filename = cursor.get_string(Query.QueryColumns.FILENAME)[0];
- let rdftype = cursor.get_string(Query.QueryColumns.RDFTYPE)[0];
+ this._ids.forEach((id) => {
+ let single = new TrackerUtils.SingleItemJob(id, queryBuilder);
+ single.run(Query.QueryFlags.UNFILTERED, (cursor) => {
+ let title = cursor.get_string(Query.QueryColumns.TITLE)[0];
+ let filename = cursor.get_string(Query.QueryColumns.FILENAME)[0];
+ let rdftype = cursor.get_string(Query.QueryColumns.RDFTYPE)[0];
- let gicon = null;
- let pixbuf = null;
+ let gicon = null;
+ let pixbuf = null;
- // Collection
- let isCollection = (rdftype.indexOf('nfo#DataContainer') != -1);
+ // Collection
+ let isCollection = (rdftype.indexOf('nfo#DataContainer') != -1);
- if (!isCollection)
- gicon = _createGIcon(cursor);
+ if (!isCollection)
+ gicon = _createGIcon(cursor);
- if (!title || title == '')
- title = GdPrivate.filename_strip_extension(filename);
+ if (!title || title == '')
+ title = GdPrivate.filename_strip_extension(filename);
- if (!title || title == '')
- title = _("Untitled Document");
+ if (!title || title == '')
+ title = _("Untitled Document");
- let meta = { id: id, title: title, icon: gicon };
+ let meta = { id: id, title: title, icon: gicon };
- if (isCollection) {
- this._createCollectionPixbuf(meta);
- } else {
- this._metas.push(meta);
- this._jobCollector();
- }
- }));
- }));
+ if (isCollection) {
+ this._createCollectionPixbuf(meta);
+ } else {
+ this._metas.push(meta);
+ this._jobCollector();
+ }
+ });
+ });
}
}
@@ -306,18 +299,17 @@ const FetchIdsJob = class FetchIdsJob {
let sortBy = Application.settings.get_enum('sort-by');
let query = queryBuilder.buildGlobalQuery(Query.QueryFlags.SEARCH, null, sortBy);
- Application.connectionQueue.add(query.sparql, this._cancellable, Lang.bind(this,
- function(object, res) {
- let cursor = null;
-
- try {
- cursor = object.query_finish(res);
- cursor.next_async(this._cancellable, Lang.bind(this, this._onCursorNext));
- } catch (e) {
- logError(e, 'Unable to run FetchIdsJob');
- callback(this._ids);
- }
- }));
+ Application.connectionQueue.add(query.sparql, this._cancellable, (object, res) => {
+ let cursor = null;
+
+ try {
+ cursor = object.query_finish(res);
+ cursor.next_async(this._cancellable, this._onCursorNext.bind(this));
+ } catch (e) {
+ logError(e, 'Unable to run FetchIdsJob');
+ callback(this._ids);
+ }
+ });
}
_onCursorNext(cursor, res) {
@@ -334,7 +326,7 @@ const FetchIdsJob = class FetchIdsJob {
if (valid) {
this._ids.push(cursor.get_string(Query.QueryColumns.URN)[0]);
- cursor.next_async(this._cancellable, Lang.bind(this, this._onCursorNext));
+ cursor.next_async(this._cancellable, this._onCursorNext.bind(this));
} else {
cursor.close();
this._callback(this._ids);
@@ -385,11 +377,10 @@ var ShellSearchProvider = class ShellSearchProvider {
this._cancellable.reset();
let job = new FetchIdsJob(terms);
- job.run(Lang.bind(this,
- function(ids) {
- Application.application.release();
- invocation.return_value(GLib.Variant.new('(as)', [ ids ]));
- }), this._cancellable);
+ job.run((ids) => {
+ Application.application.release();
+ invocation.return_value(GLib.Variant.new('(as)', [ ids ]));
+ }, this._cancellable);
}
GetSubsearchResultSetAsync(params, invocation) {
@@ -400,34 +391,30 @@ var ShellSearchProvider = class ShellSearchProvider {
this._cancellable.reset();
let job = new FetchIdsJob(terms);
- job.run(Lang.bind(this,
- function(ids) {
- Application.application.release();
- invocation.return_value(GLib.Variant.new('(as)', [ ids ]));
- }), this._cancellable);
+ job.run((ids) => {
+ Application.application.release();
+ invocation.return_value(GLib.Variant.new('(as)', [ ids ]));
+ }, this._cancellable);
}
GetResultMetasAsync(params, invocation) {
let ids = params[0];
Application.application.hold();
- let toFetch = ids.filter(Lang.bind(this,
- function(id) {
- return !(this._cache[id]);
- }));
+ let toFetch = ids.filter((id) => {
+ return !(this._cache[id]);
+ });
if (toFetch.length > 0) {
let job = new FetchMetasJob(toFetch);
- job.run(Lang.bind(this,
- function(metas) {
- // cache the newly fetched results
- metas.forEach(Lang.bind(this,
- function(meta) {
- this._cache[meta.id] = meta;
- }));
-
- this._returnMetasFromCache(ids, invocation);
- }));
+ job.run((metas) => {
+ // cache the newly fetched results
+ metas.forEach((meta) => {
+ this._cache[meta.id] = meta;
+ });
+
+ this._returnMetasFromCache(ids, invocation);
+ });
} else {
this._returnMetasFromCache(ids, invocation);
}
diff --git a/src/trackerController.js b/src/trackerController.js
index 9aa2cc11..23e1c137 100644
--- a/src/trackerController.js
+++ b/src/trackerController.js
@@ -19,7 +19,6 @@
*
*/
-const Lang = imports.lang;
const Signals = imports.signals;
const Application = imports.application;
@@ -85,16 +84,16 @@ var TrackerConnectionQueue = class TrackerConnectionQueue {
if (params.queryType == QueryType.SELECT)
Application.connection.query_async(params.query, params.cancellable,
- Lang.bind(this, this._queueCollector, params));
+ this._queueCollector.bind(this, params));
else if (params.queryType == QueryType.UPDATE)
Application.connection.update_async(params.query, GLib.PRIORITY_DEFAULT, params.cancellable,
- Lang.bind(this, this._queueCollector, params));
+ this._queueCollector.bind(this, params));
else if (params.queryType == QueryType.UPDATE_BLANK)
Application.connection.update_blank_async(params.query, GLib.PRIORITY_DEFAULT,
params.cancellable,
- Lang.bind(this, this._queueCollector, params));
+ this._queueCollector.bind(this, params));
}
- _queueCollector(connection, res, params) {
+ _queueCollector(params, connection, res) {
params.callback(connection, res);
this._running = false;
this._checkQueue();
@@ -121,19 +120,18 @@ const TrackerController = class TrackerController {
// useful for debugging
this._lastQueryTime = 0;
- Application.sourceManager.connect('item-added', Lang.bind(this, this._onSourceAddedRemoved));
- Application.sourceManager.connect('item-removed', Lang.bind(this, this._onSourceAddedRemoved));
+ Application.sourceManager.connect('item-added', this._onSourceAddedRemoved.bind(this));
+ Application.sourceManager.connect('item-removed', this._onSourceAddedRemoved.bind(this));
- Application.modeController.connect('window-mode-changed', Lang.bind(this,
- function(object, newMode) {
- if (this._refreshPending && newMode == this._mode)
- this._refreshForSource();
- }));
+ Application.modeController.connect('window-mode-changed', (object, newMode) => {
+ if (this._refreshPending && newMode == this._mode)
+ this._refreshForSource();
+ });
this._offsetController = this.getOffsetController();
- this._offsetController.connect('offset-changed', Lang.bind(this, this._performCurrentQuery));
+ this._offsetController.connect('offset-changed', this._performCurrentQuery.bind(this));
- Application.settings.connect('changed::sort-by', Lang.bind(this, this._updateSortForSettings));
+ Application.settings.connect('changed::sort-by', this._updateSortForSettings.bind(this));
this._updateSortForSettings();
}
@@ -206,7 +204,7 @@ const TrackerController = class TrackerController {
Utils.debug('Query Cursor: '
+ (GLib.get_monotonic_time() - this._lastQueryTime) / 1000000);
Application.documentManager.addDocumentFromCursor(cursor);
- cursor.next_async(this._cancellable, Lang.bind(this, this._onCursorNext));
+ cursor.next_async(this._cancellable, this._onCursorNext.bind(this));
}
_onQueryExecuted(object, res) {
@@ -215,7 +213,7 @@ const TrackerController = class TrackerController {
+ (GLib.get_monotonic_time() - this._lastQueryTime) / 1000000);
let cursor = object.query_finish(res);
- cursor.next_async(this._cancellable, Lang.bind(this, this._onCursorNext));
+ cursor.next_async(this._cancellable, this._onCursorNext.bind(this));
} catch (e) {
this._onQueryFinished(e);
}
@@ -226,7 +224,7 @@ const TrackerController = class TrackerController {
this._cancellable.reset();
Application.connectionQueue.add(this._currentQuery.sparql,
- this._cancellable, Lang.bind(this, this._onQueryExecuted));
+ this._cancellable, this._onQueryExecuted.bind(this));
}
_refreshInternal(flags) {
@@ -301,12 +299,11 @@ var TrackerCollectionsController = class TrackerCollectionsController extends Tr
constructor() {
super(WindowMode.WindowMode.COLLECTIONS);
- Application.documentManager.connect('active-collection-changed', Lang.bind(this,
- function() {
- let windowMode = Application.modeController.getWindowMode();
- if (windowMode == WindowMode.WindowMode.COLLECTIONS)
- this.refreshForObject();
- }));
+ Application.documentManager.connect('active-collection-changed', () => {
+ let windowMode = Application.modeController.getWindowMode();
+ if (windowMode == WindowMode.WindowMode.COLLECTIONS)
+ this.refreshForObject();
+ });
}
getOffsetController() {
@@ -348,18 +345,17 @@ var TrackerSearchController = class TrackerSearchController extends TrackerContr
constructor() {
super(WindowMode.WindowMode.SEARCH);
- Application.documentManager.connect('active-collection-changed', Lang.bind(this,
- function() {
- let windowMode = Application.modeController.getWindowMode();
- if (windowMode == WindowMode.WindowMode.SEARCH)
- this.refreshForObject();
- }));
+ Application.documentManager.connect('active-collection-changed', () => {
+ let windowMode = Application.modeController.getWindowMode();
+ if (windowMode == WindowMode.WindowMode.SEARCH)
+ this.refreshForObject();
+ });
- Application.sourceManager.connect('active-changed', Lang.bind(this, this.refreshForObject));
- Application.searchController.connect('search-string-changed', Lang.bind(this,
this.refreshForObject));
- Application.searchTypeManager.connect('active-changed', Lang.bind(this, this.refreshForObject));
+ Application.sourceManager.connect('active-changed', this.refreshForObject.bind(this));
+ Application.searchController.connect('search-string-changed', this.refreshForObject.bind(this));
+ Application.searchTypeManager.connect('active-changed', this.refreshForObject.bind(this));
- Application.searchMatchManager.connect('active-changed', Lang.bind(this,
this._onSearchMatchChanged));
+ Application.searchMatchManager.connect('active-changed', this._onSearchMatchChanged.bind(this));
}
_onSearchMatchChanged() {
diff --git a/src/trackerUtils.js b/src/trackerUtils.js
index d5c84613..007568c1 100644
--- a/src/trackerUtils.js
+++ b/src/trackerUtils.js
@@ -19,8 +19,6 @@
*
*/
-const Lang = imports.lang;
-
const Application = imports.application;
function setEditedName(newTitle, docId, callback) {
@@ -51,16 +49,15 @@ var SingleItemJob = class SingleItemJob {
this._callback = callback;
let query = this._builder.buildSingleQuery(flags, this._urn);
- Application.connectionQueue.add(query.sparql, null, Lang.bind(this,
- function(object, res) {
- try {
- let cursor = object.query_finish(res);
- cursor.next_async(null, Lang.bind(this, this._onCursorNext));
- } catch (e) {
- logError(e, 'Unable to query single item');
- this._emitCallback();
- }
- }));
+ Application.connectionQueue.add(query.sparql, null, (object, res) => {
+ try {
+ let cursor = object.query_finish(res);
+ cursor.next_async(null, this._onCursorNext.bind(this));
+ } catch (e) {
+ logError(e, 'Unable to query single item');
+ this._emitCallback();
+ }
+ });
}
_onCursorNext(cursor, res) {
diff --git a/src/utils.js b/src/utils.js
index bb45adfd..60912ca3 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -27,7 +27,6 @@ const Gtk = imports.gi.Gtk;
const Application = imports.application;
-const Lang = imports.lang;
const Signals = imports.signals;
const _ICON_VIEW_SIZE = 128;
@@ -88,10 +87,9 @@ function iconFromRdfType(type) {
}
function getURNsFromPaths(paths, model) {
- return paths.map(Lang.bind(this,
- function(path) {
- return getURNFromPath(path, model);
- }));
+ return paths.map((path) => {
+ return getURNFromPath(path, model);
+ });
}
function getURNFromPath(path, model) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]