[libdazzle] bolding-label: handle ellipsize specially
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] bolding-label: handle ellipsize specially
- Date: Fri, 30 Jun 2017 01:56:21 +0000 (UTC)
commit c30ac46b3a7c7ef23ce05c1185461a46f420dcd0
Author: Christian Hergert <chergert redhat com>
Date: Thu Jun 29 18:55:03 2017 -0700
bolding-label: handle ellipsize specially
Without this, we would never ellipsize the text. So we will just
use the parent allocation size if we can ellipsize.
Since this is just the minimum size, we are probably fine as
toggling bold on/off when just ... is visible isn't exactly
a useful feature.
src/widgets/dzl-bolding-label.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/widgets/dzl-bolding-label.c b/src/widgets/dzl-bolding-label.c
index b7a23e8..a79f921 100644
--- a/src/widgets/dzl-bolding-label.c
+++ b/src/widgets/dzl-bolding-label.c
@@ -69,6 +69,7 @@ dzl_bolding_label_get_preferred_width (GtkWidget *widget,
PangoFontDescription *font_desc_copy;
PangoLayout *layout;
const gchar *text;
+ PangoEllipsizeMode ellipsize;
gint height;
gint width;
@@ -80,12 +81,22 @@ dzl_bolding_label_get_preferred_width (GtkWidget *widget,
else
font_desc_copy = pango_font_description_new ();
+ ellipsize = gtk_label_get_ellipsize (GTK_LABEL (widget));
+
pango_font_description_set_weight (font_desc_copy, PANGO_WEIGHT_BOLD);
pango_layout_set_font_description (layout, font_desc_copy);
+ pango_layout_set_ellipsize (layout, ellipsize);
pango_layout_get_pixel_size (layout, &width, &height);
- if (width > *min_width)
- *min_width = width;
+ if (ellipsize == PANGO_ELLIPSIZE_NONE)
+ {
+ /*
+ * Only apply min_width if we cannot ellipsize, if we can, that
+ * effects things differently.
+ */
+ if (width > *min_width)
+ *min_width = width;
+ }
if (width > *nat_width)
*nat_width = width;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]