[the-board/tracker: 5/14] [model] Change PageManager to use TrackerClient
- From: Lucas Rocha <lucasr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [the-board/tracker: 5/14] [model] Change PageManager to use TrackerClient
- Date: Sat, 23 Jul 2011 08:22:44 +0000 (UTC)
commit 09cf27acf337d9e6dc031a1da7f1c5472578bb21
Author: Lucas Rocha <lucasr lucasr org>
Date: Sun May 8 11:34:38 2011 +0100
[model] Change PageManager to use TrackerClient
src/js/model/pageManager.js | 61 ++++++++-----------------------------------
1 files changed, 11 insertions(+), 50 deletions(-)
---
diff --git a/src/js/model/pageManager.js b/src/js/model/pageManager.js
index 5f29661..0bf4ad7 100644
--- a/src/js/model/pageManager.js
+++ b/src/js/model/pageManager.js
@@ -3,12 +3,9 @@ const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Signals = imports.signals;
-// gi imports
-const GIO = imports.gi.Gio;
-const Tracker = imports.gi.Tracker;
-
// model imports
const PageModel = imports.model.pageModel;
+const TrackerClient = imports.model.trackerClient;
let State = {
IDLE : 0,
@@ -37,19 +34,16 @@ PageManager.prototype = {
},
_connectToTracker : function() {
- if (this._connection) {
+ if (this._tracker) {
return;
}
// Now we're in connecting state
this._setState(State.CONNECTING);
- // This will allow to cancell operation is necessary
- this._getConnectionCancellable = new GIO.Cancellable();
-
- Tracker.SparqlConnection.get_async(this._getConnectionCancellable,
- Lang.bind(this, this._onGetConnectionAsync),
- null);
+ this._tracker = new TrackerClient.TrackerClient();
+ this._tracker.connect("state-changed",
+ Lang.bind(this, this._onTrackerStateChanged));
},
_setState : function(state) {
@@ -62,26 +56,16 @@ PageManager.prototype = {
this.emit("state-changed");
},
- _finishLoading : function() {
- // discard cancellable
- delete this._pageListingCancellable;
-
- this._setState(State.LOADED);
-
- this._monitorPagesDir();
- },
-
- _createPageModel : function(id, filename) {
+ _createPageModel : function(id) {
let isNew = false;
- if (!id) {
+ if (id == undefined) {
id = Math.floor(Date.now() / 1000);
- filename = id + '.json';
isNew = true;
}
- let modelArgs = { id: id,
- path: this._pagesDir + '/' + filename,
+ let modelArgs = { tracker: this._tracker,
+ id: id,
isNew: isNew };
let pageModel = new PageModel.PageModel(modelArgs);
@@ -90,11 +74,6 @@ PageManager.prototype = {
pageModel.connect("dirty-changed",
Lang.bind(this, this._onPageModelDirtyChanged));
- this._pages.push(pageModel);
- this._sortPages();
-
- this.emit("page-added", pageModel);
-
return pageModel;
},
@@ -146,22 +125,8 @@ PageManager.prototype = {
Lang.bind(this, onPageModelsSaved));
},
- _onGetConnectionAsync : function(source, result, data) {
- let cancellable = this._getConnectionCancellable;
- delete this._getConnectionCancellable;
-
- // If operation has been cancelled, we just stop
- if (cancellable.is_cancelled()) {
- return;
- }
-
- try {
- this._connection = Tracker.SparqlConnection.get_finish(result);
- } catch(e) {
- log("PageManager: failed to connect to Tracker");
- }
-
- if (this._connection) {
+ _onTrackerStateChanged : function() {
+ if (this._tracker.state == TrackerClient.State.READY) {
this._setState(State.READY);
}
},
@@ -219,10 +184,6 @@ PageManager.prototype = {
}
},
- get latestPage() {
- return this._pages[this._pages.length - 1] || null;
- },
-
get state() {
return this._state;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]