searchDisplay, and others: Switch from provider title to provider icon

Display a '+' icon on the provider icon if there are more results that are
hidden. If the provider icon is clicked, ask the provider to launch itself and
perform a search with the current terms.

https://bugzilla.gnome.org/show_bug.cgi?id=681797
This commit is contained in:
Tanner Doshier
2012-08-09 16:52:36 -05:00
committed by Cosimo Cecchi
parent 70b5db16d3
commit 9af107feff
8 changed files with 175 additions and 16 deletions

View File

@ -315,8 +315,9 @@ const AppSearchProvider = new Lang.Class({
Extends: Search.SearchProvider,
_init: function() {
this.parent(_("APPLICATIONS"));
this.parent();
this._appSys = Shell.AppSystem.get_default();
this.id = 'applications';
},
getResultMetas: function(apps, callback) {
@ -372,10 +373,8 @@ const SettingsSearchProvider = new Lang.Class({
Extends: Search.SearchProvider,
_init: function() {
this.parent(_("SETTINGS"));
this.parent(Gio.DesktopAppInfo.new('gnome-control-center.desktop'));
this._appSys = Shell.AppSystem.get_default();
this.appInfo = Gio.DesktopAppInfo.new('gnome-control-center.desktop');
},
getResultMetas: function(prefs, callback) {

View File

@ -176,7 +176,7 @@ const RemoteSearchProvider = new Lang.Class({
this.proxy = new proxyType(Gio.DBus.session,
dbusName, dbusPath, Lang.bind(this, this._onProxyConstructed));
this.parent(appInfo.get_name().toUpperCase(), appInfo, true);
this.parent(appInfo, true);
this._cancellable = new Gio.Cancellable();
},

View File

@ -76,12 +76,14 @@ const SearchResultDisplay = new Lang.Class({
const SearchProvider = new Lang.Class({
Name: 'SearchProvider',
_init: function(title, appInfo, isRemoteProvider) {
this.title = title;
_init: function(appInfo, isRemoteProvider) {
this.appInfo = appInfo;
this.searchSystem = null;
this.isRemoteProvider = !!isRemoteProvider;
this.canLaunchSearch = false;
if (this.appInfo)
this.id = this.appInfo.get_id();
},
/**
@ -273,7 +275,7 @@ const SearchSystem = new Lang.Class({
results.push([provider, []]);
provider.getSubsearchResultSet(previousResults, terms);
} catch (error) {
log('A ' + error.name + ' has occured in ' + provider.title + ': ' + error.message);
log('A ' + error.name + ' has occured in ' + provider.id + ': ' + error.message);
}
}
} else {
@ -283,7 +285,7 @@ const SearchSystem = new Lang.Class({
results.push([provider, []]);
provider.getInitialResultSet(terms);
} catch (error) {
log('A ' + error.name + ' has occured in ' + provider.title + ': ' + error.message);
log('A ' + error.name + ' has occured in ' + provider.id + ': ' + error.message);
}
}
}

View File

@ -144,6 +144,10 @@ const GridSearchResults = new Lang.Class({
return this._grid.visibleItemsCount();
},
hasMoreResults: function() {
return this._notDisplayedResult.length > 0;
},
setResults: function(results, terms) {
// copy the lists
this._notDisplayedResult = results.slice(0);
@ -222,11 +226,22 @@ const SearchResults = new Lang.Class({
},
createProviderMeta: function(provider) {
let providerBox = new St.BoxLayout({ style_class: 'search-section',
vertical: true });
let title = new St.Label({ style_class: 'search-section-header',
text: provider.title });
providerBox.add(title, { x_fill: false, x_align: St.Align.START });
let providerBox = new St.BoxLayout({ style_class: 'search-section' });
let providerIcon = null;
if (provider.appInfo) {
providerIcon = new ProviderIcon(provider);
providerIcon.connect('clicked', Lang.bind(this,
function() {
provider.launchSearch(this._searchSystem.getTerms());
Main.overview.toggle();
}));
providerBox.add(providerIcon, { x_fill: false,
y_fill: false,
x_align: St.Align.START,
y_align: St.Align.START });
}
let resultDisplayBin = new St.Bin({ style_class: 'search-section-results',
x_fill: true,
@ -237,6 +252,7 @@ const SearchResults = new Lang.Class({
this._providerMeta.push({ provider: provider,
actor: providerBox,
icon: providerIcon,
resultDisplay: resultDisplay });
this._content.add(providerBox);
},
@ -343,6 +359,11 @@ const SearchResults = new Lang.Class({
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) {
this._clearDisplayForProvider(provider);
meta.actor.show();
@ -395,3 +416,35 @@ const SearchResults = new Lang.Class({
}
}
});
const ProviderIcon = new Lang.Class({
Name: 'ProviderIcon',
Extends: St.Button,
PROVIDER_ICON_SIZE: 48,
_init: function(provider) {
this.provider = provider;
this.parent({ style_class: 'search-provider-icon',
reactive: true,
can_focus: true,
track_hover: true });
this._content = new St.Widget({ layout_manager: new Clutter.BinLayout() });
this.set_child(this._content);
let rtl = (this.get_text_direction() == Clutter.TextDirection.RTL);
this.moreIcon = new St.Widget({ style_class: 'search-provider-icon-more',
visible: false,
x_align: rtl ? Clutter.ActorAlign.START : Clutter.ActorAlign.END,
y_align: Clutter.ActorAlign.END,
x_expand: true,
y_expand: true });
let icon = new St.Icon({ icon_size: this.PROVIDER_ICON_SIZE,
gicon: provider.appInfo.get_icon() });
this._content.add_actor(icon);
this._content.add_actor(this.moreIcon);
}
});

View File

@ -136,7 +136,8 @@ const WandaSearchProvider = new Lang.Class({
Extends: Search.SearchProvider,
_init: function() {
this.parent(_("Your favorite Easter Egg"));
this.parent();
this.id = 'wanda';
},
getResultMetas: function(fish, callback) {