From 3143ab887e263617f9caf5b2edf5e44fbaa45ffe Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Thu, 23 May 2024 11:02:05 +0200 Subject: [PATCH] a11y: Use text instead of label for GtkLabel's a11y name Update the `GTK_ACCESSIBLE_PROPERTY_LABEL` property in `gtk_label_set_text_internal` using the new text instead of using the label in `gtk_label_set_label_internal`. While the `label` "includes any embedded underlines indicating mnemonics and Pango markup" [1], the `text` is the "text is as it appears on screen" [2], which is more suitable for the accessible name. With this in place, the text is reported as the accessible name again after commit d5b34aecdd10e0c6c2fb6fe8043c7121ecc480b4 Date: Wed Jan 17 12:49:38 2024 +0100 a11y: Remove special handling of accessible names for static text widgets [1] https://docs.gtk.org/gtk4/method.Label.get_label.html [2] https://docs.gtk.org/gtk4/method.Label.get_text.html Fixes: #6732 Fixes: #6735 (cherry picked from commit 317e68a58cfbfa2d5a4fa59f7219b6986d1bb8e2) --- gtk/gtklabel.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 9bdef71eb6..7f21f882be 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -3099,6 +3099,11 @@ gtk_label_set_text_internal (GtkLabel *self, g_free (self->text); self->text = str; + gtk_accessible_update_property (GTK_ACCESSIBLE (self), + GTK_ACCESSIBLE_PROPERTY_LABEL, + self->text, + -1); + gtk_label_select_region_index (self, 0, 0); } @@ -3114,11 +3119,6 @@ gtk_label_set_label_internal (GtkLabel *self, g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_LABEL]); - gtk_accessible_update_property (GTK_ACCESSIBLE (self), - GTK_ACCESSIBLE_PROPERTY_LABEL, - self->label, - -1); - return TRUE; }