inspector: show GtkAccessible bounds in a11y pane

This commit is contained in:
Jason Francis 2023-05-08 21:33:04 -04:00
parent 1181ecbf0e
commit f3996a1a66
No known key found for this signature in database
GPG Key ID: ACE1A14D3536108C
2 changed files with 62 additions and 14 deletions

View File

@ -201,6 +201,7 @@ struct _GtkInspectorA11y
GtkWidget *box;
GtkWidget *role;
GtkWidget *bounds;
GtkWidget *path_label;
GtkWidget *path;
GtkWidget *attributes;
@ -254,6 +255,19 @@ update_path (GtkInspectorA11y *sl)
#endif
}
static void
update_bounds (GtkInspectorA11y *sl)
{
int x, y, w, h;
if (gtk_accessible_get_bounds (GTK_ACCESSIBLE (sl->object), &x, &y, &w, &h))
{
char *size_label = g_strdup_printf ("%d×%d+%d+%d", w, h, x, y);
gtk_label_set_label (GTK_LABEL (sl->bounds), size_label);
g_free (size_label);
}
}
extern GType gtk_string_pair_get_type (void);
static void
@ -449,9 +463,8 @@ gtk_inspector_a11y_set_object (GtkInspectorA11y *sl,
}
gtk_stack_page_set_visible (page, TRUE);
update_role (sl);
update_path (sl);
update_attributes (sl);
refresh_all (sl);
update_bounds (sl);
}
else
{
@ -505,6 +518,7 @@ 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, bounds);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorA11y, path_label);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorA11y, path);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorA11y, attributes);

View File

@ -5,18 +5,23 @@
<object class="GtkBox" id="box">
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<object class="GtkGrid" id="grid">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">40</property>
<property name="row-spacing">20</property>
<property name="column-spacing">40</property>
<child>
<object class="GtkLabel" id="role_label">
<property name="label" translatable="yes">Role</property>
<property name="halign">start</property>
<property name="valign">baseline</property>
<property name="xalign">0.0</property>
<layout>
<property name="row">0</property>
<property name="column">0</property>
</layout>
</object>
</child>
<child>
@ -24,26 +29,51 @@
<property name="selectable">1</property>
<property name="halign">end</property>
<property name="valign">baseline</property>
<layout>
<property name="row">0</property>
<property name="column">1</property>
</layout>
<accessibility>
<relation name="labelled-by">role_label</relation>
</accessibility>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">40</property>
<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">1</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">1</property>
<property name="column">1</property>
</layout>
<accessibility>
<relation name="labelled-by">bounds_label</relation>
</accessibility>
</object>
</child>
<child>
<object class="GtkLabel" id="path_label">
<property name="label" translatable="yes">Object Path</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>
@ -51,6 +81,10 @@
<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">path_label</relation>
</accessibility>