[gnome-characters] characterList: fix initial load length in big windows
- From: Daiki Ueno <dueno src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-characters] characterList: fix initial load length in big windows
- Date: Fri, 11 Aug 2017 09:16:06 +0000 (UTC)
commit 6f22391117be6e511caa1c25168af7a03a6f6191
Author: Sam Parkinson <sam@sam.today>
Date: Sun Aug 6 21:35:47 2017 +1000
characterList: fix initial load length in big windows
When the window is big (eg. maximized at 1080p), the character list
initially loads only 100 items, when the screen fits at least 200.
This is a bad experience, as it makes the user think there are only a
small amount of characters in that category. Additionally, it breaks
the lazy-loading; as _onEdgeReached is never called because the user can
not scroll.
To fix this, we need to calculate the amount of characters a screen
fits, and use that number instead.
https://bugzilla.gnome.org/show_bug.cgi?id=785879
src/characterList.js | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/src/characterList.js b/src/characterList.js
index c5ba901..5072dae 100644
--- a/src/characterList.js
+++ b/src/characterList.js
@@ -503,6 +503,22 @@ const CharacterListView = new Lang.Class({
}
},
+ get initialSearchCount() {
+ // Use our parents allocation; we aren't visible before we do the
+ // initial search, so our allocation is 1x1
+ let allocation = this.get_parent().get_allocation();
+
+ // Sometimes more MAX_SEARCH_RESULTS are visible on screen
+ // (eg. fullscreen at 1080p). We always present a over-full screen,
+ // otherwise the lazy loading gets broken
+ let cellSize = getCellSize(this._fontDescription);
+ let cellsPerRow = Math.floor(allocation.width / cellSize);
+ // Ensure the rows cause a scroll
+ let heightInRows = Math.ceil((allocation.height + 1) / cellSize);
+
+ return Math.max(MAX_SEARCH_RESULTS, heightInRows * cellsPerRow);
+ },
+
_addSearchResult: function(result) {
for (let index = 0; index < result.len; index++) {
this._characters.push(Gc.search_result_get(result, index));
@@ -536,21 +552,21 @@ const CharacterListView = new Lang.Class({
this._characters = [];
let criteria = Gc.SearchCriteria.new_category(category.category);
this._searchContext = new Gc.SearchContext({ criteria: criteria });
- this._searchWithContext(this._searchContext, MAX_SEARCH_RESULTS);
+ this._searchWithContext(this._searchContext, this.initialSearchCount);
},
searchByKeywords: function(keywords) {
this._characters = [];
let criteria = Gc.SearchCriteria.new_keywords(keywords, Gc.SearchFlag.NONE);
this._searchContext = new Gc.SearchContext({ criteria: criteria });
- this._searchWithContext(this._searchContext, MAX_SEARCH_RESULTS);
+ this._searchWithContext(this._searchContext, this.initialSearchCount);
},
searchByScripts: function(scripts) {
this._characters = [];
var criteria = Gc.SearchCriteria.new_scripts(scripts);
this._searchContext = new Gc.SearchContext({ criteria: criteria });
- this._searchWithContext(this._searchContext, MAX_SEARCH_RESULTS);
+ this._searchWithContext(this._searchContext, this.initialSearchCount);
},
cancelSearch: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]