iconview: Ensure icons are at least 1x1 pixels
authorBenjamin Otte <otte@redhat.com>
Thu, 14 Jun 2012 16:44:06 +0000 (18:44 +0200)
committerBenjamin Otte <otte@redhat.com>
Thu, 14 Jun 2012 16:44:44 +0000 (18:44 +0200)
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.

gtk/gtkiconview.c

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