searchDisplay: Remove the "provider meta"
As everything is tracked on the SearchResults or subclasses of now, just use that, which we call the "provider display". https://bugzilla.gnome.org/show_bug.cgi?id=693836
This commit is contained in:
parent
74a6ca58ef
commit
98eaef621a
@ -200,6 +200,12 @@ const SearchResultsBase = new Lang.Class({
|
|||||||
this.actor.add(separator.actor);
|
this.actor.add(separator.actor);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
destroy: function() {
|
||||||
|
this.actor.destroy();
|
||||||
|
this._notDisplayedResult = [];
|
||||||
|
this._terms = [];
|
||||||
|
},
|
||||||
|
|
||||||
_clearResultDisplay: function() {
|
_clearResultDisplay: function() {
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -401,9 +407,9 @@ const SearchResults = new Lang.Class({
|
|||||||
this._content.add(this._statusBin, { expand: true });
|
this._content.add(this._statusBin, { expand: true });
|
||||||
this._statusBin.add_actor(this._statusText);
|
this._statusBin.add_actor(this._statusText);
|
||||||
this._providers = this._searchSystem.getProviders();
|
this._providers = this._searchSystem.getProviders();
|
||||||
this._providerMeta = [];
|
this._providerDisplays = {};
|
||||||
for (let i = 0; i < this._providers.length; i++) {
|
for (let i = 0; i < this._providers.length; i++) {
|
||||||
this.createProviderMeta(this._providers[i]);
|
this.createProviderDisplay(this._providers[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._highlightDefault = false;
|
this._highlightDefault = false;
|
||||||
@ -421,45 +427,30 @@ const SearchResults = new Lang.Class({
|
|||||||
Util.ensureActorVisibleInScrollView(this._scrollView, icon);
|
Util.ensureActorVisibleInScrollView(this._scrollView, icon);
|
||||||
},
|
},
|
||||||
|
|
||||||
createProviderMeta: function(provider) {
|
createProviderDisplay: function(provider) {
|
||||||
let resultDisplay = null;
|
let providerDisplay = null;
|
||||||
|
|
||||||
if (provider.appInfo) {
|
if (provider.appInfo) {
|
||||||
resultDisplay = new ListSearchResults(provider);
|
providerDisplay = new ListSearchResults(provider);
|
||||||
} else {
|
} else {
|
||||||
resultDisplay = new GridSearchResults(provider);
|
providerDisplay = new GridSearchResults(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
resultDisplay.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
|
providerDisplay.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
|
||||||
|
this._providerDisplays[provider.id] = providerDisplay;
|
||||||
let resultDisplayBin = new St.Bin({ child: resultDisplay.actor,
|
this._content.add(providerDisplay.actor);
|
||||||
x_fill: true,
|
|
||||||
y_fill: true });
|
|
||||||
providerBox.add(resultDisplayBin, { expand: true });
|
|
||||||
|
|
||||||
let separator = new Separator.HorizontalSeparator({ style_class: 'search-section-separator' });
|
|
||||||
providerBox.add(separator.actor);
|
|
||||||
|
|
||||||
this._providerMeta.push({ provider: provider,
|
|
||||||
resultDisplay: resultDisplay });
|
|
||||||
this._content.add(resultDisplay.actor);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
destroyProviderMeta: function(provider) {
|
destroyProviderDisplay: function(provider) {
|
||||||
for (let i=0; i < this._providerMeta.length; i++) {
|
this._providerDisplays[provider.id].destroy();
|
||||||
let meta = this._providerMeta[i];
|
delete this._providerDisplays[provider.id];
|
||||||
if (meta.provider == provider) {
|
|
||||||
meta.resultDisplay.actor.destroy();
|
|
||||||
this._providerMeta.splice(i, 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_clearDisplay: function() {
|
_clearDisplay: function() {
|
||||||
for (let i = 0; i < this._providerMeta.length; i++) {
|
for (let i = 0; i < this._providers.length; i++) {
|
||||||
let meta = this._providerMeta[i];
|
let provider = this._providers[i];
|
||||||
meta.resultDisplay.clear();
|
let providerDisplay = this._providerDisplays[provider.id];
|
||||||
|
providerDisplay.clear();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -476,20 +467,17 @@ const SearchResults = new Lang.Class({
|
|||||||
this._statusBin.show();
|
this._statusBin.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
_metaForProvider: function(provider) {
|
|
||||||
return this._providerMeta[this._providers.indexOf(provider)];
|
|
||||||
},
|
|
||||||
|
|
||||||
_maybeSetInitialSelection: function() {
|
_maybeSetInitialSelection: function() {
|
||||||
let newDefaultResult = null;
|
let newDefaultResult = null;
|
||||||
|
|
||||||
for (let i = 0; i < this._providerMeta.length; i++) {
|
for (let i = 0; i < this._providers.length; i++) {
|
||||||
let meta = this._providerMeta[i];
|
let provider = this._providers[i];
|
||||||
|
let display = this._providerDisplays[provider.id];
|
||||||
|
|
||||||
if (!meta.resultDisplay.actor.visible)
|
if (!display.actor.visible)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
let firstResult = meta.resultDisplay.getFirstResult();
|
let firstResult = display.getFirstResult();
|
||||||
if (firstResult) {
|
if (firstResult) {
|
||||||
newDefaultResult = firstResult;
|
newDefaultResult = firstResult;
|
||||||
break; // select this one!
|
break; // select this one!
|
||||||
@ -509,11 +497,14 @@ const SearchResults = new Lang.Class({
|
|||||||
_updateStatusText: function () {
|
_updateStatusText: function () {
|
||||||
let haveResults = false;
|
let haveResults = false;
|
||||||
|
|
||||||
for (let i = 0; i < this._providerMeta.length; ++i)
|
for (let i = 0; i < this._providers.length; i++) {
|
||||||
if (this._providerMeta[i].resultDisplay.getFirstResult()) {
|
let provider = this._providers[i];
|
||||||
|
let display = this._providerDisplays[provider.id];
|
||||||
|
if (display.getFirstResult()) {
|
||||||
haveResults = true;
|
haveResults = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!haveResults) {
|
if (!haveResults) {
|
||||||
this._statusText.set_text(_("No results."));
|
this._statusText.set_text(_("No results."));
|
||||||
@ -526,9 +517,9 @@ const SearchResults = new Lang.Class({
|
|||||||
_updateResults: function(searchSystem, results) {
|
_updateResults: function(searchSystem, results) {
|
||||||
let terms = searchSystem.getTerms();
|
let terms = searchSystem.getTerms();
|
||||||
let [provider, providerResults] = results;
|
let [provider, providerResults] = results;
|
||||||
let meta = this._metaForProvider(provider);
|
let display = this._providerDisplays[provider.id];
|
||||||
|
|
||||||
meta.resultDisplay.updateSearch(providerResults, terms, Lang.bind(this, function() {
|
display.updateSearch(providerResults, terms, Lang.bind(this, function() {
|
||||||
this._maybeSetInitialSelection();
|
this._maybeSetInitialSelection();
|
||||||
this._updateStatusText();
|
this._updateStatusText();
|
||||||
}));
|
}));
|
||||||
|
@ -508,12 +508,12 @@ const ViewSelector = new Lang.Class({
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
this._searchSystem.registerProvider(provider);
|
this._searchSystem.registerProvider(provider);
|
||||||
this._searchResults.createProviderMeta(provider);
|
this._searchResults.createProviderDisplay(provider);
|
||||||
},
|
},
|
||||||
|
|
||||||
removeSearchProvider: function(provider) {
|
removeSearchProvider: function(provider) {
|
||||||
this._searchSystem.unregisterProvider(provider);
|
this._searchSystem.unregisterProvider(provider);
|
||||||
this._searchResults.destroyProviderMeta(provider);
|
this._searchResults.destroyProviderDisplay(provider);
|
||||||
},
|
},
|
||||||
|
|
||||||
getActivePage: function() {
|
getActivePage: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user