[gtk+/gtk-3-4] iconview: Ensure icons are at least 1x1 pixels



commit 265e65f7a37f2d9dcd63ddf092055b32e5cec0ae
Author: Benjamin Otte <otte redhat com>
Date:   Thu Jun 14 18:44:06 2012 +0200

    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.

 gtk/gtkiconview.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index e918271..cd580f3 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -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);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]