diff options
author | Benjamin Otte <otte@redhat.com> | 2011-03-29 13:33:47 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2011-03-29 15:33:27 +0200 |
commit | 21f117c695800a8f5a16a477c40a435fcd7d224a (patch) | |
tree | b8c190a15fd0aadc86f32e1fbdfa534f3cfa6824 /gtk/gtklabel.c | |
parent | 9992efdb0e7d0cf52e47817fe049b97967400731 (diff) | |
download | gtk+-21f117c695800a8f5a16a477c40a435fcd7d224a.tar.gz |
label: Add another special case for measuring
Diffstat (limited to 'gtk/gtklabel.c')
-rw-r--r-- | gtk/gtklabel.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index ebf443159c..759459eb96 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -3066,6 +3066,17 @@ gtk_label_get_measuring_layout (GtkLabel * label, return priv->layout; } + /* We can use the label's own layout if we're not allocated a size yet, + * because we don't need it to be properly setup at that point. + * This way we can make use of caching upon the label's creation. + */ + if (gtk_widget_get_allocated_width (GTK_WIDGET (label)) <= 1) + { + g_object_ref (priv->layout); + pango_layout_set_width (priv->layout, width); + return priv->layout; + } + /* oftentimes we want to measure a width that is far wider than the current width, * even though the layout is not wrapped. In that case, we can just return the * current layout, because for measuring purposes, it will be identical. |