search: Propagate searchResults down the hierarchy
In order to prepare for applying the bold style to the part of the description that matches the search terms, we need to listen for the signal that announces the fact that the search terms have changed. Given the fact that the SearchResults class is aware of the changes regarding the search terms, the classes that extent SearchResult need to have a reference to it in order to listen for the to-be-implemented 'terms-changed' signal. https://bugzilla.gnome.org/show_bug.cgi?id=749957
This commit is contained in:
parent
bcec9f35d5
commit
77e0c38d82
@ -47,9 +47,10 @@ const MaxWidthBin = new Lang.Class({
|
||||
const SearchResult = new Lang.Class({
|
||||
Name: 'SearchResult',
|
||||
|
||||
_init: function(provider, metaInfo) {
|
||||
_init: function(provider, metaInfo, resultsView) {
|
||||
this.provider = provider;
|
||||
this.metaInfo = metaInfo;
|
||||
this._resultsView = resultsView;
|
||||
|
||||
this.actor = new St.Button({ reactive: true,
|
||||
can_focus: true,
|
||||
@ -73,8 +74,8 @@ const ListSearchResult = new Lang.Class({
|
||||
|
||||
ICON_SIZE: 24,
|
||||
|
||||
_init: function(provider, metaInfo) {
|
||||
this.parent(provider, metaInfo);
|
||||
_init: function(provider, metaInfo, resultsView) {
|
||||
this.parent(provider, metaInfo, resultsView);
|
||||
|
||||
this.actor.style_class = 'list-search-result';
|
||||
this.actor.x_fill = true;
|
||||
@ -120,8 +121,8 @@ const GridSearchResult = new Lang.Class({
|
||||
Name: 'GridSearchResult',
|
||||
Extends: SearchResult,
|
||||
|
||||
_init: function(provider, metaInfo) {
|
||||
this.parent(provider, metaInfo);
|
||||
_init: function(provider, metaInfo, resultsView) {
|
||||
this.parent(provider, metaInfo, resultsView);
|
||||
|
||||
this.actor.style_class = 'grid-search-result';
|
||||
|
||||
@ -136,8 +137,9 @@ const GridSearchResult = new Lang.Class({
|
||||
const SearchResultsBase = new Lang.Class({
|
||||
Name: 'SearchResultsBase',
|
||||
|
||||
_init: function(provider) {
|
||||
_init: function(provider, resultsView) {
|
||||
this.provider = provider;
|
||||
this._resultsView = resultsView;
|
||||
|
||||
this._terms = [];
|
||||
|
||||
@ -165,7 +167,7 @@ const SearchResultsBase = new Lang.Class({
|
||||
|
||||
_createResultDisplay: function(meta) {
|
||||
if (this.provider.createResultObject)
|
||||
return this.provider.createResultObject(meta);
|
||||
return this.provider.createResultObject(meta, this._resultsView);
|
||||
|
||||
return null;
|
||||
},
|
||||
@ -269,8 +271,8 @@ const ListSearchResults = new Lang.Class({
|
||||
Name: 'ListSearchResults',
|
||||
Extends: SearchResultsBase,
|
||||
|
||||
_init: function(provider) {
|
||||
this.parent(provider);
|
||||
_init: function(provider, resultsView) {
|
||||
this.parent(provider, resultsView);
|
||||
|
||||
this._container = new St.BoxLayout({ style_class: 'search-section-content' });
|
||||
this.providerInfo = new ProviderInfo(provider);
|
||||
@ -307,7 +309,8 @@ const ListSearchResults = new Lang.Class({
|
||||
},
|
||||
|
||||
_createResultDisplay: function(meta) {
|
||||
return this.parent(meta) || new ListSearchResult(this.provider, meta);
|
||||
return this.parent(meta, this._resultsView) ||
|
||||
new ListSearchResult(this.provider, meta, this._resultsView);
|
||||
},
|
||||
|
||||
_addItem: function(display) {
|
||||
@ -327,14 +330,14 @@ const GridSearchResults = new Lang.Class({
|
||||
Name: 'GridSearchResults',
|
||||
Extends: SearchResultsBase,
|
||||
|
||||
_init: function(provider, parentContainer) {
|
||||
this.parent(provider);
|
||||
_init: function(provider, resultsView) {
|
||||
this.parent(provider, resultsView);
|
||||
// We need to use the parent container to know how much results we can show.
|
||||
// None of the actors in this class can be used for that, since the main actor
|
||||
// goes hidden when no results are displayed, and then it lost its allocation.
|
||||
// Then on the next use of _getMaxDisplayedResults allocation is 0, en therefore
|
||||
// it doesn't show any result although we have some.
|
||||
this._parentContainer = parentContainer;
|
||||
this._parentContainer = resultsView.actor;
|
||||
|
||||
this._grid = new IconGrid.IconGrid({ rowLimit: MAX_GRID_SEARCH_RESULTS_ROWS,
|
||||
xAlign: St.Align.START });
|
||||
@ -355,7 +358,8 @@ const GridSearchResults = new Lang.Class({
|
||||
},
|
||||
|
||||
_createResultDisplay: function(meta) {
|
||||
return this.parent(meta) || new GridSearchResult(this.provider, meta);
|
||||
return this.parent(meta, this._resultsView) ||
|
||||
new GridSearchResult(this.provider, meta, this._resultsView);
|
||||
},
|
||||
|
||||
_addItem: function(display) {
|
||||
@ -557,9 +561,9 @@ const SearchResults = new Lang.Class({
|
||||
|
||||
let providerDisplay;
|
||||
if (provider.appInfo)
|
||||
providerDisplay = new ListSearchResults(provider);
|
||||
providerDisplay = new ListSearchResults(provider, this);
|
||||
else
|
||||
providerDisplay = new GridSearchResults(provider, this.actor);
|
||||
providerDisplay = new GridSearchResults(provider, this);
|
||||
|
||||
providerDisplay.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
|
||||
providerDisplay.actor.hide();
|
||||
|
Loading…
Reference in New Issue
Block a user