X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=libdocument%2Fev-document.h;h=3ab918adb6f6724e20a1c3d2c099a1efcf601ebe;hb=7d8aa7727a74f84c6fc473dbe87a923fd2c25959;hp=e07e3a22a8a5e99a17c8c68aa59ea176669a4632;hpb=95395e6b0e5e174a43931605043dba668232d331;p=evince.git diff --git a/libdocument/ev-document.h b/libdocument/ev-document.h index e07e3a22..3ab918ad 100644 --- a/libdocument/ev-document.h +++ b/libdocument/ev-document.h @@ -19,6 +19,10 @@ * $Id$ */ +#if !defined (__EV_EVINCE_DOCUMENT_H_INSIDE__) && !defined (EVINCE_COMPILATION) +#error "Only can be included directly." +#endif + #ifndef EV_DOCUMENT_H #define EV_DOCUMENT_H @@ -178,7 +182,7 @@ static void backend_name##_class_intern_init (gpointer klass) \ G_MODULE_EXPORT GType \ register_evince_backend (GTypeModule *module) \ { \ - static const GTypeInfo our_info = { \ + const GTypeInfo our_info = { \ sizeof (BackendName##Class), \ NULL, /* base_init */ \ NULL, /* base_finalize */ \ @@ -234,8 +238,38 @@ type_name##_get_type (void) } \ return g_define_type_id__volatile; \ } - +/* A convenience macro for GTypeInterface definitions, which declares + * a default vtable initialization function and defines a *_get_type() + * function. + * + * The macro expects the interface initialization function to have the + * name t_n ## _default_init, and the interface + * structure to have the name TN ## Interface. + */ +#define EV_DEFINE_INTERFACE(TypeName, type_name, TYPE_PREREQ) \ +static void type_name##_class_init (TypeName##Iface *klass); \ + \ +GType \ +type_name##_get_type (void) \ +{ \ + static volatile gsize g_define_type_id__volatile = 0; \ + if (g_once_init_enter (&g_define_type_id__volatile)) { \ + GType g_define_type_id = \ + g_type_register_static_simple (G_TYPE_INTERFACE, \ + g_intern_static_string (#TypeName), \ + sizeof (TypeName##Iface), \ + (GClassInitFunc)type_name##_class_init, \ + 0, \ + (GInstanceInitFunc)NULL, \ + (GTypeFlags) 0); \ + if (TYPE_PREREQ) \ + g_type_interface_add_prerequisite (g_define_type_id, TYPE_PREREQ); \ + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \ + } \ + return g_define_type_id__volatile; \ +} + G_END_DECLS #endif /* EV_DOCUMENT_H */