mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-12 20:00:09 +00:00
a11y: Add an explicit "reset to default" method
In some cases we explicitly want to unset an accessible attribute; for instance, an accessible property is gated on a widget property, and if the widget property gets unset, the accessible property should be reset.
This commit is contained in:
parent
bf06cad5d9
commit
470349c902
@ -7647,10 +7647,13 @@ GtkAccessibleAutocomplete
|
||||
GtkAccessibleSort
|
||||
gtk_accessible_update_state
|
||||
gtk_accessible_update_state_value
|
||||
gtk_accessible_reset_state
|
||||
gtk_accessible_update_property
|
||||
gtk_accessible_update_property_value
|
||||
gtk_accessible_reset_property
|
||||
gtk_accessible_update_relation
|
||||
gtk_accessible_update_relation_value
|
||||
gtk_accessible_reset_relation
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_ACCESSIBLE
|
||||
|
@ -28,13 +28,13 @@
|
||||
* “AT”. Every accessible implementation has:
|
||||
*
|
||||
* - a “role”, represented by a value of the #GtkAccessibleRole enumeration
|
||||
* - a “state”, represented by a set of #GtkAccessibleState,
|
||||
* #GtkAccessibleProperty and #GtkAccessibleRelation values
|
||||
* - an “attribute”, represented by a set of #GtkAccessibleState,
|
||||
* #GtkAccessibleProperty and #GtkAccessibleRelation values
|
||||
*
|
||||
* The role cannot be changed after instantiating a #GtkAccessible
|
||||
* implementation.
|
||||
*
|
||||
* The state is updated every time a UI element's state changes in a way that
|
||||
* The attributes are updated every time a UI element's state changes in a way that
|
||||
* should be reflected by assistive technologies. For instance, if a #GtkWidget
|
||||
* visibility changes, the %GTK_ACCESSIBLE_STATE_HIDDEN state will also change
|
||||
* to reflect the #GtkWidget:visible property.
|
||||
@ -218,6 +218,29 @@ gtk_accessible_update_state_value (GtkAccessible *self,
|
||||
gtk_at_context_update (context);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_accessible_reset_state:
|
||||
* @self: a #GtkAccessible
|
||||
* @state: a #GtkAccessibleState
|
||||
*
|
||||
* Resets the accessible @state to its default value.
|
||||
*/
|
||||
void
|
||||
gtk_accessible_reset_state (GtkAccessible *self,
|
||||
GtkAccessibleState state)
|
||||
{
|
||||
GtkATContext *context;
|
||||
|
||||
g_return_if_fail (GTK_IS_ACCESSIBLE (self));
|
||||
|
||||
context = gtk_accessible_get_at_context (self);
|
||||
if (context == NULL)
|
||||
return;
|
||||
|
||||
gtk_at_context_set_accessible_state (context, state, NULL);
|
||||
gtk_at_context_update (context);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_accessible_update_property:
|
||||
* @self: a #GtkAccessible
|
||||
@ -333,6 +356,29 @@ gtk_accessible_update_property_value (GtkAccessible *self,
|
||||
gtk_at_context_update (context);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_accessible_reset_property:
|
||||
* @self: a #GtkAccessible
|
||||
* @property: a #GtkAccessibleProperty
|
||||
*
|
||||
* Resets the accessible @property to its default value.
|
||||
*/
|
||||
void
|
||||
gtk_accessible_reset_property (GtkAccessible *self,
|
||||
GtkAccessibleProperty property)
|
||||
{
|
||||
GtkATContext *context;
|
||||
|
||||
g_return_if_fail (GTK_IS_ACCESSIBLE (self));
|
||||
|
||||
context = gtk_accessible_get_at_context (self);
|
||||
if (context == NULL)
|
||||
return;
|
||||
|
||||
gtk_at_context_set_accessible_property (context, property, NULL);
|
||||
gtk_at_context_update (context);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_accessible_update_relation:
|
||||
* @self: a #GtkAccessible
|
||||
@ -438,3 +484,26 @@ gtk_accessible_update_relation_value (GtkAccessible *self,
|
||||
|
||||
gtk_at_context_update (context);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_accessible_reset_relation:
|
||||
* @self: a #GtkAccessible
|
||||
* @relation: a #GtkAccessibleRelation
|
||||
*
|
||||
* Resets the accessible @relation to its default value.
|
||||
*/
|
||||
void
|
||||
gtk_accessible_reset_relation (GtkAccessible *self,
|
||||
GtkAccessibleRelation relation)
|
||||
{
|
||||
GtkATContext *context;
|
||||
|
||||
g_return_if_fail (GTK_IS_ACCESSIBLE (self));
|
||||
|
||||
context = gtk_accessible_get_at_context (self);
|
||||
if (context == NULL)
|
||||
return;
|
||||
|
||||
gtk_at_context_set_accessible_relation (context, relation, NULL);
|
||||
gtk_at_context_update (context);
|
||||
}
|
||||
|
@ -63,4 +63,14 @@ void gtk_accessible_update_relation_value (GtkAccessible
|
||||
GtkAccessibleRelation relation,
|
||||
const GValue *value);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accessible_reset_state (GtkAccessible *self,
|
||||
GtkAccessibleState state);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accessible_reset_property (GtkAccessible *self,
|
||||
GtkAccessibleProperty property);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accessible_reset_relation (GtkAccessible *self,
|
||||
GtkAccessibleRelation relation);
|
||||
|
||||
G_END_DECLS
|
||||
|
Loading…
Reference in New Issue
Block a user