[gnome-shell] dash: Clean up search pane creation



commit 619066780f6af70aa5001e82cf372432c401fd51
Author: Colin Walters <walters verbum org>
Date:   Wed Aug 12 17:07:00 2009 -0400

    dash: Clean up search pane creation
    
    There was some weirdness relating to when the search pane is shown
    in a timeout, and how that relates to setSearch.  Instead of doing
    this in the timeout, just call setSearch() in the timeout.  The
    pane hide/show state is directly controlled from the handler.

 js/ui/dash.js |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/js/ui/dash.js b/js/ui/dash.js
index 479a5d1..1059f40 100644
--- a/js/ui/dash.js
+++ b/js/ui/dash.js
@@ -447,11 +447,19 @@ Dash.prototype = {
         this._searchAreaApps = null;
         this._searchAreaDocs = null;
 
-        this._searchQueued = false;
+        this._searchId = 0;
         this._searchEntry.entry.connect('text-changed', Lang.bind(this, function (se, prop) {
             let text = this._searchEntry.getText();
+            text = text.replace(/^\s+/g, "").replace(/\s+$/g, "")
             this._searchActive = text != '';
-            if (this._searchQueued)
+            if (!this._searchActive) {
+                if (this._searchPane != null)
+                    this._searchPane.close();
+                if (this._searchId > 0)
+                    Mainloop.source_remove(this._searchId);
+                return;
+            }
+            if (this._searchId > 0)
                 return;
             if (this._searchPane == null) {
                 this._searchPane = new ResultPane(this);
@@ -468,18 +476,13 @@ Dash.prototype = {
                 this._addPane(this._searchPane);
                 this._searchEntry.setPane(this._searchPane);
             }
-            this._searchQueued = true;
-            Mainloop.timeout_add(250, Lang.bind(this, function() {
+            this._searchPane.open();
+            this._searchId = Mainloop.timeout_add(150, Lang.bind(this, function() {
+                this._searchId = 0;
                 let text = this._searchEntry.getText();
-                // Strip leading and trailing whitespace
                 text = text.replace(/^\s+/g, "").replace(/\s+$/g, "");
-                this._searchQueued = false;
                 this._searchAreaApps.setSearch(text);
                 this._searchAreaDocs.setSearch(text);
-                if (text == '')
-                    this._searchPane.close();
-                else
-                    this._searchPane.open();
                 return false;
             }));
         }));



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