[libgd] two-lines-renderer: use the wrap-width if it's less than the width



commit 6318d529754dbb2a5f95d3a546340f476b37bcc4
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Nov 8 09:02:55 2012 -0500

    two-lines-renderer: use the wrap-width if it's less than the width
    
    When requesting height for width, use the wrap-width to calculate the
    layout size if it's smaller than the requested width.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=687286

 libgd/gd-two-lines-renderer.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/libgd/gd-two-lines-renderer.c b/libgd/gd-two-lines-renderer.c
index a925c45..aa8a1ab 100644
--- a/libgd/gd-two-lines-renderer.c
+++ b/libgd/gd-two-lines-renderer.c
@@ -374,15 +374,21 @@ gd_two_lines_renderer_get_preferred_height_for_width (GtkCellRenderer *cell,
 {
   GdTwoLinesRenderer *self = GD_TWO_LINES_RENDERER (cell);
   PangoLayout *layout_one, *layout_two;
-  gint text_height;
+  gint text_height, wrap_width;
   gint xpad, ypad;
 
   gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
+  g_object_get (cell, "wrap-width", &wrap_width, NULL);
   gd_two_lines_renderer_prepare_layouts (self, NULL, widget, &layout_one, &layout_two);
 
-  pango_layout_set_width (layout_one, (width - 2 * xpad) * PANGO_SCALE);
+  if (wrap_width != -1)
+    wrap_width = MIN (width - 2 * xpad, wrap_width);
+  else
+    wrap_width = width - 2 * xpad;
+
+  pango_layout_set_width (layout_one, wrap_width);
   if (layout_two != NULL)
-    pango_layout_set_width (layout_two, (width - 2 * xpad) * PANGO_SCALE);
+    pango_layout_set_width (layout_two, wrap_width);
 
   gd_two_lines_renderer_get_size (cell, widget,
                                   layout_one, layout_two,



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