From fcb90480439fe90c3073905f0ee124a6cb6f58f9 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 9 Jun 2023 21:03:54 -0400 Subject: [PATCH] inspector: Show computed values in a11y tab Show the name and description in the a11y tab. These are not direct property values, but computed according to ARIA rules. --- gtk/inspector/a11y.c | 30 +++++++++++++++++++++ gtk/inspector/a11y.ui | 62 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 87 insertions(+), 5 deletions(-) diff --git a/gtk/inspector/a11y.c b/gtk/inspector/a11y.c index 4252f09011..e06e767bea 100644 --- a/gtk/inspector/a11y.c +++ b/gtk/inspector/a11y.c @@ -201,6 +201,8 @@ struct _GtkInspectorA11y GtkWidget *box; GtkWidget *role; + GtkWidget *name; + GtkWidget *description; GtkWidget *bounds; GtkWidget *path_label; GtkWidget *path; @@ -229,6 +231,30 @@ update_role (GtkInspectorA11y *sl) g_type_class_unref (eclass); } +static void +update_name (GtkInspectorA11y *sl) +{ + GtkATContext *context; + char *name; + + context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (sl->object)); + + name = gtk_at_context_get_name (context); + gtk_label_set_label (GTK_LABEL (sl->name), name); +} + +static void +update_description (GtkInspectorA11y *sl) +{ + GtkATContext *context; + char *description; + + context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (sl->object)); + + description = gtk_at_context_get_description (context); + gtk_label_set_label (GTK_LABEL (sl->description), description); +} + static void update_path (GtkInspectorA11y *sl) { @@ -426,6 +452,8 @@ static void refresh_all (GtkInspectorA11y *sl) { update_role (sl); + update_name (sl); + update_description (sl); update_path (sl); update_attributes (sl); } @@ -518,6 +546,8 @@ gtk_inspector_a11y_class_init (GtkInspectorA11yClass *klass) gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/a11y.ui"); gtk_widget_class_bind_template_child (widget_class, GtkInspectorA11y, box); gtk_widget_class_bind_template_child (widget_class, GtkInspectorA11y, role); + gtk_widget_class_bind_template_child (widget_class, GtkInspectorA11y, name); + gtk_widget_class_bind_template_child (widget_class, GtkInspectorA11y, description); gtk_widget_class_bind_template_child (widget_class, GtkInspectorA11y, bounds); gtk_widget_class_bind_template_child (widget_class, GtkInspectorA11y, path_label); gtk_widget_class_bind_template_child (widget_class, GtkInspectorA11y, path); diff --git a/gtk/inspector/a11y.ui b/gtk/inspector/a11y.ui index 190040a1a4..fad8470f31 100644 --- a/gtk/inspector/a11y.ui +++ b/gtk/inspector/a11y.ui @@ -39,8 +39,8 @@ - - Bounds + + Name start baseline 0.0 @@ -51,7 +51,7 @@ - + 1 end baseline @@ -59,6 +59,58 @@ 1 1 + + name_label + + + + + + Description + start + baseline + 0.0 + + 2 + 0 + + + + + + 1 + end + baseline + + 2 + 1 + + + description_label + + + + + + Bounds + start + baseline + 0.0 + + 3 + 0 + + + + + + 1 + end + baseline + + 3 + 1 + bounds_label @@ -71,7 +123,7 @@ baseline 0.0 - 2 + 4 0 @@ -82,7 +134,7 @@ end baseline - 2 + 4 1