Implemented clutter_actor_get_accessible
authorAlejandro Piñeiro <apinheiro@igalia.com>
Mon, 12 Apr 2010 18:10:24 +0000 (20:10 +0200)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 24 May 2010 14:52:37 +0000 (15:52 +0100)
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
clutter/clutter-actor.h

index 93ad88f..efe22dd 100644 (file)
@@ -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 <ulink
+ * url="http://developer.gnome.org/doc/API/2.0/atk/index.html">ATK</ulink>
+ * 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
index b7ae817..7a3915a 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <glib-object.h>
 #include <pango/pango.h>
+#include <atk/atk.h>
 
 #include <clutter/clutter-color.h>
 #include <clutter/clutter-types.h>
@@ -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__ */