[gtk+] label: Update layout width directly form allocation
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] label: Update layout width directly form allocation
- Date: Wed, 17 Jan 2018 20:54:31 +0000 (UTC)
commit 12be5ccbb72b41edb990d7487406f19cfa731434
Author: Timm Bäder <mail baedert org>
Date: Wed Jan 17 12:36:37 2018 +0100
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.
gtk/gtklabel.c | 24 +++++++++---------------
1 files changed, 9 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 8df6e8f..cd96949 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]