ATK Implemetation for a Specific Object
- GNOME Accessibility Developers Guide
- What is Accessibility?
- Examples that Use the Accessibility API
- Implementing an ATK Object
All GObjects implement a get_type() function. Using the above example the naming convention for this function name would be myatkimp_mytype_get_type().
In this function, you specify which interfaces your object implements. If the following logic were included in this get_type() function, this object would implement the ATK_TEXT interface:
Primer 1-5 Sample get_type() function
static const GInterfaceInfo atk_text_info = { (GInterfaceInitFunc) atk_text_interface_init, (GInterfaceFinalizeFunc) NULL, NULL }; g_type_add_interface_static (type, ATK_TYPE_TEXT, &atk_text_info);
The function atk_text_interface_init(), which has the following prototype, would need to be implemented:
void atk_text_interface_init (AtkTextIface *iface);
This function would connect the interface function calls to the specific implementation as follows:
Primer 1-6 Connecting custom interface calls to an AtkObject implementation
void atk_text_interface_init (AtkTextIface *iface) { g_return_if_fail (iface != NULL); iface->get_text = myatkimp_mytype_get_text; iface->get_character_at_offset = myatkimp_mytype_get_character_at_offset; ... }
Then the functions myatkimp_mytype_get_text(), myatkimp_mytype_get_character_at_offset(), and the rest of the ATK_TEXT interface functions would need to be implemented.