From 8a1578ede8935be82a1b21702993d032cec84ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tyrychtr?= Date: Tue, 11 Oct 2022 13:34:21 +0200 Subject: [PATCH] GtkInspector: make the inspector at least a little bit more accessible Namely, it adds accessible name to the property value editors and to a few labels in the a11y panel. --- gtk/inspector/a11y.ui | 10 ++++++++-- gtk/inspector/prop-editor.c | 17 +++++++++++++++++ gtk/inspector/strv-editor.c | 11 +++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/gtk/inspector/a11y.ui b/gtk/inspector/a11y.ui index 6c212e9d86..8e001f6c95 100644 --- a/gtk/inspector/a11y.ui +++ b/gtk/inspector/a11y.ui @@ -12,7 +12,7 @@ 10 40 - + Role start baseline @@ -24,6 +24,9 @@ 1 end baseline + + role_label + @@ -36,7 +39,7 @@ 10 40 - + Object path start baseline @@ -48,6 +51,9 @@ 1 end baseline + + path_label + diff --git a/gtk/inspector/prop-editor.c b/gtk/inspector/prop-editor.c index cc3dc89e24..e08a194e0c 100644 --- a/gtk/inspector/prop-editor.c +++ b/gtk/inspector/prop-editor.c @@ -1249,6 +1249,23 @@ property_editor (GObject *object, notify_property (object, spec); + if (GTK_IS_LABEL (prop_edit)) + { + gtk_widget_set_can_focus (prop_edit, TRUE); + gtk_accessible_update_property (GTK_ACCESSIBLE (prop_edit), + GTK_ACCESSIBLE_PROPERTY_LABEL, + g_strdup_printf ("%s: %s", + self->name, + gtk_label_get_text (GTK_LABEL (prop_edit))), + NULL); + } + else + { + gtk_accessible_update_property (GTK_ACCESSIBLE (prop_edit), + GTK_ACCESSIBLE_PROPERTY_LABEL, self->name, + NULL); + } + return prop_edit; } diff --git a/gtk/inspector/strv-editor.c b/gtk/inspector/strv-editor.c index 26240f9d69..3230d63351 100644 --- a/gtk/inspector/strv-editor.c +++ b/gtk/inspector/strv-editor.c @@ -19,6 +19,7 @@ #include #include "strv-editor.h" +#include "gtkaccessible.h" #include "gtkbutton.h" #include "gtkentry.h" #include "gtkbox.h" @@ -69,6 +70,9 @@ add_string (GtkInspectorStrvEditor *editor, entry = gtk_entry_new (); gtk_editable_set_text (GTK_EDITABLE (entry), str); + gtk_accessible_update_property (GTK_ACCESSIBLE (entry), + GTK_ACCESSIBLE_PROPERTY_LABEL, _("Value"), + NULL); gtk_widget_show (entry); gtk_box_append (GTK_BOX (box), entry); g_object_set_data (G_OBJECT (box), "entry", entry); @@ -76,6 +80,10 @@ add_string (GtkInspectorStrvEditor *editor, button = gtk_button_new_from_icon_name ("user-trash-symbolic"); gtk_widget_add_css_class (button, "image-button"); + gtk_accessible_update_property (GTK_ACCESSIBLE (button), + GTK_ACCESSIBLE_PROPERTY_LABEL, + g_strdup_printf (_("Remove %s"), str), + NULL); gtk_widget_show (button); gtk_box_append (GTK_BOX (box), button); g_signal_connect (button, "clicked", G_CALLBACK (remove_string), editor); @@ -106,6 +114,9 @@ gtk_inspector_strv_editor_init (GtkInspectorStrvEditor *editor) gtk_widget_add_css_class (editor->button, "image-button"); gtk_widget_set_focus_on_click (editor->button, FALSE); gtk_widget_set_halign (editor->button, GTK_ALIGN_END); + gtk_accessible_update_property (GTK_ACCESSIBLE (editor->button), + GTK_ACCESSIBLE_PROPERTY_LABEL, _("Add"), + NULL); gtk_widget_show (editor->button); g_signal_connect (editor->button, "clicked", G_CALLBACK (add_cb), editor);