iconGrid: Handle preferred height requests for infinite widths

Request enough height to fit all children in a single line instead of
requesting 0.

https://bugzilla.gnome.org/show_bug.cgi?id=679168
This commit is contained in:
Rui Matos 2012-07-01 18:38:28 +02:00 committed by Jasper St. Pierre
parent 1d7c2b1c26
commit c985fdccba

View File

@ -198,7 +198,11 @@ const IconGrid = new Lang.Class({
_getPreferredHeight: function (grid, forWidth, alloc) { _getPreferredHeight: function (grid, forWidth, alloc) {
let children = this._getVisibleChildren(); let children = this._getVisibleChildren();
let [nColumns, usedWidth] = this._computeLayout(forWidth); let nColumns;
if (forWidth < 0)
nColumns = children.length;
else
nColumns = this._computeLayout(forWidth)[0];
let nRows; let nRows;
if (nColumns > 0) if (nColumns > 0)
nRows = Math.ceil(children.length / nColumns); nRows = Math.ceil(children.length / nColumns);