summaryrefslogtreecommitdiff
path: root/gtk/gtkiconview.c
diff options
context:
space:
mode:
authorKristian Rietveld <kris@imendio.com>2007-06-12 09:19:26 +0000
committerKristian Rietveld <kristian@src.gnome.org>2007-06-12 09:19:26 +0000
commit8d5fd5168b89b384ef48f6ffe4f35ec4102d8041 (patch)
tree3f1bf78b9e66811a2225128eaa76796275bdf524 /gtk/gtkiconview.c
parentd6061b54e29db4a230d2ddaf827b52ede25e1d23 (diff)
downloadgtk+-8d5fd5168b89b384ef48f6ffe4f35ec4102d8041.tar.gz
Fix #410815, reported by Lucas Rocha.
2007-06-12 Kristian Rietveld <kris@imendio.com> Fix #410815, reported by Lucas Rocha. * gtk/gtkiconview.c (gtk_icon_view_layout): determine a suitable wrap-width with the first icon, if it exists, (adjust_wrap_width): try to use icon_view->priv->item_width if available, (gtk_icon_view_set_cell_data): don't call adjust_wrap_width here, which caused changes in wrap-width during the layouting process and resulted in layouting artefacts, (update_text_cell): don't set the wrap-width property, this should be handled by adjust_wrap_width. svn path=/trunk/; revision=18111
Diffstat (limited to 'gtk/gtkiconview.c')
-rw-r--r--gtk/gtkiconview.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index 7d3505f0e8..65c2a91153 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -447,6 +447,8 @@ static void remove_scroll_timeout (GtkIconView *icon_view);
static void clear_dest_info (GtkIconView *icon_view);
static void clear_source_info (GtkIconView *icon_view);
+static void adjust_wrap_width (GtkIconView *icon_view,
+ GtkIconViewItem *item);
static guint icon_view_signals[LAST_SIGNAL] = { 0 };
@@ -2588,9 +2590,16 @@ gtk_icon_view_layout (GtkIconView *icon_view)
}
}
+
icons = icon_view->priv->items;
y += icon_view->priv->margin;
row = 0;
+
+ if (icons)
+ {
+ gtk_icon_view_set_cell_data (icon_view, icons->data);
+ adjust_wrap_width (icon_view, icons->data);
+ }
do
{
@@ -2687,6 +2696,8 @@ adjust_wrap_width (GtkIconView *icon_view,
if (icon_view->priv->text_cell != -1 &&
icon_view->priv->pixbuf_cell != -1)
{
+ gint item_width;
+
text_info = g_list_nth_data (icon_view->priv->cell_list,
icon_view->priv->text_cell);
pixbuf_info = g_list_nth_data (icon_view->priv->cell_list,
@@ -2698,12 +2709,23 @@ adjust_wrap_width (GtkIconView *icon_view,
&pixbuf_width,
NULL);
+
+ if (icon_view->priv->item_width > 0)
+ item_width = icon_view->priv->item_width;
+ else
+ item_width = item->width;
+
if (item->width == -1)
- wrap_width = MAX (2 * pixbuf_width, 50);
+ {
+ if (item_width > 0)
+ wrap_width = item_width - pixbuf_width - icon_view->priv->spacing;
+ else
+ wrap_width = MAX (2 * pixbuf_width, 50);
+ }
else if (icon_view->priv->orientation == GTK_ORIENTATION_VERTICAL)
- wrap_width = item->width;
+ wrap_width = item_width;
else
- wrap_width = item->width - pixbuf_width - icon_view->priv->spacing;
+ wrap_width = item_width - pixbuf_width - icon_view->priv->spacing;
g_object_set (text_info->cell, "wrap-width", wrap_width, NULL);
g_object_set (text_info->cell, "width", wrap_width, NULL);
@@ -4234,8 +4256,6 @@ gtk_icon_view_set_cell_data (GtkIconView *icon_view,
g_object_thaw_notify (G_OBJECT (info->cell));
}
-
- adjust_wrap_width (icon_view, item);
}
static void
@@ -4893,7 +4913,6 @@ update_text_cell (GtkIconView *icon_view)
g_object_set (info->cell,
"alignment", PANGO_ALIGN_CENTER,
"wrap-mode", PANGO_WRAP_WORD,
- "wrap-width", icon_view->priv->item_width,
"xalign", 0.0,
"yalign", 0.0,
NULL);
@@ -4901,7 +4920,6 @@ update_text_cell (GtkIconView *icon_view)
g_object_set (info->cell,
"alignment", PANGO_ALIGN_LEFT,
"wrap-mode", PANGO_WRAP_WORD,
- "wrap-width", icon_view->priv->item_width,
"xalign", 0.0,
"yalign", 0.0,
NULL);