iconview: Ensure icons are at least 1x1 pixels

This is useful for 2 reasons:
(1) Items actually exist and are clickable
(2) Size computations don't divide by 0

I've not seen problems with this in the wild (mostly because
item-padding defaults to non-0), but noticed this while fixing other
bugs.
This commit is contained in:
Benjamin Otte 2012-06-14 18:44:06 +02:00
parent 62292dc247
commit fd4c330500

View File

@ -1469,8 +1469,8 @@ gtk_icon_view_get_preferred_item_size (GtkIconView *icon_view,
if (priv->items == NULL) if (priv->items == NULL)
{ {
*minimum = 0; *minimum = 1;
*natural = 0; *natural = 1;
return; return;
} }
@ -1530,9 +1530,9 @@ gtk_icon_view_get_preferred_item_size (GtkIconView *icon_view,
} }
if (minimum) if (minimum)
*minimum += 2 * priv->item_padding; *minimum = MAX (1, *minimum + 2 * priv->item_padding);
if (natural) if (natural)
*natural += 2 * priv->item_padding; *natural = MAX (1, *natural + 2 * priv->item_padding);
g_object_unref (context); g_object_unref (context);
} }