From 3749b093666bf4e6f4145b5e603ad23448dd32c9 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 8 Feb 2013 19:04:24 -0500 Subject: [PATCH] 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 --- js/ui/appDisplay.js | 2 +- js/ui/search.js | 31 ++++++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 2889aba61..cc711bd40 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -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); } diff --git a/js/ui/search.js b/js/ui/search.js index b6da0e904..7cd219557 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -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); }