[polari/wip/kunaljain/polari-search] working search on searchbar



commit f2edeaabc3c901090257825c26a857ad527f589d
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 25e7111..a50f361 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -226,6 +226,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',
@@ -237,10 +239,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
@@ -274,6 +276,10 @@ const MainWindow = new Lang.Class({
         }
     },
 
+    _Log1: function() {
+        this._results.foreach(r => { r.destroy(); })
+    },
+
     get subtitle() {
         return this._subtitle;
     },
@@ -282,6 +288,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]