From eec01b6e7312371e6a39adaa7c41d01d772be156 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 22 Oct 2007 15:47:07 +0000 Subject: [PATCH] Check width in ClutterLabel::request_coords If we get a size requisition, and we have ellipsization active, check if we are getting less space than what the layout needs and recompute the width. --- ChangeLog | 7 +++++++ clutter/clutter-label.c | 27 +++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9c4170b0a..7af804529 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-10-22 Emmanuele Bassi + + * clutter/clutter-label.c (clutter_label_request_coords): If + we get a size requisition, and we have ellipsization active, + check if we are getting less space than what the layout needs + and recompute the width. + 2007-10-22 Emmanuele Bassi * clutter/clutter-color.c (clutter_color_to_string): Change diff --git a/clutter/clutter-label.c b/clutter/clutter-label.c index d5bece809..36755e1b1 100644 --- a/clutter/clutter-label.c +++ b/clutter/clutter-label.c @@ -84,6 +84,7 @@ struct _ClutterLabelPrivate ClutterColor fgcol; ClutterLayoutFlags layout_flags; + ClutterActorBox allocation; gchar *text; gchar *font_name; @@ -275,6 +276,9 @@ clutter_label_paint (ClutterActor *self) return; } + CLUTTER_NOTE (PAINT, "painting label (text:`%s')", + priv->text); + clutter_label_ensure_layout (label, clutter_actor_get_width (self)); priv->fgcol.alpha = clutter_actor_get_opacity(self); @@ -306,8 +310,27 @@ static void clutter_label_request_coords (ClutterActor *self, ClutterActorBox *box) { - /* do we need to do anything ? */ - clutter_label_clear_layout (CLUTTER_LABEL (self)); + ClutterLabel *label = CLUTTER_LABEL (self); + ClutterLabelPrivate *priv = label->priv; + + if (priv->ellipsize) + { + if (priv->layout) + { + gint width; + PangoRectangle logical; + + width = CLUTTER_UNITS_TO_INT (box->x2 - box->x1) * PANGO_SCALE; + + pango_layout_set_width (priv->layout, -1); + pango_layout_get_extents (priv->layout, NULL, &logical); + + if (logical.width > width) + pango_layout_set_width (priv->layout, width); + } + } + else + clutter_label_clear_layout (label); } static void