Make it possible to register new search providers for the dash after it has been created.

Factors out meta creation from SearchResults._init to SearchResults.createProviderMeta(provider).

Adds Dash.addSearchProvider(provider).

https://bugzilla.gnome.org/show_bug.cgi?id=625954
This commit is contained in:
Tor-björn Claesson 2010-08-07 19:43:41 +02:00 committed by Owen W. Taylor
parent d9169d27f5
commit 039229f340

View File

@ -416,38 +416,40 @@ SearchResults.prototype = {
this._selectedProvider = -1; this._selectedProvider = -1;
this._providers = this._searchSystem.getProviders(); this._providers = this._searchSystem.getProviders();
this._providerMeta = []; this._providerMeta = [];
for (let i = 0; i < this._providers.length; i++) { for (let i = 0; i < this._providers.length; i++)
let provider = this._providers[i]; this.createProviderMeta(this._providers[i]);
let providerBox = new St.BoxLayout({ style_class: 'dash-search-section', },
vertical: true });
let titleButton = new St.Button({ style_class: 'dash-search-section-header',
reactive: true,
x_fill: true,
y_fill: true });
titleButton.connect('clicked', Lang.bind(this, function () { this._onHeaderClicked(provider); }));
providerBox.add(titleButton);
let titleBox = new St.BoxLayout();
titleButton.set_child(titleBox);
let title = new St.Label({ text: provider.title });
let count = new St.Label();
titleBox.add(title, { expand: true });
titleBox.add(count);
let resultDisplayBin = new St.Bin({ style_class: 'dash-search-section-results', createProviderMeta: function(provider) {
x_fill: true, let providerBox = new St.BoxLayout({ style_class: 'dash-search-section',
y_fill: true }); vertical: true });
providerBox.add(resultDisplayBin, { expand: true }); let titleButton = new St.Button({ style_class: 'dash-search-section-header',
let resultDisplay = provider.createResultContainerActor(); reactive: true,
if (resultDisplay == null) { x_fill: true,
resultDisplay = new OverflowSearchResults(provider); y_fill: true });
} titleButton.connect('clicked', Lang.bind(this, function () { this._onHeaderClicked(provider); }));
resultDisplayBin.set_child(resultDisplay.actor); providerBox.add(titleButton);
let titleBox = new St.BoxLayout();
titleButton.set_child(titleBox);
let title = new St.Label({ text: provider.title });
let count = new St.Label();
titleBox.add(title, { expand: true });
titleBox.add(count);
this._providerMeta.push({ actor: providerBox, let resultDisplayBin = new St.Bin({ style_class: 'dash-search-section-results',
resultDisplay: resultDisplay, x_fill: true,
count: count }); y_fill: true });
this.actor.add(providerBox); providerBox.add(resultDisplayBin, { expand: true });
let resultDisplay = provider.createResultContainerActor();
if (resultDisplay == null) {
resultDisplay = new OverflowSearchResults(provider);
} }
resultDisplayBin.set_child(resultDisplay.actor);
this._providerMeta.push({ actor: providerBox,
resultDisplay: resultDisplay,
count: count });
this.actor.add(providerBox);
}, },
_clearDisplay: function() { _clearDisplay: function() {
@ -864,6 +866,13 @@ Dash.prototype = {
return false; return false;
}, },
addSearchProvider: function(provider) {
//Add a new search provider to the dash.
this._searchSystem.registerProvider(provider);
this.searchResults.createProviderMeta(provider);
},
show: function() { show: function() {
this._searchEntry.show(); this._searchEntry.show();
if (this._keyPressId == 0) if (this._keyPressId == 0)