[gtk+] label: Request more natural size for ellipsizing wrapping labels



commit 38676ef718719666363fd7389fca9b9050f7210f
Author: Benjamin Otte <otte redhat com>
Date:   Mon Apr 18 04:24:12 2011 +0200

    label: Request more natural size for ellipsizing wrapping labels

 gtk/gtklabel.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index f9abc0b..0ef1f7f 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -3487,6 +3487,7 @@ get_size_for_allocation (GtkLabel        *label,
                          gint            *minimum_size,
                          gint            *natural_size)
 {
+  GtkLabelPrivate *priv = label->priv;
   PangoLayout *layout;
   gint text_height;
 
@@ -3498,7 +3499,15 @@ get_size_for_allocation (GtkLabel        *label,
     *minimum_size = text_height;
 
   if (natural_size)
-    *natural_size = text_height;
+    {
+      if (priv->ellipsize && priv->wrap)
+        {
+          layout = gtk_label_get_measuring_layout (label, layout, allocation * PANGO_SCALE, G_MAXINT);
+          pango_layout_get_pixel_size (layout, NULL, &text_height);
+        }
+
+      *natural_size = text_height;
+    }
 
   g_object_unref (layout);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]