[gnome-shell] Search: Don't use IconGrid width for maxDisplayedResults
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Search: Don't use IconGrid width for maxDisplayedResults
- Date: Sat, 19 Jul 2014 16:13:01 +0000 (UTC)
commit 9970671bb1041d1a20f0c5122bb1184255179e29
Author: Carlos Soriano <carlos soriano89 gmail com>
Date: Tue Jul 15 17:09:41 2014 +0200
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
js/ui/search.js | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/search.js b/js/ui/search.js
index 9a58e79..dc2729a 100644
--- a/js/ui/search.js
+++ b/js/ui/search.js
@@ -465,8 +465,14 @@ const GridSearchResults = new Lang.Class({
Name: 'GridSearchResults',
Extends: SearchResultsBase,
- _init: function(provider) {
+ _init: function(provider, parentContainer) {
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,
xAlign: St.Align.START });
@@ -477,7 +483,9 @@ const GridSearchResults = new Lang.Class({
},
_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) {
@@ -577,7 +585,7 @@ const SearchResults = new Lang.Class({
if (provider.appInfo)
providerDisplay = new ListSearchResults(provider);
else
- providerDisplay = new GridSearchResults(provider);
+ providerDisplay = new GridSearchResults(provider, this._content);
providerDisplay.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
this._content.add(providerDisplay.actor);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]