Fixed GtkTextView & GtkIconView to consult it's true previous size request

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.
This commit is contained in:
Tristan Van Berkom 2010-09-09 16:27:22 +09:00
parent 843be48572
commit 73ea777c33
2 changed files with 27 additions and 10 deletions

View 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);

View 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.