a11y: Allow updating role on unrealized contexts

We can still change the accessible role if an ATContext instance is
unrealized.
This commit is contained in:
Emmanuele Bassi 2020-11-04 14:35:16 +00:00
parent 30210c7087
commit dafb2b0361
2 changed files with 6 additions and 3 deletions

View File

@ -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);
/**

View File

@ -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);