]> Pileus Git - ~andy/gtk/commitdiff
Fixed GtkTextView & GtkIconView to consult it's true previous size request
authorTristan Van Berkom <tristan.van.berkom@gmail.com>
Thu, 9 Sep 2010 07:27:22 +0000 (16:27 +0900)
committerTristan Van Berkom <tristan.van.berkom@gmail.com>
Thu, 9 Sep 2010 08:19:18 +0000 (17:19 +0900)
Fixed issues in my previous patch for bug 626939 removing GtkRequisition
cache: these widgets monitor the previous requested size and decide whether
to queue a resize when the content changes based on it's prior request.

gtk/gtkiconview.c
gtk/gtktextview.c

index 84ce3f85e5e38b885cc24d8c32b0846b98a2e5d3..2dc10434eea7f3900bdda707f040771dd4f385df 100644 (file)
@@ -2821,12 +2821,12 @@ static void
 gtk_icon_view_layout (GtkIconView *icon_view)
 {
   GtkAllocation allocation;
-  GtkRequisition requisition;
   GtkWidget *widget;
   GList *icons;
   gint y = 0, maximum_width = 0;
   gint row;
   gint item_width;
+  gboolean size_changed = FALSE;
 
   if (icon_view->priv->layout_idle_id != 0)
     {
@@ -2872,22 +2872,25 @@ gtk_icon_view_layout (GtkIconView *icon_view)
   while (icons != NULL);
 
   if (maximum_width != icon_view->priv->width)
-    icon_view->priv->width = maximum_width;
+    {
+      icon_view->priv->width = maximum_width;
+      size_changed = TRUE;
+    }
 
   y += icon_view->priv->margin;
   
   if (y != icon_view->priv->height)
-    icon_view->priv->height = y;
+    {
+      icon_view->priv->height = y;
+      size_changed = TRUE;
+    }
 
   gtk_icon_view_set_adjustment_upper (icon_view->priv->hadjustment, 
                                      icon_view->priv->width);
   gtk_icon_view_set_adjustment_upper (icon_view->priv->vadjustment, 
                                      icon_view->priv->height);
 
-  gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &requisition, NULL);
-
-  if (icon_view->priv->width != requisition.width ||
-      icon_view->priv->height != requisition.height)
+  if (size_changed)
     gtk_widget_queue_resize_no_redraw (widget);
 
   gtk_widget_get_allocation (widget, &allocation);
index db1073a2f10b3ac93f886e7c867c387e63b5a962..e49fb01e71ee29c919ad7772bbb32f20bd14754a 100644 (file)
@@ -134,6 +134,18 @@ struct _GtkTextViewPrivate
   gint width;           /* Width and height of the buffer */
   gint height;
 
+  /* This is used to monitor the overall size request 
+   * and decide whether we need to queue resizes when
+   * the buffer content changes. 
+   *
+   * FIXME: This could be done in a simpler way by 
+   * consulting the above width/height of the buffer + some
+   * padding values, however all of this request code needs
+   * to be changed to use GtkSizeRequestIface and deserves
+   * more attention.
+   */
+  GtkRequisition cached_size_request;
+
   /* The virtual cursor position is normally the same as the
    * actual (strong) cursor position, except in two circumstances:
    *
@@ -3319,6 +3331,10 @@ gtk_text_view_size_request (GtkWidget      *widget,
 
       tmp_list = g_slist_next (tmp_list);
     }
+
+  /* Cache the requested size of the text view so we can 
+   * compare it in the changed_handler() */
+  priv->cached_size_request = *requisition;
 }
 
 static void
@@ -3935,11 +3951,9 @@ changed_handler (GtkTextLayout     *layout,
     }
 
   {
-    GtkRequisition old_req;
+    GtkRequisition old_req = priv->cached_size_request;
     GtkRequisition new_req;
 
-    gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &old_req, NULL);
-
     /* Use this instead of gtk_widget_size_request wrapper
      * to avoid the optimization which just returns widget->requisition
      * if a resize hasn't been queued.