API: Add gtk_widget_class_set_accessible_role()
Easy access to modifying the roles of subclasses, as this is a thing that commonly changes for various subclasses.
This commit is contained in:
@ -5052,6 +5052,7 @@ gtk_widget_style_get_property
|
||||
gtk_widget_style_get_valist
|
||||
gtk_widget_style_attach
|
||||
gtk_widget_class_set_accessible_type
|
||||
gtk_widget_class_set_accessible_role
|
||||
gtk_widget_get_accessible
|
||||
gtk_widget_child_focus
|
||||
gtk_widget_child_notify
|
||||
|
||||
@ -3464,6 +3464,7 @@ gtk_widget_class_install_style_property
|
||||
gtk_widget_class_install_style_property_parser
|
||||
gtk_widget_class_list_style_properties
|
||||
gtk_widget_class_path
|
||||
gtk_widget_class_set_accessible_role
|
||||
gtk_widget_class_set_accessible_type
|
||||
gtk_widget_compute_expand
|
||||
gtk_widget_create_pango_context
|
||||
|
||||
@ -409,6 +409,7 @@ struct _GtkWidgetPrivate
|
||||
struct _GtkWidgetClassPrivate
|
||||
{
|
||||
GType accessible_type;
|
||||
AtkRole accessible_role;
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -937,6 +938,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
|
||||
/* Accessibility support */
|
||||
klass->priv->accessible_type = GTK_TYPE_ACCESSIBLE;
|
||||
klass->priv->accessible_role = ATK_ROLE_INVALID;
|
||||
klass->get_accessible = gtk_widget_real_get_accessible;
|
||||
|
||||
klass->adjust_size_request = gtk_widget_real_adjust_size_request;
|
||||
@ -11942,6 +11944,40 @@ gtk_widget_class_set_accessible_type (GtkWidgetClass *widget_class,
|
||||
priv->accessible_type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_class_set_accessible_role:
|
||||
* @widget_class: class to set the accessible role for
|
||||
* @role: The role to use for accessibles created for @widget_class
|
||||
*
|
||||
* Sets the default #AtkRole to be set on accessibles created for
|
||||
* widgets of @widget_class. Accessibles may decide to not honor this
|
||||
* setting if their role reporting is more refined.
|
||||
*
|
||||
* In cases where you want more fine-grained control over the role of
|
||||
* accessibles created for @widget_class, you should provide your own
|
||||
* accessible type and use gtk_widget_class_set_accessible_type()
|
||||
* instead.
|
||||
*
|
||||
* If @role is #ATK_ROLE_INVALID, the default role will not be changed
|
||||
* and the accessible's default role will be used instead.
|
||||
*
|
||||
* This function should only be called from class init functions of widgets.
|
||||
*
|
||||
* Since: 3.2
|
||||
**/
|
||||
void
|
||||
gtk_widget_class_set_accessible_role (GtkWidgetClass *widget_class,
|
||||
AtkRole role)
|
||||
{
|
||||
GtkWidgetClassPrivate *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET_CLASS (widget_class));
|
||||
|
||||
priv = widget_class->priv;
|
||||
|
||||
priv->accessible_role = role;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_get_accessible:
|
||||
* @widget: a #GtkWidget
|
||||
@ -11986,12 +12022,14 @@ gtk_widget_real_get_accessible (GtkWidget *widget)
|
||||
if (!accessible)
|
||||
{
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkWidgetClassPrivate *priv;
|
||||
AtkObjectFactory *factory;
|
||||
AtkRegistry *default_registry;
|
||||
|
||||
widget_class = GTK_WIDGET_GET_CLASS (widget);
|
||||
priv = widget_class->priv;
|
||||
|
||||
if (widget_class->priv->accessible_type == GTK_TYPE_ACCESSIBLE)
|
||||
if (priv->accessible_type == GTK_TYPE_ACCESSIBLE)
|
||||
{
|
||||
default_registry = atk_get_default_registry ();
|
||||
factory = atk_registry_get_factory (default_registry,
|
||||
@ -12002,10 +12040,13 @@ gtk_widget_real_get_accessible (GtkWidget *widget)
|
||||
}
|
||||
else
|
||||
{
|
||||
accessible = g_object_new (widget_class->priv->accessible_type, NULL);
|
||||
accessible = g_object_new (priv->accessible_type, NULL);
|
||||
atk_object_initialize (accessible, widget);
|
||||
}
|
||||
|
||||
if (priv->accessible_role != ATK_ROLE_INVALID)
|
||||
atk_object_set_role (accessible, priv->accessible_role);
|
||||
|
||||
g_object_set_qdata (G_OBJECT (widget),
|
||||
quark_accessible_object,
|
||||
accessible);
|
||||
|
||||
@ -724,6 +724,8 @@ void gtk_widget_set_support_multidevice (GtkWidget *widget,
|
||||
/* Accessibility support */
|
||||
void gtk_widget_class_set_accessible_type (GtkWidgetClass *widget_class,
|
||||
GType type);
|
||||
void gtk_widget_class_set_accessible_role (GtkWidgetClass *widget_class,
|
||||
AtkRole role);
|
||||
AtkObject* gtk_widget_get_accessible (GtkWidget *widget);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user