[gtk/backports-for-4-2: 3/7] label: Fix mnemonic handling




commit 741603c838f72f6dab7cc4877b53efca396b9a92
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jun 15 13:06:10 2021 -0400

    label: Fix mnemonic handling
    
    We were not handling the case right in which we
    want to use underlines, but not use markup. Since
    we are now using pango_parse_markup for this case,
    we need to escape the xml markup.
    
    Fixes: #4041

 gtk/gtklabel.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 8037f33519..b3feb50c28 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -2970,8 +2970,18 @@ gtk_label_recalculate (GtkLabel *self)
   gtk_label_clear_layout (self);
   gtk_label_clear_select_info (self);
 
-  if (self->use_markup || self->use_underline)
-    gtk_label_set_markup_internal (self, self->label, self->use_underline);
+  if (self->use_markup)
+    {
+      gtk_label_set_markup_internal (self, self->label, self->use_underline);
+    }
+  else if (self->use_underline)
+    {
+      char *text;
+
+      text = g_markup_escape_text (self->label, -1);
+      gtk_label_set_markup_internal (self, text, TRUE);
+      g_free (text);
+    }
   else
     {
       g_clear_pointer (&self->markup_attrs, pango_attr_list_unref);


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