Search: Don't use IconGrid width for maxDisplayedResults
Currently to know how many results we could show for GridResults we use the width of the bin containing those results. Since it's expanding it shouldn't be a problem. But it becomes a problem when no results are displayed, thus the container becomes hidden and it losts its allocation. In the next introduction of terms in search we call again maxDisplayedResults but it doesn't have allocation yet, and therefore no results are displayed (currently a bug on IconGrid makes the min size = one icon, so actually we show one and only one icon in this case). To solve that use the parent container which contains the search results of all providers or the text label with not displayed results, so it always have the real available width to calculate maxDisplayedResults. Thanks Alban Browaeys for the debugging footwork. https://bugzilla.gnome.org/show_bug.cgi?id=732416
This commit is contained in:
parent
bb4502dca8
commit
9970671bb1
@ -465,8 +465,14 @@ const GridSearchResults = new Lang.Class({
|
|||||||
Name: 'GridSearchResults',
|
Name: 'GridSearchResults',
|
||||||
Extends: SearchResultsBase,
|
Extends: SearchResultsBase,
|
||||||
|
|
||||||
_init: function(provider) {
|
_init: function(provider, parentContainer) {
|
||||||
this.parent(provider);
|
this.parent(provider);
|
||||||
|
// 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._grid = new IconGrid.IconGrid({ rowLimit: MAX_GRID_SEARCH_RESULTS_ROWS,
|
this._grid = new IconGrid.IconGrid({ rowLimit: MAX_GRID_SEARCH_RESULTS_ROWS,
|
||||||
xAlign: St.Align.START });
|
xAlign: St.Align.START });
|
||||||
@ -477,7 +483,9 @@ const GridSearchResults = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_getMaxDisplayedResults: function() {
|
_getMaxDisplayedResults: function() {
|
||||||
return this._grid.columnsForWidth(this._bin.width) * this._grid.getRowLimit();
|
let parentThemeNode = this._parentContainer.get_theme_node();
|
||||||
|
let availableWidth = parentThemeNode.adjust_for_width(this._parentContainer.width);
|
||||||
|
return this._grid.columnsForWidth(availableWidth) * this._grid.getRowLimit();
|
||||||
},
|
},
|
||||||
|
|
||||||
_renderResults: function(metas) {
|
_renderResults: function(metas) {
|
||||||
@ -577,7 +585,7 @@ const SearchResults = new Lang.Class({
|
|||||||
if (provider.appInfo)
|
if (provider.appInfo)
|
||||||
providerDisplay = new ListSearchResults(provider);
|
providerDisplay = new ListSearchResults(provider);
|
||||||
else
|
else
|
||||||
providerDisplay = new GridSearchResults(provider);
|
providerDisplay = new GridSearchResults(provider, this._content);
|
||||||
|
|
||||||
providerDisplay.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
|
providerDisplay.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
|
||||||
this._content.add(providerDisplay.actor);
|
this._content.add(providerDisplay.actor);
|
||||||
|
Loading…
Reference in New Issue
Block a user