searchDisplay: Make the results display in charge of updating the actor
While this is a very simple translation right now, soon enough it will be so that it will have a less crazy "public" API and can do things like cache result metas. https://bugzilla.gnome.org/show_bug.cgi?id=693836
This commit is contained in:
parent
5ab4c484a5
commit
19749bb37f
@ -202,6 +202,41 @@ const SearchResultsBase = new Lang.Class({
|
||||
// copy the lists
|
||||
this._notDisplayedResult = results.slice(0);
|
||||
this._terms = terms.slice(0);
|
||||
},
|
||||
|
||||
_setMoreIconVisible: function(visible) {
|
||||
},
|
||||
|
||||
updateSearch: function(providerResults, terms, callback) {
|
||||
this.setResults(providerResults, terms);
|
||||
if (providerResults.length == 0) {
|
||||
this.clear();
|
||||
callback();
|
||||
} else {
|
||||
let results = this.getResultsForDisplay();
|
||||
|
||||
this.provider.getResultMetas(results, Lang.bind(this, function(metas) {
|
||||
this.clear();
|
||||
|
||||
// Hiding drops the key focus if we have it
|
||||
let focus = global.stage.get_key_focus();
|
||||
|
||||
// To avoid CSS transitions causing flickering when
|
||||
// the first search result stays the same, we hide the
|
||||
// content while filling in the results.
|
||||
this.actor.hide();
|
||||
|
||||
this.renderResults(metas);
|
||||
|
||||
this._setMoreIconVisible(this.hasMoreResults() && this.provider.canLaunchSearch);
|
||||
|
||||
this.actor.show();
|
||||
if (this.actor.contains(focus))
|
||||
global.stage.set_key_focus(focus);
|
||||
|
||||
callback();
|
||||
}));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -230,6 +265,10 @@ const ListSearchResults = new Lang.Class({
|
||||
this.actor.add(this._content, { expand: true });
|
||||
},
|
||||
|
||||
_setMoreIconVisible: function(visible) {
|
||||
this.providerIcon.moreIcon.visible = true;
|
||||
},
|
||||
|
||||
getResultsForDisplay: function() {
|
||||
let canDisplay = MAX_LIST_SEARCH_RESULTS_ROWS;
|
||||
let newResults = this._notDisplayedResult.splice(0, canDisplay);
|
||||
@ -482,41 +521,11 @@ const SearchResults = new Lang.Class({
|
||||
let [provider, providerResults] = results;
|
||||
let meta = this._metaForProvider(provider);
|
||||
|
||||
if (providerResults.length == 0) {
|
||||
meta.resultDisplay.clear();
|
||||
meta.actor.hide();
|
||||
meta.resultDisplay.setResults([], []);
|
||||
meta.actor.visible = providerResults.length > 0;
|
||||
meta.resultDisplay.updateSearch(providerResults, terms, Lang.bind(this, function() {
|
||||
this._maybeSetInitialSelection();
|
||||
this._updateStatusText();
|
||||
} else {
|
||||
meta.resultDisplay.setResults(providerResults, terms);
|
||||
let results = meta.resultDisplay.getResultsForDisplay();
|
||||
|
||||
if (meta.icon)
|
||||
meta.icon.moreIcon.visible =
|
||||
meta.resultDisplay.hasMoreResults() &&
|
||||
provider.canLaunchSearch;
|
||||
|
||||
provider.getResultMetas(results, Lang.bind(this, function(metas) {
|
||||
meta.resultDisplay.clear();
|
||||
meta.actor.show();
|
||||
|
||||
// Hiding drops the key focus if we have it
|
||||
let focus = global.stage.get_key_focus();
|
||||
// To avoid CSS transitions causing flickering when
|
||||
// the first search result stays the same, we hide the
|
||||
// content while filling in the results.
|
||||
this._content.hide();
|
||||
|
||||
meta.resultDisplay.renderResults(metas);
|
||||
this._maybeSetInitialSelection();
|
||||
this._updateStatusText();
|
||||
|
||||
this._content.show();
|
||||
if (this._content.contains(focus))
|
||||
global.stage.set_key_focus(focus);
|
||||
}));
|
||||
}
|
||||
}));
|
||||
},
|
||||
|
||||
activateDefault: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user