diff options
author | Carlos Garcia Campos <carlosgc@gnome.org> | 2012-09-30 13:09:53 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2013-08-26 18:23:55 +0200 |
commit | 247ebbd17c70d2fe82b48d857549ceeeaad500ff (patch) | |
tree | 7a28d74277f739b6f0297ac2b0fb93aa3de4d53f /gtk/gtkiconview.c | |
parent | c8cad4910860fe3e9023f24a0592b84fdf847170 (diff) | |
download | gtk+-247ebbd17c70d2fe82b48d857549ceeeaad500ff.tar.gz |
iconview: Respect the fixed item width when adjusting the wrap width
Restore the code the way it was in GTK2.
https://bugzilla.gnome.org/show_bug.cgi?id=680953
Diffstat (limited to 'gtk/gtkiconview.c')
-rw-r--r-- | gtk/gtkiconview.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 070378ab7b..20e61750e6 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -1390,16 +1390,42 @@ adjust_wrap_width (GtkIconView *icon_view) { if (icon_view->priv->text_cell) { - gint wrap_width = 50; + gint pixbuf_width, wrap_width; + + if (icon_view->priv->items && icon_view->priv->pixbuf_cell) + { + gtk_cell_renderer_get_preferred_width (icon_view->priv->pixbuf_cell, + GTK_WIDGET (icon_view), + &pixbuf_width, NULL); + } + else + { + pixbuf_width = 0; + } + + if (icon_view->priv->item_width >= 0) + { + if (icon_view->priv->item_orientation == GTK_ORIENTATION_VERTICAL) + { + wrap_width = icon_view->priv->item_width; + } + else + { + wrap_width = icon_view->priv->item_width - pixbuf_width; + } + + wrap_width -= 2 * icon_view->priv->item_padding * 2; + } + else + { + wrap_width = MAX (pixbuf_width * 2, 50); + } - /* Here we go with the same old guess, try the icon size and set double - * the size of the first icon found in the list, naive but works much - * of the time */ if (icon_view->priv->items && icon_view->priv->pixbuf_cell) { - gtk_cell_renderer_get_preferred_width (icon_view->priv->pixbuf_cell, - GTK_WIDGET (icon_view), - &wrap_width, NULL); + /* Here we go with the same old guess, try the icon size and set double + * the size of the first icon found in the list, naive but works much + * of the time */ wrap_width = MAX (wrap_width * 2, 50); } |