AtkObject 구현
AtkObject는 GObjects이며, 모든 GObject는 get_type() 함수를 지정해야합니다. 클래스 및 인스턴스 초기화 처리자를 설정하는 예제를 보여드리겠습니다. 여기서 get_type() 함수는 ATK_TEXT 객체 구현체를 지정하며, MYATKIMP_MYPARENTTYPE이 될 상위 객체도 지정합니다.
예제 1-7 get_type() 구현 예제
GType myatkimp_mytype_get_type (void) { static GType type = 0; if (!type) { static const GTypeInfo tinfo = { sizeof (GailLabelClass), (GBaseInitFunc) NULL, /* base init */ (GBaseFinalizeFunc) NULL, /* base finalize */ (GClassInitFunc) myatkimp_mytype_class_init, /* class init */ (GClassFinalizeFunc) NULL, /* class finalize */ NULL, /* class data */ sizeof (GailLabel), /* instance size */ 0, /* nb preallocs */ (GInstanceInitFunc) myatkimp_mytype_instance_init, /* instance init */ NULL /* value table */ }; /* Set up atk_text_info structure used below */ static const GInterfaceInfo atk_text_info = { (GInterfaceInitFunc) atk_text_interface_init, (GInterfaceFinalizeFunc) NULL, NULL }; /* Set up typename and specify parent type */ type = g_type_register_static (MYATKIMP_MYPARENTTYPE, "MyatkimpMytype", &tinfo, 0); /* This class implements interface ATK_TYPE_TEXT */ g_type_add_interface_static (type, ATK_TYPE_TEXT, &atk_text_info); } return type; }