-static GList *
-gtk_icon_view_layout_single_row (GtkIconView *icon_view,
- GList *first_item,
- gint item_width,
- gint row,
- gint *y,
- gint *maximum_width)
-{
- GtkAllocation allocation;
- GtkCellAreaContext *context;
- GtkIconViewPrivate *priv = icon_view->priv;
- GtkWidget *widget = GTK_WIDGET (icon_view);
- gint x, current_width;
- GList *items, *last_item;
- gint col;
- gint max_height = 0;
- gboolean rtl;
-
- rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
-
- x = 0;
- col = 0;
- items = first_item;
- current_width = 0;
-
- x += priv->margin;
- current_width += 2 * priv->margin;
-
- gtk_widget_get_allocation (widget, &allocation);
-
- context = gtk_cell_area_copy_context (priv->cell_area, priv->cell_area_context);
- g_ptr_array_add (priv->row_contexts, context);
-
- /* In the first loop we iterate horizontally until we hit allocation width
- * and collect the aligned height-for-width */
- items = first_item;
- while (items)
- {
- GtkIconViewItem *item = items->data;
- GdkRectangle *item_area = &item->cell_area;
-
- item_area->width = item_width;
-
- current_width += item_area->width + icon_view->priv->item_padding * 2;
-
- if (items != first_item)
- {
- if ((icon_view->priv->columns <= 0 && current_width > allocation.width) ||
- (icon_view->priv->columns > 0 && col >= icon_view->priv->columns))
- break;
- }
-
- /* Get this item's particular width & height (all alignments are cached by now) */
- _gtk_icon_view_set_cell_data (icon_view, item);
- gtk_cell_area_get_preferred_height_for_width (priv->cell_area,
- context,
- widget, item_width,
- NULL, NULL);
-
- current_width += icon_view->priv->column_spacing;
-
- item_area->y = *y + icon_view->priv->item_padding;
- item_area->x = x + icon_view->priv->item_padding;
-
- x = current_width - icon_view->priv->margin;
-
- if (current_width > *maximum_width)
- *maximum_width = current_width;
-
- item->row = row;
- item->col = col;
-
- col ++;
- items = items->next;
- }
-
- last_item = items;
-
- gtk_cell_area_context_get_preferred_height_for_width (context, item_width, &max_height, NULL);
- gtk_cell_area_context_allocate (context, item_width, max_height);
-
- /* In the second loop the item height has been aligned and derived and
- * we just set the height and handle rtl layout */
- for (items = first_item; items != last_item; items = items->next)
- {
- GtkIconViewItem *item = items->data;
- GdkRectangle *item_area = &item->cell_area;
-
- if (rtl)
- {
- item_area->x = *maximum_width - item_area->width - item_area->x;
- item->col = col - 1 - item->col;
- }
-
- /* All items in the same row get the same height */
- item_area->height = max_height;
- }
-
- /* Adjust the new y coordinate. */
- *y += max_height + icon_view->priv->row_spacing + icon_view->priv->item_padding * 2;
-
- return last_item;
-}
-