From 039229f340ed48b6affdd189c27b5fae19872b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor-bj=C3=B6rn=20Claesson?= Date: Sat, 7 Aug 2010 19:43:41 +0200 Subject: [PATCH] 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 --- js/ui/dash.js | 67 +++++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/js/ui/dash.js b/js/ui/dash.js index 982e9c7d1..530962bba 100644 --- a/js/ui/dash.js +++ b/js/ui/dash.js @@ -416,38 +416,40 @@ SearchResults.prototype = { this._selectedProvider = -1; this._providers = this._searchSystem.getProviders(); this._providerMeta = []; - for (let i = 0; i < this._providers.length; i++) { - let provider = 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); + for (let i = 0; i < this._providers.length; i++) + this.createProviderMeta(this._providers[i]); + }, - let resultDisplayBin = new St.Bin({ style_class: 'dash-search-section-results', - x_fill: true, - y_fill: true }); - providerBox.add(resultDisplayBin, { expand: true }); - let resultDisplay = provider.createResultContainerActor(); - if (resultDisplay == null) { - resultDisplay = new OverflowSearchResults(provider); - } - resultDisplayBin.set_child(resultDisplay.actor); + createProviderMeta: function(provider) { + 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); - this._providerMeta.push({ actor: providerBox, - resultDisplay: resultDisplay, - count: count }); - this.actor.add(providerBox); + let resultDisplayBin = new St.Bin({ style_class: 'dash-search-section-results', + x_fill: true, + y_fill: true }); + 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() { @@ -864,6 +866,13 @@ Dash.prototype = { return false; }, + addSearchProvider: function(provider) { + //Add a new search provider to the dash. + + this._searchSystem.registerProvider(provider); + this.searchResults.createProviderMeta(provider); + }, + show: function() { this._searchEntry.show(); if (this._keyPressId == 0)