]> Pileus Git - ~andy/gtk/commitdiff
Fix #410815, reported by Lucas Rocha.
authorKristian Rietveld <kris@imendio.com>
Tue, 12 Jun 2007 09:19:26 +0000 (09:19 +0000)
committerKristian Rietveld <kristian@src.gnome.org>
Tue, 12 Jun 2007 09:19:26 +0000 (09:19 +0000)
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

ChangeLog
gtk/gtkiconview.c

index 52860d823d54b78392e5c18cf7fd0ced1542cfb8..9cc49b83ec7b3290240589674afb786c2f874805 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+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.
+
 2007-06-12  Behdad Esfahbod  <behdad@gnome.org>
 
        * gdk/gdkwindow.c (gdk_window_get_pointer): Improve docs.
index 7d3505f0e8f85d5ae549ff68104bf6cc7424f56c..65c2a9115352d9bf53d29e3f482c5496f8591516 100644 (file)
@@ -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);