[gnome-shell] searchDisplay: Split renderResults()
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] searchDisplay: Split renderResults()
- Date: Tue, 21 Feb 2012 22:01:49 +0000 (UTC)
commit eb0d803617b5fd5eefb96d36c0d240e25aff1644
Author: Florian MÃllner <fmuellner gnome org>
Date: Fri Feb 17 19:39:25 2012 +0100
searchDisplay: Split renderResults()
renderResults() updates the results set, determines the number of
results to display, retrieves the corresponding result metas and
adds a new results actor for each meta.
Splitting the function in those parts allows to move the retrieval
of the result metas into SearchResults, which is where we ensure
flicker-free rendering and control the selection - we want to keep
both features for asynchronous result metas which we are about to
introduce.
https://bugzilla.gnome.org/show_bug.cgi?id=663125
js/ui/searchDisplay.js | 37 +++++++++++++++++++++++--------------
1 files changed, 23 insertions(+), 14 deletions(-)
---
diff --git a/js/ui/searchDisplay.js b/js/ui/searchDisplay.js
index 85a0631..8caf433 100644
--- a/js/ui/searchDisplay.js
+++ b/js/ui/searchDisplay.js
@@ -115,37 +115,42 @@ const GridSearchResults = new Lang.Class({
this.actor.connect('notify::width', Lang.bind(this, function() {
this._width = this.actor.width;
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
- this._tryAddResults();
+ let results = this.getResultsForDisplay();
+ if (results.length == 0)
+ return;
+
+ let metas = provider.getResultMetas(results);
+ this.renderResults(metas);
}));
}));
this._notDisplayedResult = [];
this._terms = [];
},
- _tryAddResults: function() {
+ getResultsForDisplay: function() {
let canDisplay = this._grid.childrenInRow(this._width) * MAX_SEARCH_RESULTS_ROWS
- this._grid.visibleItemsCount();
let numResults = Math.min(this._notDisplayedResult.length, canDisplay);
- if (numResults == 0)
- return;
- let results = this._notDisplayedResult.splice(0, numResults);
- let metas = this.provider.getResultMetas(results);
- for (let i = 0; i < metas.length; i++) {
- let display = new SearchResult(this.provider, metas[i], this._terms);
- this._grid.addItem(display.actor);
- }
+
+ return this._notDisplayedResult.splice(0, numResults);
},
getVisibleResultCount: function() {
return this._grid.visibleItemsCount();
},
- renderResults: function(results, terms) {
+ setResults: function(results, terms) {
// copy the lists
this._notDisplayedResult = results.slice(0);
this._terms = terms.slice(0);
- this._tryAddResults();
+ },
+
+ renderResults: function(metas) {
+ for (let i = 0; i < metas.length; i++) {
+ let display = new SearchResult(this.provider, metas[i], this._terms);
+ this._grid.addItem(display.actor);
+ }
},
clear: function () {
@@ -350,7 +355,9 @@ const SearchResults = new Lang.Class({
let meta = this._metaForProvider(provider);
meta.resultDisplay.clear();
meta.actor.show();
- meta.resultDisplay.renderResults(results, terms);
+ meta.resultDisplay.setResults(providerResults, terms);
+ let displayResults = meta.resultDisplay.getResultsForDisplay();
+ meta.resultDisplay.renderResults(provider.getResultMetas(displayResults));
return true;
},
@@ -383,7 +390,9 @@ const SearchResults = new Lang.Class({
this._clearDisplayForProvider(i);
let meta = this._metaForProvider(provider);
meta.actor.show();
- meta.resultDisplay.renderResults(providerResults, terms);
+ meta.resultDisplay.setResults(providerResults, terms);
+ let displayResults = meta.resultDisplay.getResultsForDisplay();
+ meta.resultDisplay.renderResults(provider.getResultMetas(displayResults));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]