iconview: Add a descriptive function
authorBenjamin Otte <otte@redhat.com>
Thu, 14 Jun 2012 16:52:09 +0000 (18:52 +0200)
committerBenjamin Otte <otte@redhat.com>
Thu, 14 Jun 2012 16:52:09 +0000 (18:52 +0200)
I want to special-case empty icon views in the sizing code to avoid
various bugs, and having such a function is nice.

gtk/gtkiconview.c

index cd580f303091e8f3e9655c166b0864870163455f..848ccabc42d89fa7b16cdbcce5da1a4db3a4ecfb 100644 (file)
@@ -1456,6 +1456,12 @@ cell_area_get_preferred_size (GtkIconView        *icon_view,
     }
 }
 
+static gboolean
+gtk_icon_view_is_empty (GtkIconView *icon_view)
+{
+  return icon_view->priv->items == NULL;
+}
+
 static void
 gtk_icon_view_get_preferred_item_size (GtkIconView    *icon_view,
                                        GtkOrientation  orientation,
@@ -1467,7 +1473,7 @@ gtk_icon_view_get_preferred_item_size (GtkIconView    *icon_view,
   GtkCellAreaContext *context;
   GList *items;
 
-  if (priv->items == NULL)
+  if (gtk_icon_view_is_empty (icon_view))
     {
       *minimum = 1;
       *natural = 1;