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.
This commit is contained in:
Matthias Clasen
2023-06-09 21:03:54 -04:00
parent 5816e2fe51
commit fcb9048043
2 changed files with 87 additions and 5 deletions

View File

@@ -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);

View File

@@ -39,8 +39,8 @@
</object>
</child>
<child>
<object class="GtkLabel" id="bounds_label">
<property name="label" translatable="yes">Bounds</property>
<object class="GtkLabel" id="name_label">
<property name="label" translatable="yes">Name</property>
<property name="halign">start</property>
<property name="valign">baseline</property>
<property name="xalign">0.0</property>
@@ -51,7 +51,7 @@
</object>
</child>
<child>
<object class="GtkLabel" id="bounds">
<object class="GtkLabel" id="name">
<property name="selectable">1</property>
<property name="halign">end</property>
<property name="valign">baseline</property>
@@ -59,6 +59,58 @@
<property name="row">1</property>
<property name="column">1</property>
</layout>
<accessibility>
<relation name="labelled-by">name_label</relation>
</accessibility>
</object>
</child>
<child>
<object class="GtkLabel" id="description_label">
<property name="label" translatable="yes">Description</property>
<property name="halign">start</property>
<property name="valign">baseline</property>
<property name="xalign">0.0</property>
<layout>
<property name="row">2</property>
<property name="column">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="description">
<property name="selectable">1</property>
<property name="halign">end</property>
<property name="valign">baseline</property>
<layout>
<property name="row">2</property>
<property name="column">1</property>
</layout>
<accessibility>
<relation name="labelled-by">description_label</relation>
</accessibility>
</object>
</child>
<child>
<object class="GtkLabel" id="bounds_label">
<property name="label" translatable="yes">Bounds</property>
<property name="halign">start</property>
<property name="valign">baseline</property>
<property name="xalign">0.0</property>
<layout>
<property name="row">3</property>
<property name="column">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="bounds">
<property name="selectable">1</property>
<property name="halign">end</property>
<property name="valign">baseline</property>
<layout>
<property name="row">3</property>
<property name="column">1</property>
</layout>
<accessibility>
<relation name="labelled-by">bounds_label</relation>
</accessibility>
@@ -71,7 +123,7 @@
<property name="valign">baseline</property>
<property name="xalign">0.0</property>
<layout>
<property name="row">2</property>
<property name="row">4</property>
<property name="column">0</property>
</layout>
</object>
@@ -82,7 +134,7 @@
<property name="halign">end</property>
<property name="valign">baseline</property>
<layout>
<property name="row">2</property>
<property name="row">4</property>
<property name="column">1</property>
</layout>
<accessibility>