[polari/wip/kunaljain/polari-search] added cancellable



commit 2bd8dfdfd3536db6bc4c8cb7a3703f8089d9b33c
Author: Kunaal Jain <kunaalus gmail com>
Date:   Sat Jun 11 00:24:29 2016 +0530

    added cancellable

 src/mainWindow.js |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index a50f361..4d278a1 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -210,6 +210,8 @@ const MainWindow = new Lang.Class({
         // this.connect('key-press-event', Lang.bind(this, this._handleKeyPress));
 
         // search start
+        this._cancellable  = new Gio.Cancellable();
+
         Utils.initActions(this,
                          [
                           { name: 'search-active',
@@ -241,7 +243,7 @@ const MainWindow = new Lang.Class({
         //test
         this._logManager = LogManager.getDefault();
         let query = "select ?text as ?mms where { ?msg a nmo:IMMessage; nie:plainTextContent ?text. ?msg 
nmo:communicationChannel ?channel. ?channel nie:title '#tracker'. ?msg nmo:from ?contact. ?contact 
nco:nickname 'bijan' . ?msg fts:match 'wonderful' }"
-        let query1 = "select ?nick as ?name ?text as ?mms where { ?msg a nmo:IMMessage; nie:plainTextContent 
?text. ?msg nmo:communicationChannel ?channel. ?channel nie:title '#tracker'. ?msg nmo:from ?contact. 
?contact nco:nickname ?nick }"
+        let query1 = "select ?msg as ?id ?nick as ?name ?text as ?mms where { ?msg a nmo:IMMessage; 
nie:plainTextContent ?text. ?msg nmo:communicationChannel ?channel. ?channel nie:title '#tracker'. ?msg 
nmo:from ?contact. ?contact nco:nickname ?nick }"
         this._logManager.query(query1,null,Lang.bind(this, this._Log));
         log("hello");
         //test
@@ -272,6 +274,8 @@ const MainWindow = new Lang.Class({
                                         ellipsize: Pango.EllipsizeMode.END,
                                         max_width_chars: 18  });
             row.add(label);
+            row.uid = events[i].id;
+            print(row.uid);
             this._results.add(row);
         }
     },
@@ -289,12 +293,14 @@ const MainWindow = new Lang.Class({
     },
 
     _handleSearchChanged: function(entry) {
+        this._cancellable.cancel();
+        this._cancellable.reset();
         this._Log1();
         let text = entry.get_text().replace(/^\s+|\s+$/g, '');
         log(text);
-        let query1 = ("select ?text as ?mms ?text as ?id where { ?msg a nmo:IMMessage . ?msg 
nie:plainTextContent ?text . ?msg fts:match '%s*' }").format(text);
+        let query1 = ("select ?text as ?mms ?msg as ?id where { ?msg a nmo:IMMessage . ?msg 
nie:plainTextContent ?text . ?msg fts:match '%s*' }").format(text);
         log(query1);
-        this._logManager.query(query1,null,Lang.bind(this, this._Log));
+        this._logManager.query(query1,this._cancellable,Lang.bind(this, this._Log));
     },
 
     _onWindowStateEvent: function(widget, event) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]