overview: Add API to remove search providers
As extensions are now expected to provide a "disable" function, they need to remove search providers they added. Implement the removal functionality and add a public removeSearchProvider() method. https://bugzilla.gnome.org/show_bug.cgi?id=657548
This commit is contained in:
parent
8b796e745d
commit
595be5083c
@ -237,6 +237,10 @@ Overview.prototype = {
|
|||||||
this._viewSelector.addSearchProvider(provider);
|
this._viewSelector.addSearchProvider(provider);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
removeSearchProvider: function(provider) {
|
||||||
|
this._viewSelector.removeSearchProvider(provider);
|
||||||
|
},
|
||||||
|
|
||||||
setMessage: function(text, undoCallback, undoLabel) {
|
setMessage: function(text, undoCallback, undoLabel) {
|
||||||
if (this.isDummy)
|
if (this.isDummy)
|
||||||
return;
|
return;
|
||||||
|
@ -356,6 +356,14 @@ SearchSystem.prototype = {
|
|||||||
this._providers.push(provider);
|
this._providers.push(provider);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
unregisterProvider: function (provider) {
|
||||||
|
let index = this._providers.indexOf(provider);
|
||||||
|
if (index == -1)
|
||||||
|
return;
|
||||||
|
provider.searchSystem = null;
|
||||||
|
this._providers.splice(index, 1);
|
||||||
|
},
|
||||||
|
|
||||||
getProviders: function() {
|
getProviders: function() {
|
||||||
return this._providers;
|
return this._providers;
|
||||||
},
|
},
|
||||||
|
@ -294,11 +294,23 @@ SearchResults.prototype = {
|
|||||||
}
|
}
|
||||||
resultDisplayBin.set_child(resultDisplay.actor);
|
resultDisplayBin.set_child(resultDisplay.actor);
|
||||||
|
|
||||||
this._providerMeta.push({ actor: providerBox,
|
this._providerMeta.push({ provider: provider,
|
||||||
|
actor: providerBox,
|
||||||
resultDisplay: resultDisplay });
|
resultDisplay: resultDisplay });
|
||||||
this._content.add(providerBox);
|
this._content.add(providerBox);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
destroyProviderMeta: function(provider) {
|
||||||
|
for (let i=0; i < this._providerMeta.length; i++) {
|
||||||
|
let meta = this._providerMeta[i];
|
||||||
|
if (meta.provider == provider) {
|
||||||
|
meta.actor.destroy();
|
||||||
|
this._providerMeta.splice(i, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_clearDisplay: function() {
|
_clearDisplay: function() {
|
||||||
this._selectedProvider = -1;
|
this._selectedProvider = -1;
|
||||||
this._visibleResultsCount = 0;
|
this._visibleResultsCount = 0;
|
||||||
|
@ -210,6 +210,11 @@ SearchTab.prototype = {
|
|||||||
this._searchResults.createProviderMeta(provider);
|
this._searchResults.createProviderMeta(provider);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
removeSearchProvider: function(provider) {
|
||||||
|
this._searchSystem.unregisterProvider(provider);
|
||||||
|
this._searchResults.destroyProviderMeta(provider);
|
||||||
|
},
|
||||||
|
|
||||||
startSearch: function(event) {
|
startSearch: function(event) {
|
||||||
global.stage.set_key_focus(this._text);
|
global.stage.set_key_focus(this._text);
|
||||||
this._text.event(event, false);
|
this._text.event(event, false);
|
||||||
@ -563,6 +568,10 @@ ViewSelector.prototype = {
|
|||||||
|
|
||||||
addSearchProvider: function(provider) {
|
addSearchProvider: function(provider) {
|
||||||
this._searchTab.addSearchProvider(provider);
|
this._searchTab.addSearchProvider(provider);
|
||||||
|
},
|
||||||
|
|
||||||
|
removeSearchProvider: function(provider) {
|
||||||
|
this._searchTab.removeSearchProvider(provider);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Signals.addSignalMethods(ViewSelector.prototype);
|
Signals.addSignalMethods(ViewSelector.prototype);
|
||||||
|
Loading…
Reference in New Issue
Block a user