From 6a313ec2e2c227448ee83e6610ef78d1d0fe14a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= Date: Mon, 12 Apr 2010 20:10:24 +0200 Subject: [PATCH] Implemented clutter_actor_get_accessible Added the implementation for clutter_actor_get_accessible, virtual ClutterActor function, used to obtain the accessible object of any ClutterActor. As it is defined virtual, it would be possible to redefine it, so any custom clutter actor could implement their accessibility object, withouth relying totally on a accessibility implementation module. See gtkiconview as example. http://bugzilla.openedhand.com/show_bug.cgi?id=2070 --- clutter/clutter-actor.c | 45 +++++++++++++++++++++++++++++++++++++++++ clutter/clutter-actor.h | 10 ++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 93ad88f00..efe22dd19 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -3314,6 +3314,50 @@ clutter_actor_finalize (GObject *object) G_OBJECT_CLASS (clutter_actor_parent_class)->finalize (object); } + +/** + * clutter_actor_get_accessible: + * @actor: a #ClutterActor + * + * Returns the accessible object that describes the actor to an + * assistive technology. + * + * If no class-specific #AtkObject implementation is available for the + * actor instance in question, it will inherit an #AtkObject + * implementation from the first ancestor class for which such an + * implementation is defined. + * + * The documentation of the ATK + * library contains more information about accessible objects and + * their uses. + * + * Returns: (transfer none): the #AtkObject associated with @actor + */ +AtkObject* +clutter_actor_get_accessible (ClutterActor *actor) +{ + ClutterActorClass *klass; + + g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), NULL); + + klass = CLUTTER_ACTOR_GET_CLASS (actor); + + g_return_val_if_fail (klass->get_accessible != NULL, NULL); + + return klass->get_accessible (actor); +} + +static AtkObject* +clutter_actor_real_get_accessible (ClutterActor *actor) +{ + AtkObject* accessible; + + accessible = atk_gobject_accessible_for_object (G_OBJECT (actor)); + + return accessible; +} + static void clutter_actor_class_init (ClutterActorClass *klass) { @@ -4685,6 +4729,7 @@ clutter_actor_class_init (ClutterActorClass *klass) klass->queue_redraw = clutter_actor_real_queue_redraw; klass->queue_relayout = clutter_actor_real_queue_relayout; klass->apply_transform = clutter_actor_real_apply_transform; + klass->get_accessible = clutter_actor_real_get_accessible; } static void diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h index b7ae817a6..7a3915a02 100644 --- a/clutter/clutter-actor.h +++ b/clutter/clutter-actor.h @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -208,6 +209,8 @@ struct _ClutterActor * @apply_transform: virtual function, used when applying the transformations * to an actor before painting it or when transforming coordinates or * the allocation; it must chain up to the parent's implementation + * @get_accessible: virtual function, returns the accessible object that + * describes the actor to an assistive technology. * @parent_set: signal class handler for the #ClutterActor::parent-set * @destroy: signal class handler for #ClutterActor::destroy * @pick: virtual function, used to draw an outline of the actor with @@ -273,6 +276,9 @@ struct _ClutterActorClass void (* apply_transform) (ClutterActor *actor, CoglMatrix *matrix); + /* accessibility support */ + AtkObject* (*get_accessible) (ClutterActor *actor); + /* event signals */ gboolean (* event) (ClutterActor *actor, ClutterEvent *event); @@ -301,7 +307,7 @@ struct _ClutterActorClass /*< private >*/ /* padding for future expansion */ - gpointer _padding_dummy[31]; + gpointer _padding_dummy[30]; }; GType clutter_actor_get_type (void) G_GNUC_CONST; @@ -564,6 +570,8 @@ void clutter_actor_pop_internal (ClutterActor *sel gboolean clutter_actor_has_allocation (ClutterActor *self); +AtkObject* clutter_actor_get_accessible (ClutterActor *actor); + G_END_DECLS #endif /* __CLUTTER_ACTOR_H__ */