From f3996a1a6690dcdd517405fd34324f5216e82892 Mon Sep 17 00:00:00 2001 From: Jason Francis Date: Mon, 8 May 2023 21:33:04 -0400 Subject: [PATCH] inspector: show GtkAccessible bounds in a11y pane --- gtk/inspector/a11y.c | 20 +++++++++++++--- gtk/inspector/a11y.ui | 56 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 62 insertions(+), 14 deletions(-) diff --git a/gtk/inspector/a11y.c b/gtk/inspector/a11y.c index 8d4c20a5cf..4252f09011 100644 --- a/gtk/inspector/a11y.c +++ b/gtk/inspector/a11y.c @@ -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); diff --git a/gtk/inspector/a11y.ui b/gtk/inspector/a11y.ui index 785a337df6..190040a1a4 100644 --- a/gtk/inspector/a11y.ui +++ b/gtk/inspector/a11y.ui @@ -5,18 +5,23 @@ vertical - + 10 10 10 10 - 40 + 20 + 40 Role start baseline 0.0 + + 0 + 0 + @@ -24,26 +29,51 @@ 1 end baseline + + 0 + 1 + role_label - - - - - 10 - 10 - 10 - 10 - 40 + + + Bounds + start + baseline + 0.0 + + 1 + 0 + + + + + + 1 + end + baseline + + 1 + 1 + + + bounds_label + + + Object Path start baseline 0.0 + + 2 + 0 + @@ -51,6 +81,10 @@ 1 end baseline + + 2 + 1 + path_label