ATK Implemetation for a Specific 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:

例 1-5Sample 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:

例 1-6Connecting 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.