[polari/wip/fmuellner/combined-gsoc: 5/103] working search on searchbar



commit 3f742638b0ccbe7f2833afc32d85883db5eb5d37
Author: Kunaal Jain <kunaalus gmail com>
Date:   Fri Jun 10 02:12:21 2016 +0530

    working search on searchbar

 src/mainWindow.js |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 269aa41..0c3f43e 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -223,6 +223,8 @@ const MainWindow = new Lang.Class({
                            GObject.BindingFlags.SYNC_CREATE |
                            GObject.BindingFlags.BIDIRECTIONAL);
         this._search_bar.connect_entry(this._search_entry);
+        this._search_entry.connect('search-changed',
+                                   Lang.bind(this, this._handleSearchChanged));
 
         this._search_active_button.connect(
             'toggled',
@@ -234,10 +236,10 @@ const MainWindow = new Lang.Class({
             }));
 
         //test
-        let logManager = LogManager.getDefault();
+        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 }"
-        logManager.query(query1,null,Lang.bind(this, this._Log));
+        this._logManager.query(query1,null,Lang.bind(this, this._Log));
         log("hello");
         //test
         // search end
@@ -271,6 +273,10 @@ const MainWindow = new Lang.Class({
         }
     },
 
+    _Log1: function() {
+        this._results.foreach(r => { r.destroy(); })
+    },
+
     get subtitle() {
         return this._subtitle;
     },
@@ -279,6 +285,15 @@ const MainWindow = new Lang.Class({
         return this._subtitle.length > 0;
     },
 
+    _handleSearchChanged: function(entry) {
+        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);
+        log(query1);
+        this._logManager.query(query1,null,Lang.bind(this, this._Log));
+    },
+
     _onWindowStateEvent: function(widget, event) {
         let state = event.get_window().get_state();
 


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