[gnome-documents/wip/rishi/init-getting-started: 2/6] application: Make window creation complete asynchronously
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/rishi/init-getting-started: 2/6] application: Make window creation complete asynchronously
- Date: Tue, 12 Dec 2017 13:55:20 +0000 (UTC)
commit a17c36ed3c26d63ec849e82d62df66bc0d4ed180
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Dec 7 20:53:10 2017 +0100
application: Make window creation complete asynchronously
Creating MainWindow starts the TrackerControllers. The getting started
PDF needs to be located before that happens, to let the
TrackerControllers include it in their queries.
src/application.js | 78 ++++++++++++++++++++++++++++++++++-----------------
1 files changed, 52 insertions(+), 26 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 70dbfca..d1a9572 100644
--- a/src/application.js
+++ b/src/application.js
@@ -420,9 +420,16 @@ var Application = new Lang.Class({
Utils.populateActionGroup(this, actionEntries, 'app');
},
- _createWindow: function() {
- if (this._mainWindow)
+ _createWindow: function(callback) {
+ if (this._mainWindow) {
+ Mainloop.idle_add(Lang.bind(this,
+ function() {
+ callback();
+ return GLib.SOURCE_REMOVE;
+ }));
+
return;
+ }
if (!this.isBooks)
this._initGettingStarted();
@@ -440,6 +447,20 @@ var Application = new Lang.Class({
// start miners
this._startMiners();
+
+ Mainloop.idle_add(Lang.bind(this,
+ function() {
+ callback();
+ return GLib.SOURCE_REMOVE;
+ }));
+ },
+
+ _presentWindow: function() {
+ if (!this._mainWindow)
+ throw(new Error('this._mainWindow == null'));
+
+ this._mainWindow.present_with_time(this._activationTimestamp);
+ this._activationTimestamp = Gdk.CURRENT_TIME;
},
vfunc_dbus_register: function(connection, path) {
@@ -482,12 +503,14 @@ var Application = new Lang.Class({
vfunc_activate: function() {
if (!this._mainWindow) {
- this._createWindow();
- modeController.setWindowMode(WindowMode.WindowMode.DOCUMENTS);
+ this._createWindow(Lang.bind(this,
+ function() {
+ modeController.setWindowMode(WindowMode.WindowMode.DOCUMENTS);
+ this._presentWindow();
+ }));
+ } else {
+ this._presentWindow();
}
-
- this._mainWindow.present_with_time(this._activationTimestamp);
- this._activationTimestamp = Gdk.CURRENT_TIME;
},
_clearState: function() {
@@ -526,21 +549,22 @@ var Application = new Lang.Class({
},
_onActivateResult: function(provider, urn, terms, timestamp) {
- this._createWindow();
-
- let doc = documentManager.getItemById(urn);
- if (doc) {
- 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);
-
+ this._createWindow(Lang.bind(this,
+ function() {
+ let doc = documentManager.getItemById(urn);
+ if (doc) {
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);
+
+ doActivate.apply(this, [doc]);
+ }));
+ }
+ }));
function doActivate(doc) {
documentManager.setActiveItem(doc);
@@ -560,12 +584,14 @@ var Application = new Lang.Class({
},
_onLaunchSearch: function(provider, terms, timestamp) {
- this._createWindow();
- modeController.setWindowMode(WindowMode.WindowMode.DOCUMENTS);
- searchController.setString(terms.join(' '));
+ this._createWindow(Lang.bind(this,
+ function() {
+ modeController.setWindowMode(WindowMode.WindowMode.DOCUMENTS);
+ searchController.setString(terms.join(' '));
- this._activationTimestamp = timestamp;
- this.activate();
+ this._activationTimestamp = timestamp;
+ this.activate();
+ }));
},
getScaleFactor: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]