From dafb2b0361064e58462d0cb3509bb2d0aaa8cb67 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 4 Nov 2020 14:35:16 +0000 Subject: [PATCH] a11y: Allow updating role on unrealized contexts We can still change the accessible role if an ATContext instance is unrealized. --- gtk/gtkatcontext.c | 7 +++++-- gtk/gtkwidget.c | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gtk/gtkatcontext.c b/gtk/gtkatcontext.c index 078dc2872d..0305ac156e 100644 --- a/gtk/gtkatcontext.c +++ b/gtk/gtkatcontext.c @@ -90,7 +90,10 @@ gtk_at_context_set_property (GObject *gobject, switch (prop_id) { case PROP_ACCESSIBLE_ROLE: - self->accessible_role = g_value_get_enum (value); + if (!self->realized) + self->accessible_role = g_value_get_enum (value); + else + g_critical ("The accessible role cannot be set on a realized AT context"); break; case PROP_ACCESSIBLE: @@ -203,7 +206,7 @@ gtk_at_context_class_init (GtkATContextClass *klass) GTK_TYPE_ACCESSIBLE_ROLE, GTK_ACCESSIBLE_ROLE_NONE, G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | + G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); /** diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 36c8f95ade..9c4f78ad57 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -1731,7 +1731,7 @@ gtk_widget_set_property (GObject *object, gtk_widget_set_layout_manager (widget, g_value_dup_object (value)); break; case PROP_ACCESSIBLE_ROLE: - if (priv->at_context == NULL) + if (priv->at_context == NULL || !gtk_at_context_is_realized (priv->at_context)) { priv->accessible_role = g_value_get_enum (value); g_object_notify_by_pspec (object, pspec);