summaryrefslogtreecommitdiff
path: root/gtk/gtklabel.c
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2018-01-17 12:36:37 +0100
committerTimm Bäder <mail@baedert.org>2018-01-17 21:57:19 +0100
commit12be5ccbb72b41edb990d7487406f19cfa731434 (patch)
treed49bc95d681dd2d40e299067adc36c9dc9cf1e75 /gtk/gtklabel.c
parent8ad1b09a3a1f1609497a5ae133ff3e5313d35495 (diff)
downloadgtk+-12be5ccbb72b41edb990d7487406f19cfa731434.tar.gz
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.
Diffstat (limited to 'gtk/gtklabel.c')
-rw-r--r--gtk/gtklabel.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 8df6e8f018..cd969492f6 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -3305,19 +3305,6 @@ gtk_label_get_measuring_layout (GtkLabel * label,
}
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)
{
GtkLabelPrivate *priv = gtk_label_get_instance_private (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);
}