Class/Instance Initializers
- GNOME Accessibility Developers Guide
- What is Accessibility?
- Examples that Use the Accessibility API
- Implementing an ATK Object
You will have to set up a class initializer for the GObject if your AtkObject implementation either:
-
Redefines any function calls defined by the object's parent. This is typically necessary when an object needs to implement a function like atk_object_get_n_accessible_children(). This is necessary if the object has children, but they are not represented with widgets.
-
Requires a parent->init, parent->notify_gtk, or parent->finalize function.
-
parent->init
A parent->init() function may be necessary if the ATK implementation needs to do either of the following:
- Cache any data obtained from a backing GTK widget.
- Listen to any signals from the backing GTK widget.
-
parent->notify_gtk
If the ATK implementation needs to listen to any property notifications on the backing GTK object, a parent->notify_gtk() function may be necessary. For example:
Example 1-7 A custom notify_gtk() functionvoid myatkimp_mytype_real_notify_gtk (GObject *obj, GParamSpec *pspec) { GtkWidget *widget = GTK_WIDGET (obj); AtkObject* atk_obj = gtk_widget_get_accessible (widget); if (strcmp (pspec->name, "property-of-interest") == 0) { /* Handle the property change. */ } else { parent_class->notify_gtk (obj, pspec); } }
-
parent->finalize
If it is necessary to free any data when a GObject instance is destroyed, then a finalize() function is needed to free the memory. For example:
Example 1-8 A custom finalize() functionvoid myatkimp_mytype_finalize (GObject *object) { MyAtkimpMyType *my_type = MYATKIMP_MYTYPE (object); g_object_unref (my_type->cached_value); G_OBJECT_CLASS (parent_class)->finalize (object); }
-