diff options
author | Benjamin Otte <otte@redhat.com> | 2012-05-07 01:35:00 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-05-07 01:37:27 +0200 |
commit | e133c6cb71e8416c5848ad06c680e6b5a0b9b16e (patch) | |
tree | d65e47ae3df03f890825d6ec1dcd248d98039e88 /gtk/gtkiconview.c | |
parent | e187cda5e99f088080da8bc812efba2ece81f72f (diff) | |
download | gtk+-e133c6cb71e8416c5848ad06c680e6b5a0b9b16e.tar.gz |
iconview: Don't expand items to more than natural size
This ensures that items stay left-aligned instead of slowly expanding into
empty space when widening the iconview. It's also what the iconview did
pre-refactoring.
Note that for cases where natural width != minimum width, the cells
might still expand and shrink back.
Diffstat (limited to 'gtk/gtkiconview.c')
-rw-r--r-- | gtk/gtkiconview.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 7aaf158d4d..c891509f2f 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -2777,7 +2777,8 @@ gtk_icon_view_layout (GtkIconView *icon_view) GtkIconViewPrivate *priv = icon_view->priv; GtkWidget *widget = GTK_WIDGET (icon_view); GList *items; - gint item_width; + gint min_item_width, max_item_width; /* These include item_padding */ + gint item_width; /* this doesn't include item_padding */ gint n_columns, n_rows, n_items; gint col, row; GtkRequestedSize *sizes; @@ -2795,12 +2796,13 @@ gtk_icon_view_layout (GtkIconView *icon_view) &n_columns); n_rows = (n_items + n_columns - 1) / n_columns; + gtk_icon_view_get_preferred_item_size (icon_view, GTK_ORIENTATION_HORIZONTAL, -1, &min_item_width, &max_item_width); + if (n_columns <= 1) { /* We might need vertical scrolling here */ - gtk_icon_view_get_preferred_item_size (icon_view, GTK_ORIENTATION_HORIZONTAL, -1, &item_width, NULL); - item_width += 2 * priv->item_padding + 2 * priv->margin; - priv->width = MAX (item_width, gtk_widget_get_allocated_width (widget)); + int min_width = min_item_width + 2 * priv->margin; + priv->width = MAX (min_width, gtk_widget_get_allocated_width (widget)); } else { @@ -2809,6 +2811,7 @@ gtk_icon_view_layout (GtkIconView *icon_view) item_width = (priv->width - 2 * priv->margin + priv->column_spacing) / n_columns; item_width -= priv->column_spacing; + item_width = MIN (item_width, max_item_width); item_width -= 2 * priv->item_padding; gtk_cell_area_context_reset (priv->cell_area_context); |