[gtk/wrap-label-fixup] label: Only produce multiple lines when wrapping
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wrap-label-fixup] label: Only produce multiple lines when wrapping
- Date: Sat, 9 Apr 2022 21:33:22 +0000 (UTC)
commit fbbd90e7f6aea8efd75dc3613e3830ec7407e68d
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Apr 9 17:31:58 2022 -0400
label: Only produce multiple lines when wrapping
We have a wrap property, and we should respect it.
This changes things so that the lines property is
ignored unless the label is both ellipsized and
wrapping.
Fixes: #4714
gtk/gtklabel.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 7560e551fe..882d3386f9 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -2547,7 +2547,7 @@ gtk_label_class_init (GtkLabelClass *class)
* The number of lines to which an ellipsized, wrapping label
* should be limited.
*
- * This property has no effect if the label is not wrapping or ellipsized.
+ * This property has no effect if the label is not wrapping and ellipsized.
* Set this property to -1 if you don't want to limit the number of lines.
*/
label_props[PROP_LINES] =
@@ -4168,8 +4168,10 @@ gtk_label_ensure_layout (GtkLabel *self)
pango_layout_set_ellipsize (self->layout, self->ellipsize);
pango_layout_set_wrap (self->layout, self->wrap_mode);
pango_layout_set_single_paragraph_mode (self->layout, self->single_line_mode);
- if (self->lines > 0)
+ if (self->wrap && self->lines > 0)
pango_layout_set_height (self->layout, - self->lines);
+ else
+ pango_layout_set_height (self->layout, -1);
if (self->ellipsize || self->wrap)
pango_layout_set_width (self->layout, gtk_widget_get_width (GTK_WIDGET (self)) * PANGO_SCALE);
@@ -5777,7 +5779,7 @@ _gtk_label_get_selection_bound (GtkLabel *self)
* Sets the number of lines to which an ellipsized, wrapping label
* should be limited.
*
- * This has no effect if the label is not wrapping or ellipsized.
+ * This has no effect if the label is not wrapping and ellipsized.
* Set this to -1 if you don’t want to limit the number of lines.
*/
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]