From b3f5243aeb6a2b06d66b11b8cebcbb8770b2151e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 5 Feb 2020 23:07:33 -0500 Subject: [PATCH 01/12] a11y: Report children of widgets We want children of composite accessibles to be reported. --- gtk/a11y/gtkwidgetaccessible.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/gtk/a11y/gtkwidgetaccessible.c b/gtk/a11y/gtkwidgetaccessible.c index 0a07f47fe2..79c38a8f01 100644 --- a/gtk/a11y/gtkwidgetaccessible.c +++ b/gtk/a11y/gtkwidgetaccessible.c @@ -409,16 +409,26 @@ gtk_widget_accessible_get_index_in_parent (AtkObject *accessible) } } - if (!GTK_IS_WIDGET (widget)) - return -1; parent_widget = gtk_widget_get_parent (widget); - if (!GTK_IS_CONTAINER (parent_widget)) - return -1; + if (GTK_IS_CONTAINER (parent_widget)) + { + children = gtk_container_get_children (GTK_CONTAINER (parent_widget)); + index = g_list_index (children, widget); + g_list_free (children); + } + else if (GTK_IS_WIDGET (parent_widget)) + { + GtkWidget *child; - children = gtk_container_get_children (GTK_CONTAINER (parent_widget)); + for (child = gtk_widget_get_first_child (parent_widget), index = 0; child; child = gtk_widget_get_next_sibling (child), index++) + { + if (child == widget) + break; + } + } + else + index = -1; - index = g_list_index (children, widget); - g_list_free (children); return index; } From d01070d4728e79153fbb0f4555adc26652b42ccb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 5 Feb 2020 23:05:01 -0500 Subject: [PATCH 02/12] a11y: Add an accessible for widgets with children We've started to turns containers into widgets which just happen to have children, and some of these need to be exposed to the a11y stack. This adds a very minimal implementation, it does not currently emit change notification when children are added or removed. --- gtk/a11y/gtkcompositeaccessible.c | 87 +++++++++++++++++++++++++++++++ gtk/a11y/gtkcompositeaccessible.h | 55 +++++++++++++++++++ gtk/a11y/meson.build | 2 + gtk/gtk-a11y.h | 1 + 4 files changed, 145 insertions(+) create mode 100644 gtk/a11y/gtkcompositeaccessible.c create mode 100644 gtk/a11y/gtkcompositeaccessible.h diff --git a/gtk/a11y/gtkcompositeaccessible.c b/gtk/a11y/gtkcompositeaccessible.c new file mode 100644 index 0000000000..8e8a6297b3 --- /dev/null +++ b/gtk/a11y/gtkcompositeaccessible.c @@ -0,0 +1,87 @@ +/* GTK+ - accessibility implementations + * Copyright 2020 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#include "config.h" + +#include "gtkcompositeaccessible.h" + +#include + +#include "gtkwidgetprivate.h" + +G_DEFINE_TYPE (GtkCompositeAccessible, gtk_composite_accessible, GTK_TYPE_WIDGET_ACCESSIBLE) + +static int +gtk_composite_accessible_get_n_children (AtkObject *obj) +{ + GtkWidget *widget; + GtkWidget *child; + int count = 0; + + widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); + if (widget == NULL) + return 0; + + for (child = gtk_widget_get_first_child (widget); child; child = gtk_widget_get_next_sibling (child)) + count++; + + return count; +} + +static AtkObject * +gtk_composite_accessible_ref_child (AtkObject *obj, + int i) +{ + GtkWidget *widget; + GtkWidget *child; + int pos; + + widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); + if (widget == NULL) + return NULL; + + for (child = gtk_widget_get_first_child (widget), pos = 0; child && pos < i; child = gtk_widget_get_next_sibling (child), pos++); + + if (child) + return g_object_ref (gtk_widget_get_accessible (GTK_WIDGET (child))); + + return NULL; +} + +static void +gtk_composite_accessible_initialize (AtkObject *obj, + gpointer data) +{ + ATK_OBJECT_CLASS (gtk_composite_accessible_parent_class)->initialize (obj, data); + + obj->role = ATK_ROLE_FILLER; +} + +static void +gtk_composite_accessible_class_init (GtkCompositeAccessibleClass *klass) +{ + AtkObjectClass *class = ATK_OBJECT_CLASS (klass); + + class->initialize = gtk_composite_accessible_initialize; + class->get_n_children = gtk_composite_accessible_get_n_children; + class->ref_child = gtk_composite_accessible_ref_child; +} + +static void +gtk_composite_accessible_init (GtkCompositeAccessible *composite) +{ +} diff --git a/gtk/a11y/gtkcompositeaccessible.h b/gtk/a11y/gtkcompositeaccessible.h new file mode 100644 index 0000000000..bc6a2bbafc --- /dev/null +++ b/gtk/a11y/gtkcompositeaccessible.h @@ -0,0 +1,55 @@ +/* GTK+ - accessibility implementations + * Copyright 2020 Red Hat, Inc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library. If not, see . + */ + +#ifndef __GTK_COMPOSITE_ACCESSIBLE_H__ +#define __GTK_COMPOSITE_ACCESSIBLE_H__ + +#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define GTK_TYPE_COMPOSITE_ACCESSIBLE (gtk_composite_accessible_get_type ()) +#define GTK_COMPOSITE_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COMPOSITE_ACCESSIBLE, GtkCompositeAccessible)) +#define GTK_COMPOSITE_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_COMPOSITE_ACCESSIBLE, GtkCompositeAccessibleClass)) +#define GTK_IS_COMPOSITE_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COMPOSITE_ACCESSIBLE)) +#define GTK_IS_COMPOSITE_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_COMPOSITE_ACCESSIBLE)) +#define GTK_COMPOSITE_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_COMPOSITE_ACCESSIBLE, GtkCompositeAccessibleClass)) + +typedef struct _GtkCompositeAccessible GtkCompositeAccessible; +typedef struct _GtkCompositeAccessibleClass GtkCompositeAccessibleClass; + +struct _GtkCompositeAccessible +{ + GtkWidgetAccessible parent; +}; + +struct _GtkCompositeAccessibleClass +{ + GtkWidgetAccessibleClass parent_class; +}; + +GDK_AVAILABLE_IN_ALL +GType gtk_composite_accessible_get_type (void); + +G_END_DECLS + +#endif /* __GTK_COMPOSITE_ACCESSIBLE_H__ */ diff --git a/gtk/a11y/meson.build b/gtk/a11y/meson.build index 550e4e7173..d8f330e016 100644 --- a/gtk/a11y/meson.build +++ b/gtk/a11y/meson.build @@ -7,6 +7,7 @@ a11y_sources = files([ 'gtkcellaccessibleparent.c', 'gtkcolorswatchaccessible.c', 'gtkcomboboxaccessible.c', + 'gtkcompositeaccessible.c', 'gtkcontaineraccessible.c', 'gtkcontainercellaccessible.c', 'gtkentryaccessible.c', @@ -58,6 +59,7 @@ a11y_headers = files([ 'gtkcellaccessible.h', 'gtkcellaccessibleparent.h', 'gtkcomboboxaccessible.h', + 'gtkcompositeaccessible.h', 'gtkcontaineraccessible.h', 'gtkcontainercellaccessible.h', 'gtkentryaccessible.h', diff --git a/gtk/gtk-a11y.h b/gtk/gtk-a11y.h index 7afaf753de..05a0cb21bc 100644 --- a/gtk/gtk-a11y.h +++ b/gtk/gtk-a11y.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include From 145ccfe1c442de04a013b83a21919d79a2940d8b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 5 Feb 2020 23:06:47 -0500 Subject: [PATCH 03/12] stackswitcher: Use a composite accessible This makes the buttons show up in the a11y tree again. --- gtk/gtkstackswitcher.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c index c9d30fecf1..aa4bf7f567 100644 --- a/gtk/gtkstackswitcher.c +++ b/gtk/gtkstackswitcher.c @@ -33,6 +33,8 @@ #include "gtktypebuiltins.h" #include "gtkwidgetprivate.h" +#include "a11y/gtkcompositeaccessible.h" + /** * SECTION:gtkstackswitcher * @Short_description: A controller for GtkStack @@ -595,6 +597,7 @@ gtk_stack_switcher_class_init (GtkStackSwitcherClass *class) gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT); gtk_widget_class_set_css_name (widget_class, I_("stackswitcher")); + gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_COMPOSITE_ACCESSIBLE); } /** From 18965eec8354eb6fb77242996013354db610b5c2 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 5 Feb 2020 23:09:23 -0500 Subject: [PATCH 04/12] testsuite: Update some a11y tests GtkMenuButton::use-popover no longer exists, remove it from test files. --- testsuite/a11y/menubutton3.ui | 1 - 1 file changed, 1 deletion(-) diff --git a/testsuite/a11y/menubutton3.ui b/testsuite/a11y/menubutton3.ui index 15c462c829..30f6a82737 100644 --- a/testsuite/a11y/menubutton3.ui +++ b/testsuite/a11y/menubutton3.ui @@ -15,7 +15,6 @@ True True menu - True From 580384e962bee5c355d9c48a5e50b3d06e3a8cdd Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 5 Feb 2020 23:17:17 -0500 Subject: [PATCH 05/12] tests: Update expected output The stackswitcher is no longer a box, so it doesn't have the horizontal state anymore. --- testsuite/a11y/about.txt | 2 +- testsuite/a11y/stack.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testsuite/a11y/about.txt b/testsuite/a11y/about.txt index 6fccc8c8aa..f1b4823ddb 100644 --- a/testsuite/a11y/about.txt +++ b/testsuite/a11y/about.txt @@ -364,7 +364,7 @@ See the GNU General Public License, version 3 or later for details. "filler" parent: headerbar1 index: 0 - state: enabled horizontal sensitive + state: enabled sensitive toolkit: gtk layer: widget diff --git a/testsuite/a11y/stack.txt b/testsuite/a11y/stack.txt index dfb48d43e7..b23d23e78a 100644 --- a/testsuite/a11y/stack.txt +++ b/testsuite/a11y/stack.txt @@ -20,7 +20,7 @@ window1 "filler" parent: box1 index: 0 - state: enabled horizontal sensitive showing visible + state: enabled sensitive showing visible toolkit: gtk layer: widget From bc682bef741ad1c58e0c7f2f7bc80966383dc3c3 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 6 Feb 2020 00:16:18 -0500 Subject: [PATCH 06/12] colorchooser: Use a composite accessible This makes the content show up in the a11y tree again. --- gtk/gtkcolorchooserwidget.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gtk/gtkcolorchooserwidget.c b/gtk/gtkcolorchooserwidget.c index a9c4f12962..85ec2ec817 100644 --- a/gtk/gtkcolorchooserwidget.c +++ b/gtk/gtkcolorchooserwidget.c @@ -31,6 +31,8 @@ #include "gtkstylecontext.h" #include "gtkboxlayout.h" +#include "a11y/gtkcompositeaccessible.h" + #include /** @@ -745,6 +747,8 @@ gtk_color_chooser_widget_class_init (GtkColorChooserWidgetClass *class) */ gtk_widget_class_install_action (widget_class, "color.customize", "(dddd)", gtk_color_chooser_widget_activate_color_customize); + + gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_COMPOSITE_ACCESSIBLE); } /* GtkColorChooser implementation {{{1 */ From a11b1bd08ebd325f3c0855a04df38f7aa76280a4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 6 Feb 2020 00:46:48 -0500 Subject: [PATCH 07/12] testsuite: Update expected output --- testsuite/a11y/colorchooser.txt | 692 ++++++++++++++++---------------- 1 file changed, 343 insertions(+), 349 deletions(-) diff --git a/testsuite/a11y/colorchooser.txt b/testsuite/a11y/colorchooser.txt index e18dae502a..026114b46b 100644 --- a/testsuite/a11y/colorchooser.txt +++ b/testsuite/a11y/colorchooser.txt @@ -1,3 +1,6 @@ +# random seed: R02Sf794a68049c2fd91c6e2c6cd2c801ffb +# GLib-GIO-DEBUG: _g_io_module_get_default: Found default implementation memory (GMemorySettingsBackend) for ‘gsettings-backend’ +# GLib-GIO-DEBUG: _g_io_module_get_default: Found default implementation gvfs (GDaemonVfs) for ‘gio-vfs’ window1 "dialog" index: 0 @@ -30,7 +33,7 @@ window1 "filler" parent: dialog-vbox1 index: 0 - state: enabled sensitive showing vertical visible + state: enabled sensitive showing visible toolkit: gtk layer: widget @@ -741,87 +744,176 @@ window1 action 1 description: Activates the color action 2 name: customize action 2 description: Customizes the color - unnamed-GtkContainerAccessible-41 + GtkColorEditor "filler" parent: chooser index: 1 - state: enabled horizontal sensitive showing visible + state: enabled horizontal sensitive toolkit: gtk layer: widget alpha: 1 - GtkColorEditor - "filler" - parent: unnamed-GtkContainerAccessible-41 + overlay + "panel" + parent: GtkColorEditor index: 0 - state: enabled horizontal sensitive + state: enabled sensitive visible toolkit: gtk layer: widget alpha: 1 - overlay + grid "panel" - parent: GtkColorEditor + parent: overlay index: 0 - state: enabled sensitive visible + state: enabled horizontal sensitive visible toolkit: gtk layer: widget alpha: 1 - grid + picker_button + "push button" + parent: grid + index: 0 + description: Pick a color from the screen + state: enabled focusable sensitive visible has-tooltip + toolkit: gtk + + layer: widget + alpha: 1 + + image size: 16 x 16 + image description: (null) + + action 0 name: click + action 0 description: Clicks the button + swatch + "radio button" + parent: grid + index: 1 + state: enabled sensitive visible + toolkit: gtk + + layer: widget + alpha: 1 + + action 0 name: select + action 0 description: Selects the color + action 1 name: activate + action 1 description: Activates the color + action 2 name: customize + action 2 description: Customizes the color + entry + "text" + parent: grid + index: 2 + name: Color Name + state: editable enabled focusable sensitive single-line visible + toolkit: gtk + + layer: widget + alpha: 1 + + text: + character count: 0 + caret offset: -1 + default attributes: bg-color: + bg-full-height: 0 + direction: + editable: false + family-name: + fg-color: + indent: 0 + invisible: false + justification: left + language: + left-margin: 0 + pixels-above-lines: 0 + pixels-below-lines: 0 + pixels-inside-wrap: 0 + right-margin: 0 + rise: 0 + scale: 1 + size: + stretch: + strikethrough: false + style: + underline: none + variant: + weight: + wrap-mode: word + + action 0 name: activate + action 0 description: Activates the entry + h_slider + "color chooser" + parent: grid + index: 3 + name: Hue + state: enabled focusable sensitive vertical visible + toolkit: gtk + + layer: widget + alpha: 1 + + minimum value: 0.000000 + maximum value: 1.000000 + current value: 0.000000 + a_slider + "color chooser" + parent: grid + index: 4 + name: Alpha + state: enabled focusable horizontal sensitive visible + toolkit: gtk + + layer: widget + alpha: 1 + + minimum value: 0.000000 + maximum value: 1.000000 + current value: 0.000000 + sv_plane + "color chooser" + parent: grid + index: 5 + name: Color Plane + state: enabled focusable sensitive visible + toolkit: gtk + + layer: widget + alpha: 1 + sv_popup + "filler" + parent: overlay + index: 1 + state: enabled horizontal sensitive + toolkit: gtk + + layer: widget + alpha: 1 + grid2 "panel" - parent: overlay + parent: sv_popup index: 0 state: enabled horizontal sensitive visible toolkit: gtk layer: widget alpha: 1 - picker_button - "push button" - parent: grid + label1 + "label" + parent: grid2 index: 0 - description: Pick a color from the screen - state: enabled focusable sensitive visible has-tooltip - toolkit: gtk - - layer: widget - alpha: 1 - - image size: 16 x 16 - image description: (null) - - action 0 name: click - action 0 description: Clicks the button - swatch - "radio button" - parent: grid - index: 1 - state: enabled sensitive visible - toolkit: gtk - - layer: widget - alpha: 1 - - action 0 name: select - action 0 description: Selects the color - action 1 name: activate - action 1 description: Activates the color - action 2 name: customize - action 2 description: Customizes the color - entry - "text" - parent: grid - index: 2 - name: Color Name - state: editable enabled focusable sensitive single-line visible + name: S + state: enabled multi-line sensitive visible toolkit: gtk layer: widget alpha: 1 - text: - character count: 0 + text: S + character count: 1 caret offset: -1 default attributes: bg-color: bg-full-height: 0 @@ -848,27 +940,209 @@ window1 variant: weight: wrap-mode: word - - action 0 name: activate - action 0 description: Activates the entry - h_slider - "color chooser" - parent: grid - index: 3 - name: Hue - state: enabled focusable sensitive vertical visible + + label2 + "label" + parent: grid2 + index: 1 + name: V + state: enabled multi-line sensitive visible + toolkit: gtk + + layer: widget + alpha: 1 + + text: V + character count: 1 + caret offset: -1 + default attributes: bg-color: + bg-full-height: 0 + direction: + editable: false + family-name: + fg-color: + indent: 0 + invisible: false + justification: left + language: + left-margin: 0 + pixels-above-lines: 0 + pixels-below-lines: 0 + pixels-inside-wrap: 0 + right-margin: 0 + rise: 0 + scale: 1 + size: + stretch: + strikethrough: false + style: + underline: none + variant: + weight: + wrap-mode: word + + s_entry + "spin button" + parent: grid2 + index: 2 + name: Saturation + state: enabled focusable horizontal sensitive visible toolkit: gtk layer: widget alpha: 1 minimum value: 0.000000 - maximum value: 1.000000 + maximum value: 100.000000 current value: 0.000000 - a_slider - "color chooser" - parent: grid - index: 4 + v_entry + "spin button" + parent: grid2 + index: 3 + name: Value + state: enabled focusable horizontal sensitive visible + toolkit: gtk + + layer: widget + alpha: 1 + + minimum value: 0.000000 + maximum value: 100.000000 + current value: 0.000000 + h_popup + "filler" + parent: overlay + index: 2 + state: enabled horizontal sensitive + toolkit: gtk + + layer: widget + alpha: 1 + grid3 + "panel" + parent: h_popup + index: 0 + state: enabled horizontal sensitive visible + toolkit: gtk + + layer: widget + alpha: 1 + label3 + "label" + parent: grid3 + index: 0 + name: H + state: enabled multi-line sensitive visible + toolkit: gtk + + layer: widget + alpha: 1 + + text: H + character count: 1 + caret offset: -1 + default attributes: bg-color: + bg-full-height: 0 + direction: + editable: false + family-name: + fg-color: + indent: 0 + invisible: false + justification: left + language: + left-margin: 0 + pixels-above-lines: 0 + pixels-below-lines: 0 + pixels-inside-wrap: 0 + right-margin: 0 + rise: 0 + scale: 1 + size: + stretch: + strikethrough: false + style: + underline: none + variant: + weight: + wrap-mode: word + + h_entry + "spin button" + parent: grid3 + index: 1 + name: Hue + state: enabled focusable horizontal sensitive visible + toolkit: gtk + + layer: widget + alpha: 1 + + minimum value: 0.000000 + maximum value: 100.000000 + current value: 0.000000 + a_popup + "filler" + parent: overlay + index: 3 + state: enabled horizontal sensitive + toolkit: gtk + + layer: widget + alpha: 1 + grid4 + "panel" + parent: a_popup + index: 0 + state: enabled horizontal sensitive visible + toolkit: gtk + + layer: widget + alpha: 1 + label4 + "label" + parent: grid4 + index: 0 + name: A + state: enabled multi-line sensitive visible + toolkit: gtk + + layer: widget + alpha: 1 + + text: A + character count: 1 + caret offset: -1 + default attributes: bg-color: + bg-full-height: 0 + direction: + editable: false + family-name: + fg-color: + indent: 0 + invisible: false + justification: left + language: + left-margin: 0 + pixels-above-lines: 0 + pixels-below-lines: 0 + pixels-inside-wrap: 0 + right-margin: 0 + rise: 0 + scale: 1 + size: + stretch: + strikethrough: false + style: + underline: none + variant: + weight: + wrap-mode: word + + a_entry + "spin button" + parent: grid4 + index: 1 name: Alpha state: enabled focusable horizontal sensitive visible toolkit: gtk @@ -877,288 +1151,8 @@ window1 alpha: 1 minimum value: 0.000000 - maximum value: 1.000000 + maximum value: 100.000000 current value: 0.000000 - sv_plane - "color chooser" - parent: grid - index: 5 - name: Color Plane - state: enabled focusable sensitive visible - toolkit: gtk - - layer: widget - alpha: 1 - sv_popup - "filler" - parent: overlay - index: 1 - state: enabled horizontal sensitive - toolkit: gtk - - layer: widget - alpha: 1 - grid2 - "panel" - parent: sv_popup - index: 0 - state: enabled horizontal sensitive visible - toolkit: gtk - - layer: widget - alpha: 1 - label1 - "label" - parent: grid2 - index: 0 - name: S - state: enabled multi-line sensitive visible - toolkit: gtk - - layer: widget - alpha: 1 - - text: S - character count: 1 - caret offset: -1 - default attributes: bg-color: - bg-full-height: 0 - direction: - editable: false - family-name: - fg-color: - indent: 0 - invisible: false - justification: left - language: - left-margin: 0 - pixels-above-lines: 0 - pixels-below-lines: 0 - pixels-inside-wrap: 0 - right-margin: 0 - rise: 0 - scale: 1 - size: - stretch: - strikethrough: false - style: - underline: none - variant: - weight: - wrap-mode: word - - label2 - "label" - parent: grid2 - index: 1 - name: V - state: enabled multi-line sensitive visible - toolkit: gtk - - layer: widget - alpha: 1 - - text: V - character count: 1 - caret offset: -1 - default attributes: bg-color: - bg-full-height: 0 - direction: - editable: false - family-name: - fg-color: - indent: 0 - invisible: false - justification: left - language: - left-margin: 0 - pixels-above-lines: 0 - pixels-below-lines: 0 - pixels-inside-wrap: 0 - right-margin: 0 - rise: 0 - scale: 1 - size: - stretch: - strikethrough: false - style: - underline: none - variant: - weight: - wrap-mode: word - - s_entry - "spin button" - parent: grid2 - index: 2 - name: Saturation - state: enabled focusable horizontal sensitive visible - toolkit: gtk - - layer: widget - alpha: 1 - - minimum value: 0.000000 - maximum value: 100.000000 - current value: 0.000000 - v_entry - "spin button" - parent: grid2 - index: 3 - name: Value - state: enabled focusable horizontal sensitive visible - toolkit: gtk - - layer: widget - alpha: 1 - - minimum value: 0.000000 - maximum value: 100.000000 - current value: 0.000000 - h_popup - "filler" - parent: overlay - index: 2 - state: enabled horizontal sensitive - toolkit: gtk - - layer: widget - alpha: 1 - grid3 - "panel" - parent: h_popup - index: 0 - state: enabled horizontal sensitive visible - toolkit: gtk - - layer: widget - alpha: 1 - label3 - "label" - parent: grid3 - index: 0 - name: H - state: enabled multi-line sensitive visible - toolkit: gtk - - layer: widget - alpha: 1 - - text: H - character count: 1 - caret offset: -1 - default attributes: bg-color: - bg-full-height: 0 - direction: - editable: false - family-name: - fg-color: - indent: 0 - invisible: false - justification: left - language: - left-margin: 0 - pixels-above-lines: 0 - pixels-below-lines: 0 - pixels-inside-wrap: 0 - right-margin: 0 - rise: 0 - scale: 1 - size: - stretch: - strikethrough: false - style: - underline: none - variant: - weight: - wrap-mode: word - - h_entry - "spin button" - parent: grid3 - index: 1 - name: Hue - state: enabled focusable horizontal sensitive visible - toolkit: gtk - - layer: widget - alpha: 1 - - minimum value: 0.000000 - maximum value: 100.000000 - current value: 0.000000 - a_popup - "filler" - parent: overlay - index: 3 - state: enabled horizontal sensitive - toolkit: gtk - - layer: widget - alpha: 1 - grid4 - "panel" - parent: a_popup - index: 0 - state: enabled horizontal sensitive visible - toolkit: gtk - - layer: widget - alpha: 1 - label4 - "label" - parent: grid4 - index: 0 - name: A - state: enabled multi-line sensitive visible - toolkit: gtk - - layer: widget - alpha: 1 - - text: A - character count: 1 - caret offset: -1 - default attributes: bg-color: - bg-full-height: 0 - direction: - editable: false - family-name: - fg-color: - indent: 0 - invisible: false - justification: left - language: - left-margin: 0 - pixels-above-lines: 0 - pixels-below-lines: 0 - pixels-inside-wrap: 0 - right-margin: 0 - rise: 0 - scale: 1 - size: - stretch: - strikethrough: false - style: - underline: none - variant: - weight: - wrap-mode: word - - a_entry - "spin button" - parent: grid4 - index: 1 - name: Alpha - state: enabled focusable horizontal sensitive visible - toolkit: gtk - - layer: widget - alpha: 1 - - minimum value: 0.000000 - maximum value: 100.000000 - current value: 0.000000 action_box "filler" parent: ___object_1___ @@ -1188,7 +1182,7 @@ window1 alpha: 1 cancel_button "push button" - parent: headerbar + parent: unnamed-GtkContainerAccessible-41 index: 0 name: Cancel state: enabled focusable sensitive showing visible @@ -1205,8 +1199,8 @@ window1 action 0 keybinding: c ok_button "push button" - parent: headerbar - index: 1 + parent: unnamed-GtkContainerAccessible-42 + index: 0 name: Select state: enabled focusable sensitive showing visible default toolkit: gtk From 2dba92fd0c79d8147566f9035b9db66a812847e3 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 6 Feb 2020 00:47:13 -0500 Subject: [PATCH 08/12] tests: Fix infobars in ui files GtkInfoBar no longer exposes the content_area as internal child. --- testsuite/a11y/infobar.ui | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/testsuite/a11y/infobar.ui b/testsuite/a11y/infobar.ui index a082198ee8..32047883b8 100644 --- a/testsuite/a11y/infobar.ui +++ b/testsuite/a11y/infobar.ui @@ -8,14 +8,10 @@ True info - - - - - True - Some important info - - + + + True + Some important info From b916723baf26225911c4fe34b5619352b205aad8 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 6 Feb 2020 16:50:09 -0500 Subject: [PATCH 09/12] testsuite: Improve --generate support When using the test binary to generate expected output, don't initialize the test machinery, since that pollutes the output with noise. --- testsuite/a11y/accessibility-dump.c | 38 +++++++++++++++-------------- testsuite/a11y/colorchooser.txt | 3 --- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/testsuite/a11y/accessibility-dump.c b/testsuite/a11y/accessibility-dump.c index 70d31d5f04..ff2afff5c5 100644 --- a/testsuite/a11y/accessibility-dump.c +++ b/testsuite/a11y/accessibility-dump.c @@ -929,14 +929,6 @@ parse_command_line (int *argc, char ***argv) return FALSE; } - gtk_test_init (argc, argv); - - /* gtk_test_init does not call setlocale(), so do it ourselves, - * since running in the C locale breaks some our fancy - * utf8 output. - */ - setlocale (LC_ALL, "en_US.utf8"); - return TRUE; } @@ -960,6 +952,26 @@ main (int argc, char **argv) fix_settings (); + if (argc == 3 && strcmp (argv[1], "--generate") == 0) + { + GFile *file = g_file_new_for_commandline_arg (argv[2]); + + gtk_init (); + + dump_to_stdout (file); + g_object_unref (file); + + return 0; + } + + gtk_test_init (&argc, &argv); + + /* gtk_test_init does not call setlocale(), so do it ourselves, + * since running in the C locale breaks some our fancy + * utf8 output. + */ + setlocale (LC_ALL, "en_US.utf8"); + if (argc < 2) { const char *basedir; @@ -974,16 +986,6 @@ main (int argc, char **argv) g_object_unref (dir); } - else if (argc == 3 && strcmp (argv[1], "--generate") == 0) - { - GFile *file = g_file_new_for_commandline_arg (argv[2]); - - dump_to_stdout (file); - - g_object_unref (file); - - return 0; - } else { guint i; diff --git a/testsuite/a11y/colorchooser.txt b/testsuite/a11y/colorchooser.txt index 026114b46b..db434621ce 100644 --- a/testsuite/a11y/colorchooser.txt +++ b/testsuite/a11y/colorchooser.txt @@ -1,6 +1,3 @@ -# random seed: R02Sf794a68049c2fd91c6e2c6cd2c801ffb -# GLib-GIO-DEBUG: _g_io_module_get_default: Found default implementation memory (GMemorySettingsBackend) for ‘gsettings-backend’ -# GLib-GIO-DEBUG: _g_io_module_get_default: Found default implementation gvfs (GDaemonVfs) for ‘gio-vfs’ window1 "dialog" index: 0 From 048effdc5a3beac45d07dd598d72af5fd5d19fa9 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 6 Feb 2020 17:12:34 -0500 Subject: [PATCH 10/12] testsuite: Clean up a11y menu tests We don't need some of the tests anymore, since we just have popovers now. --- testsuite/a11y/menubutton.txt | 13 --- testsuite/a11y/menubutton.ui | 5 +- testsuite/a11y/menubutton2.ui | 1 - testsuite/a11y/menubutton3.txt | 27 ------ testsuite/a11y/menubutton3.ui | 21 ----- testsuite/a11y/meson.build | 165 +++++++++++++-------------------- 6 files changed, 63 insertions(+), 169 deletions(-) delete mode 100644 testsuite/a11y/menubutton3.txt delete mode 100644 testsuite/a11y/menubutton3.ui diff --git a/testsuite/a11y/menubutton.txt b/testsuite/a11y/menubutton.txt index 59c99901ad..ec6956665b 100644 --- a/testsuite/a11y/menubutton.txt +++ b/testsuite/a11y/menubutton.txt @@ -25,16 +25,3 @@ window1 layer: widget alpha: 1 - imagemenuitem - "menu item" - parent: menu - index: 0 - state: enabled selectable sensitive visible - toolkit: gtk - - layer: popup - alpha: 1 - - action 0 name: click - action 0 description: Clicks the menuitem - diff --git a/testsuite/a11y/menubutton.ui b/testsuite/a11y/menubutton.ui index eb7d509d73..c48c253b29 100644 --- a/testsuite/a11y/menubutton.ui +++ b/testsuite/a11y/menubutton.ui @@ -2,11 +2,9 @@ - True _New - True True @@ -15,9 +13,8 @@ False - True True - menu + menu diff --git a/testsuite/a11y/menubutton2.ui b/testsuite/a11y/menubutton2.ui index 30f6a82737..97c31b11ae 100644 --- a/testsuite/a11y/menubutton2.ui +++ b/testsuite/a11y/menubutton2.ui @@ -12,7 +12,6 @@ False - True True menu diff --git a/testsuite/a11y/menubutton3.txt b/testsuite/a11y/menubutton3.txt deleted file mode 100644 index ec6956665b..0000000000 --- a/testsuite/a11y/menubutton3.txt +++ /dev/null @@ -1,27 +0,0 @@ -window1 - "frame" - index: 0 - state: enabled resizable sensitive showing visible - toolkit: gtk - window-type: normal - - layer: window - alpha: 1 - unnamed-GtkContainerAccessible-0 - "panel" - parent: window1 - state: enabled sensitive showing visible - toolkit: gtk - - layer: widget - alpha: 1 - menubutton - "toggle button" - parent: window1 - index: 0 - name: Menu - state: enabled focusable focused sensitive showing visible - toolkit: gtk - - layer: widget - alpha: 1 diff --git a/testsuite/a11y/menubutton3.ui b/testsuite/a11y/menubutton3.ui deleted file mode 100644 index 30f6a82737..0000000000 --- a/testsuite/a11y/menubutton3.ui +++ /dev/null @@ -1,21 +0,0 @@ - - - - -
- - New - -
-
- - False - - - True - True - menu - - - -
diff --git a/testsuite/a11y/meson.build b/testsuite/a11y/meson.build index 6df0b25b2f..b782f45dc0 100644 --- a/testsuite/a11y/meson.build +++ b/testsuite/a11y/meson.build @@ -2,43 +2,41 @@ testexecdir = join_paths(installed_test_bindir, 'a11y') testdatadir = join_paths(installed_test_datadir, 'a11y') a11y_state_tests = [ - 'hello-world', - 'mnemonic', - 'accessible-name', - 'notebook', - 'range', - 'link', - 'text', - 'buttons', - 'colorchooser', 'about', - 'messagedialog', - 'expander', + 'accessible-name', + 'actionbar', 'assistant', - 'pickers', - 'label', - 'lockbutton', - 'spinner', - 'progress', - 'infobar', + 'buttons', 'calendar', - 'statusbar', - 'paned', - 'iconview', + 'colorchooser', + 'combos', 'entries', - 'scale-drawvalue', - 'placeholder-text', - 'menu', + 'expander', + 'headerbar', + 'hello-world', + 'iconview', + 'infobar', + 'label', + 'link', + 'listbox', + 'lockbutton', 'menubutton', 'menubutton2', - 'menubutton3', - 'combos', - 'listbox', + 'messagedialog', + 'mnemonic', + 'notebook', + 'paned', + 'pickers', + 'placeholder-text', + 'progress', + 'range', + 'scale-drawvalue', + 'spinner', + 'statusbar', 'stack', - 'headerbar', - 'tree', - 'actionbar', + 'text', 'tooltips', + 'tree', ] a11y_dump_bin = executable('accessibility-dump', @@ -111,80 +109,41 @@ a11y_installed_tests = [ ] installed_test_data = [ - 'hello-world.ui', - 'hello-world.txt', - 'mnemonic.ui', - 'mnemonic.txt', - 'accessible-name.ui', - 'accessible-name.txt', - 'notebook.ui', - 'notebook.txt', - 'range.ui', - 'range.txt', - 'link.ui', - 'link.txt', - 'text.ui', - 'text.txt', - 'buttons.ui', - 'buttons.txt', - 'colorchooser.ui', - 'colorchooser.txt', - 'about.ui', - 'about.txt', - 'messagedialog.ui', - 'messagedialog.txt', - 'expander.ui', - 'expander.txt', - 'assistant.ui', - 'assistant.txt', - 'pickers.ui', - 'pickers.txt', - 'label.ui', - 'label.txt', - 'lockbutton.ui', - 'lockbutton.txt', - 'spinner.ui', - 'spinner.txt', - 'progress.ui', - 'progress.txt', - 'infobar.ui', - 'infobar.txt', - 'calendar.ui', - 'calendar.txt', - 'statusbar.ui', - 'statusbar.txt', - 'paned.ui', - 'paned.txt', - 'iconview.ui', - 'iconview.txt', - 'entries.ui', - 'entries.txt', - 'scale-drawvalue.ui', - 'scale-drawvalue.txt', - 'placeholder-text.ui', - 'placeholder-text.txt', - 'menu.ui', - 'menu.txt', - 'menubutton.ui', - 'menubutton.txt', - 'menubutton2.ui', - 'menubutton2.txt', - 'menubutton3.ui', - 'menubutton3.txt', - 'combos.ui', - 'combos.txt', - 'listbox.ui', - 'listbox.txt', - 'stack.ui', - 'stack.txt', - 'headerbar.ui', - 'headerbar.txt', - 'tree.ui', - 'tree.txt', - 'actionbar.ui', - 'actionbar.txt', - 'tooltips.ui', - 'tooltips.txt', + 'about.ui', 'about.txt', + 'accessible-name.ui', 'accessible-name.txt', + 'actionbar.ui', 'actionbar.txt', + 'assistant.ui', 'assistant.txt', + 'buttons.ui', 'buttons.txt', + 'calendar.ui', 'calendar.txt', + 'colorchooser.ui', 'colorchooser.txt', + 'combos.ui', 'combos.txt', + 'entries.ui', 'entries.txt', + 'expander.ui', 'expander.txt', + 'headerbar.ui', 'headerbar.txt', + 'hello-world.ui', 'hello-world.txt', + 'iconview.ui', 'iconview.txt', + 'infobar.ui', 'infobar.txt', + 'label.ui', 'label.txt', + 'link.ui', 'link.txt', + 'listbox.ui', 'listbox.txt', + 'lockbutton.ui', 'lockbutton.txt', + 'menubutton.ui', 'menubutton.txt', + 'menubutton2.ui', 'menubutton2.txt', + 'messagedialog.ui', 'messagedialog.txt', + 'mnemonic.ui', 'mnemonic.txt', + 'notebook.ui', 'notebook.txt', + 'paned.ui', 'paned.txt', + 'pickers.ui', 'pickers.txt', + 'placeholder-text.ui', 'placeholder-text.txt', + 'progress.ui', 'progress.txt', + 'range.ui', 'range.txt', + 'scale-drawvalue.ui', 'scale-drawvalue.txt', + 'spinner.ui', 'spinner.txt', + 'stack.ui', 'stack.txt', + 'statusbar.ui', 'statusbar.txt', + 'text.ui', 'text.txt', + 'tooltips.ui', 'tooltips.txt', + 'tree.ui', 'tree.txt', ] if get_option('install-tests') From 769dae2c71e0bbead834178f3584abbebc29a5b7 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 6 Feb 2020 18:03:28 -0500 Subject: [PATCH 11/12] infobar: Implement forall As a container, that is what you have to do. --- gtk/gtkinfobar.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gtk/gtkinfobar.c b/gtk/gtkinfobar.c index a7b902cf17..5cfb54430e 100644 --- a/gtk/gtkinfobar.c +++ b/gtk/gtkinfobar.c @@ -51,6 +51,8 @@ #include "gtkbinlayout.h" #include "gtkgestureclick.h" +#include "a11y/gtkcontaineraccessibleprivate.h" + /** * SECTION:gtkinfobar * @short_description: Report important messages to the user @@ -351,6 +353,18 @@ gtk_info_bar_remove (GtkContainer *container, gtk_container_remove (GTK_CONTAINER (priv->content_area), child); } +static void +gtk_info_bar_forall (GtkContainer *container, + GtkCallback callback, + gpointer user_data) +{ + GtkInfoBar *self = GTK_INFO_BAR (container); + GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (self); + + if (priv->revealer) + (*callback) (priv->revealer, user_data); +} + static void gtk_info_bar_dispose (GObject *object) { @@ -380,6 +394,7 @@ gtk_info_bar_class_init (GtkInfoBarClass *klass) container_class->add = gtk_info_bar_add; container_class->remove = gtk_info_bar_remove; + container_class->forall = gtk_info_bar_forall; klass->close = gtk_info_bar_close; From e45b668e043b44d0d5f2793689d675a721099e3c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 6 Feb 2020 17:21:22 -0500 Subject: [PATCH 12/12] testsuite: Misc. updates of expected output The a11y dumps for action and header bars have changed in harmless ways. --- testsuite/a11y/actionbar.txt | 1 + testsuite/a11y/headerbar.txt | 6 +++--- testsuite/a11y/iconview.txt | 8 ++++---- testsuite/a11y/infobar.txt | 22 +++++++++++----------- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/testsuite/a11y/actionbar.txt b/testsuite/a11y/actionbar.txt index 5fec7b6a2f..c5dfafa274 100644 --- a/testsuite/a11y/actionbar.txt +++ b/testsuite/a11y/actionbar.txt @@ -51,6 +51,7 @@ window1 button5 "push button" parent: unnamed-GtkWidgetAccessible-1 + index: 1 name: Center state: enabled focusable sensitive showing visible toolkit: gtk diff --git a/testsuite/a11y/headerbar.txt b/testsuite/a11y/headerbar.txt index a0dffd43f1..b92dd63504 100644 --- a/testsuite/a11y/headerbar.txt +++ b/testsuite/a11y/headerbar.txt @@ -18,7 +18,7 @@ window1 alpha: 1 button1 "push button" - parent: headerbar1 + parent: unnamed-GtkContainerAccessible-0 index: 0 name: Yes state: enabled focusable focused sensitive showing visible @@ -34,8 +34,8 @@ window1 action 0 description: Clicks the button page2 "push button" - parent: headerbar1 - index: 1 + parent: unnamed-GtkContainerAccessible-1 + index: 0 name: No state: enabled focusable sensitive showing visible toolkit: gtk diff --git a/testsuite/a11y/iconview.txt b/testsuite/a11y/iconview.txt index 98a6acad82..404a2c73c2 100644 --- a/testsuite/a11y/iconview.txt +++ b/testsuite/a11y/iconview.txt @@ -28,7 +28,7 @@ window1 text: One character count: 3 - caret offset: 0 + caret offset: -1 image size: 0 x 0 image description: (null) @@ -46,7 +46,7 @@ window1 text: Three character count: 5 - caret offset: 0 + caret offset: -1 image size: 0 x 0 image description: (null) @@ -64,7 +64,7 @@ window1 text: Five character count: 4 - caret offset: 0 + caret offset: -1 image size: 0 x 0 image description: (null) @@ -82,7 +82,7 @@ window1 text: Seven character count: 5 - caret offset: 0 + caret offset: -1 image size: 0 x 0 image description: (null) diff --git a/testsuite/a11y/infobar.txt b/testsuite/a11y/infobar.txt index 34758d6f2b..f0a8a105a8 100644 --- a/testsuite/a11y/infobar.txt +++ b/testsuite/a11y/infobar.txt @@ -12,12 +12,12 @@ window1 parent: window1 index: 0 name: Information - state: enabled horizontal sensitive showing visible + state: enabled sensitive showing visible toolkit: gtk layer: widget alpha: 1 - revealer + unnamed-GtkContainerAccessible-0 "panel" parent: bar1 index: 0 @@ -26,18 +26,18 @@ window1 layer: widget alpha: 1 - content + unnamed-GtkContainerAccessible-1 "filler" - parent: revealer + parent: unnamed-GtkContainerAccessible-0 index: 0 state: enabled horizontal sensitive showing visible toolkit: gtk layer: widget alpha: 1 - box1 + unnamed-GtkContainerAccessible-2 "filler" - parent: content + parent: unnamed-GtkContainerAccessible-1 index: 0 state: enabled horizontal sensitive showing visible toolkit: gtk @@ -46,7 +46,7 @@ window1 alpha: 1 label1 "label" - parent: box1 + parent: unnamed-GtkContainerAccessible-2 index: 0 name: Some important info state: enabled multi-line sensitive showing visible @@ -84,18 +84,18 @@ window1 weight: wrap-mode: word - action_area + unnamed-GtkContainerAccessible-3 "filler" - parent: content + parent: unnamed-GtkContainerAccessible-1 index: 1 state: enabled horizontal sensitive showing visible toolkit: gtk layer: widget alpha: 1 - close_button + unnamed-GtkButtonAccessible-4 "push button" - parent: content + parent: unnamed-GtkContainerAccessible-1 index: 2 name: Close state: enabled focusable sensitive