searchDisplay: Make the search result actors stateless, by removing terms

We want to cache result actors between searches, so we shouldn't
instantiate them with search-specific info.

https://bugzilla.gnome.org/show_bug.cgi?id=704912
This commit is contained in:
Jasper St. Pierre 2013-02-08 19:04:24 -05:00
parent 27cac10d0c
commit 3749b09366
2 changed files with 19 additions and 14 deletions

View File

@ -914,7 +914,7 @@ const AppSearchProvider = new Lang.Class({
app.open_new_window(workspace);
},
createResultObject: function (resultMeta, terms) {
createResultObject: function (resultMeta) {
let app = this._appSys.lookup_app(resultMeta['id']);
return new AppIcon(app);
}

View File

@ -167,10 +167,9 @@ const MaxWidthBin = new Lang.Class({
const SearchResult = new Lang.Class({
Name: 'SearchResult',
_init: function(provider, metaInfo, terms) {
_init: function(provider, metaInfo) {
this.provider = provider;
this.metaInfo = metaInfo;
this.terms = terms;
this.actor = new St.Button({ reactive: true,
can_focus: true,
@ -179,12 +178,11 @@ const SearchResult = new Lang.Class({
y_fill: true });
this.actor._delegate = this;
this.actor.connect('clicked', Lang.bind(this, this.activate));
this.actor.connect('clicked', Lang.bind(this, this._activate));
},
activate: function() {
this.provider.activateResult(this.metaInfo.id, this.terms);
Main.overview.toggle();
_activate: function() {
this.emit('activate', this.metaInfo.id);
},
setSelected: function(selected) {
@ -194,6 +192,7 @@ const SearchResult = new Lang.Class({
this.actor.remove_style_pseudo_class('selected');
}
});
Signals.addSignalMethods(SearchResult.prototype);
const ListSearchResult = new Lang.Class({
Name: 'ListSearchResult',
@ -201,8 +200,8 @@ const ListSearchResult = new Lang.Class({
ICON_SIZE: 64,
_init: function(provider, metaInfo, terms) {
this.parent(provider, metaInfo, terms);
_init: function(provider, metaInfo) {
this.parent(provider, metaInfo);
this.actor.style_class = 'list-search-result';
this.actor.x_fill = true;
@ -246,12 +245,12 @@ const GridSearchResult = new Lang.Class({
Name: 'GridSearchResult',
Extends: SearchResult,
_init: function(provider, metaInfo, terms) {
this.parent(provider, metaInfo, terms);
_init: function(provider, metaInfo) {
this.parent(provider, metaInfo);
this.actor.style_class = 'grid-search-result';
let content = provider.createResultObject(metaInfo, terms);
let content = provider.createResultObject(metaInfo);
let dragSource = null;
if (content == null) {
@ -343,6 +342,10 @@ const SearchResultsBase = new Lang.Class({
this.emit('key-focus-in', actor);
},
_activateResult: function(result, id) {
return this.provider.activateResult(id, this._terms);
},
_setMoreIconVisible: function(visible) {
},
@ -413,7 +416,8 @@ const ListSearchResults = new Lang.Class({
_renderResults: function(metas) {
for (let i = 0; i < metas.length; i++) {
let display = new ListSearchResult(this.provider, metas[i], this._terms);
let display = new ListSearchResult(this.provider, metas[i]);
display.connect('activate', Lang.bind(this, this._activateResult));
display.actor.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
this._content.add_actor(display.actor);
}
@ -453,7 +457,8 @@ const GridSearchResults = new Lang.Class({
_renderResults: function(metas) {
for (let i = 0; i < metas.length; i++) {
let display = new GridSearchResult(this.provider, metas[i], this._terms);
let display = new GridSearchResult(this.provider, metas[i]);
display.connect('activate', Lang.bind(this, this._activateResult));
display.actor.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
this._grid.addItem(display);
}