[gtk+] iconview: Move wrap width adjustment to size request code
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] iconview: Move wrap width adjustment to size request code
- Date: Tue, 8 May 2012 01:58:41 +0000 (UTC)
commit e8eeb39d980fd993e17181dc45e44a84eaff109f
Author: Benjamin Otte <otte redhat com>
Date: Tue May 8 01:51:51 2012 +0200
iconview: Move wrap width adjustment to size request code
gtk/gtkiconview.c | 55 +++++++++++++++++++++++++---------------------------
1 files changed, 26 insertions(+), 29 deletions(-)
---
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index 6670098..ffc47b0 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -1361,6 +1361,30 @@ gtk_icon_view_get_n_items (GtkIconView *icon_view)
}
static void
+adjust_wrap_width (GtkIconView *icon_view)
+{
+ if (icon_view->priv->text_cell)
+ {
+ gint wrap_width = 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);
+
+ wrap_width = MAX (wrap_width * 2, 50);
+ }
+
+ g_object_set (icon_view->priv->text_cell, "wrap-width", wrap_width, NULL);
+ g_object_set (icon_view->priv->text_cell, "width", wrap_width, NULL);
+ }
+}
+
+static void
cell_area_get_preferred_size (GtkIconView *icon_view,
GtkCellAreaContext *context,
GtkOrientation orientation,
@@ -1430,6 +1454,8 @@ gtk_icon_view_get_preferred_item_size (GtkIconView *icon_view,
GtkIconViewItem *item = items->data;
_gtk_icon_view_set_cell_data (icon_view, item);
+ if (items == priv->items)
+ adjust_wrap_width (icon_view);
cell_area_get_preferred_size (icon_view, context, orientation, for_size, NULL, NULL);
}
@@ -2753,31 +2779,6 @@ gtk_icon_view_adjustment_changed (GtkAdjustment *adjustment,
}
}
-static void
-adjust_wrap_width (GtkIconView *icon_view)
-{
- if (icon_view->priv->text_cell)
- {
- gint wrap_width = 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_icon_view_set_cell_data (icon_view, icon_view->priv->items->data);
- gtk_cell_renderer_get_preferred_width (icon_view->priv->pixbuf_cell,
- GTK_WIDGET (icon_view),
- &wrap_width, NULL);
-
- wrap_width = MAX (wrap_width * 2, 50);
- }
-
- g_object_set (icon_view->priv->text_cell, "wrap-width", wrap_width, NULL);
- g_object_set (icon_view->priv->text_cell, "width", wrap_width, NULL);
- }
-}
-
static gint
compare_sizes (gconstpointer p1,
gconstpointer p2,
@@ -2801,10 +2802,6 @@ gtk_icon_view_layout (GtkIconView *icon_view)
n_items = gtk_icon_view_get_n_items (icon_view);
- /* Update the wrap width for the text cell before going and requesting sizes */
- if (n_items)
- adjust_wrap_width (icon_view);
-
gtk_icon_view_compute_n_items_for_size (icon_view,
GTK_ORIENTATION_HORIZONTAL,
gtk_widget_get_allocated_width (widget),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]