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 d5b34aecdd
    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
This commit is contained in:
Michael Weghorn 2024-05-23 11:02:05 +02:00 committed by Matthias Clasen
parent d2298f1c8f
commit 3b5f0ed05e

View File

@ -3101,6 +3101,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);
}
@ -3116,11 +3121,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;
}