[gnome-characters] characterList: load more on resize



commit 6e08f5b1e2b694b59bff564f62dfac378122d551
Author: Sam Parkinson <sam@sam.today>
Date:   Sun Aug 6 21:44:29 2017 +1000

    characterList: load more on resize
    
    Resizing the window to be larger than the result set is very similar to
    scrolling the end of the result set.  However, previously resizing the
    window would not trigger loading more search results.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785879

 src/characterList.js |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/characterList.js b/src/characterList.js
index 5072dae..4a3acbf 100644
--- a/src/characterList.js
+++ b/src/characterList.js
@@ -496,13 +496,18 @@ const CharacterListView = new Lang.Class({
         this.show_all();
     },
 
-    _onEdgeReached: function(scrolled, pos) {
-        if (pos == Gtk.PositionType.BOTTOM &&
-            this._searchContext != null && !this._searchContext.is_finished()) {
+    _maybeLoadMore() {
+        if (this._searchContext != null && !this._searchContext.is_finished()) {
             this._searchWithContext(this._searchContext, MAX_SEARCH_RESULTS);
         }
     },
 
+    _onEdgeReached: function(scrolled, pos) {
+        if (pos == Gtk.PositionType.BOTTOM) {
+            this._maybeLoadMore();
+        }
+    },
+
     get initialSearchCount() {
         // Use our parents allocation; we aren't visible before we do the
         // initial search, so our allocation is 1x1
@@ -519,6 +524,14 @@ const CharacterListView = new Lang.Class({
         return Math.max(MAX_SEARCH_RESULTS, heightInRows * cellsPerRow);
     },
 
+    vfunc_size_allocate: function(allocation) {
+        this.parent(allocation);
+
+        if (this._characters.length < this.initialSearchCount) {
+            this._maybeLoadMore();
+        }
+    },
+
     _addSearchResult: function(result) {
         for (let index = 0; index < result.len; index++) {
             this._characters.push(Gc.search_result_get(result, index));


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