[gnome-shell/eos3.8: 74/255] Add isAnimating property and 'search-progress-updated' signal to SearchResults



commit 8ade69e92ed2a88f81ba582c5fecfa34a886a0e5
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Fri May 19 22:52:11 2017 +0100

    Add isAnimating property and 'search-progress-updated' signal to SearchResults
    
    This will be used from a new class ViewDisplay that will be used to manage
    different widgets that will be used to compose the desktop, including the
    search box that will be placed on top of the icons grid.

 js/ui/search.js | 36 +++++++++++++++++++++++++++++++++---
 1 file changed, 33 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/search.js b/js/ui/search.js
index cce72fae3e..9706361d37 100644
--- a/js/ui/search.js
+++ b/js/ui/search.js
@@ -427,7 +427,10 @@ class GridSearchResults extends SearchResultsBase {
 });
 
 var SearchResultsView = GObject.registerClass({
-    Signals: { 'terms-changed': {} },
+    Signals: {
+        'terms-changed': {},
+        'search-progress-updated': {},
+    },
 }, class SearchResultsView extends St.BoxLayout {
     _init() {
         super._init({ name: 'searchResults', vertical: true });
@@ -468,6 +471,7 @@ var SearchResultsView = GObject.registerClass({
 
         this._terms = [];
         this._results = {};
+        this._isAnimating = false;
 
         this._providers = [];
 
@@ -686,21 +690,43 @@ var SearchResultsView = GObject.registerClass({
         return this._providers.some(p => p.searchInProgress);
     }
 
+    get isAnimating() {
+        return this._isAnimating;
+    }
+
+    set isAnimating(v) {
+        if (this._isAnimating === v)
+            return;
+
+        this._isAnimating = v;
+        this._updateSearchProgress();
+        if (!this._isAnimating) {
+            this._providers.forEach(provider => {
+                let results = this._results[provider.id];
+                if (results)
+                    this._updateResults(provider, results);
+            });
+        }
+    }
+
     _updateSearchProgress() {
         let haveResults = this._providers.some(provider => {
             let display = provider.display;
             return display.getFirstResult() != null;
         });
+        let showStatus = !haveResults && !this.isAnimating;
 
         this._scrollView.visible = haveResults;
-        this._statusBin.visible = !haveResults;
+        this._statusBin.visible = showStatus;
 
-        if (!haveResults) {
+        if (showStatus) {
             if (this.searchInProgress)
                 this._statusText.set_text(_("Searching…"));
             else
                 this._statusText.set_text(_("No results."));
         }
+
+        this.emit('search-progress-updated');
     }
 
     _updateResults(provider, results) {
@@ -716,6 +742,10 @@ var SearchResultsView = GObject.registerClass({
     }
 
     activateDefault() {
+        // If we are about to activate a result, we are done animating and need
+        // to update the display immediately.
+        this.isAnimating = false;
+
         // If we have a search queued up, force the search now.
         if (this._searchTimeoutId > 0)
             this._doSearch();


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