From bcdf9b31e36ab194b8334fff3e9418fa500b1b94 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 13 Jul 2020 16:26:24 +0100 Subject: [PATCH] a11y: Update GtkSeparator Add an accessible role, and update the orientation state. --- gtk/gtkseparator.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/gtk/gtkseparator.c b/gtk/gtkseparator.c index 6a515dbf89..63ad838027 100644 --- a/gtk/gtkseparator.c +++ b/gtk/gtkseparator.c @@ -26,6 +26,7 @@ #include "gtkseparator.h" +#include "gtkaccessible.h" #include "gtkintl.h" #include "gtkorientable.h" #include "gtkprivate.h" @@ -70,6 +71,24 @@ enum { G_DEFINE_TYPE_WITH_CODE (GtkSeparator, gtk_separator, GTK_TYPE_WIDGET, G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)) +static void +gtk_separator_set_orientation (GtkSeparator *self, + GtkOrientation orientation) +{ + if (self->orientation != orientation) + { + self->orientation = orientation; + + gtk_widget_update_orientation (GTK_WIDGET (self), orientation); + gtk_widget_queue_resize (GTK_WIDGET (self)); + + gtk_accessible_update_property (GTK_ACCESSIBLE (self), + GTK_ACCESSIBLE_PROPERTY_ORIENTATION, orientation, + -1); + + g_object_notify (G_OBJECT (self), "orientation"); + } +} static void gtk_separator_set_property (GObject *object, @@ -82,14 +101,7 @@ gtk_separator_set_property (GObject *object, switch (prop_id) { case PROP_ORIENTATION: - if (separator->orientation != g_value_get_enum (value)) - { - separator->orientation = g_value_get_enum (value); - gtk_widget_update_orientation (GTK_WIDGET (object), - separator->orientation); - gtk_widget_queue_resize (GTK_WIDGET (object)); - g_object_notify_by_pspec (object, pspec); - } + gtk_separator_set_orientation (separator, g_value_get_enum (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -137,6 +149,7 @@ gtk_separator_class_init (GtkSeparatorClass *class) g_object_class_override_property (object_class, PROP_ORIENTATION, "orientation"); gtk_widget_class_set_css_name (widget_class, I_("separator")); + gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_SEPARATOR); } /**