label: Update layout width directly form allocation

For the one update_layout_width call in size_allocate, we can just use
the passed-in allocation width instead of a separate (relatively slow)
gtk_widget_get_width call.
This commit is contained in:
Timm Bäder 2018-01-17 12:36:37 +01:00
parent 8ad1b09a3a
commit 12be5ccbb7

View File

@ -3304,19 +3304,6 @@ gtk_label_get_measuring_layout (GtkLabel * label,
return copy;
}
static void
gtk_label_update_layout_width (GtkLabel *label)
{
GtkLabelPrivate *priv = gtk_label_get_instance_private (label);
g_assert (priv->layout);
if (priv->ellipsize || priv->wrap)
pango_layout_set_width (priv->layout, gtk_widget_get_width (GTK_WIDGET (label)) * PANGO_SCALE);
else
pango_layout_set_width (priv->layout, -1);
}
static void
gtk_label_update_layout_attributes (GtkLabel *label)
{
@ -3424,7 +3411,8 @@ gtk_label_ensure_layout (GtkLabel *label)
if (priv->lines > 0)
pango_layout_set_height (priv->layout, - priv->lines);
gtk_label_update_layout_width (label);
if (priv->ellipsize || priv->wrap)
pango_layout_set_width (priv->layout, gtk_widget_get_width (GTK_WIDGET (label)) * PANGO_SCALE);
}
}
@ -3736,7 +3724,13 @@ gtk_label_size_allocate (GtkWidget *widget,
GtkLabelPrivate *priv = gtk_label_get_instance_private (label);
if (priv->layout)
gtk_label_update_layout_width (label);
{
if (priv->ellipsize || priv->wrap)
pango_layout_set_width (priv->layout,
allocation->width * PANGO_SCALE);
else
pango_layout_set_width (priv->layout, -1);
}
gtk_label_get_ink_rect (label, out_clip);
}