X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=libdocument%2Fev-document.h;h=5afdb035166e60951bc0dc9a6b6fa00464da96dc;hb=776a6fe02961d8901d21e172633d3c8d1c85dc93;hp=367d6e6af39a518ab304fc98954c3ef05aeb8e9b;hpb=e71d27db284ccf431167816167bf72f1e23c334d;p=evince.git diff --git a/libdocument/ev-document.h b/libdocument/ev-document.h index 367d6e6a..5afdb035 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 @@ -60,12 +64,7 @@ typedef struct { double y; } EvPoint; -typedef struct { - double x1; - double y1; - double x2; - double y2; -} EvRectangle; +typedef struct _EvRectangle EvRectangle; struct _EvDocumentIface { @@ -133,6 +132,20 @@ cairo_surface_t *ev_document_render (EvDocument *document, gint ev_rect_cmp (EvRectangle *a, EvRectangle *b); +#define EV_TYPE_RECTANGLE (ev_rectangle_get_type ()) +struct _EvRectangle +{ + gdouble x1; + gdouble y1; + gdouble x2; + gdouble y2; +}; + +GType ev_rectangle_get_type (void) G_GNUC_CONST; +EvRectangle *ev_rectangle_new (void); +EvRectangle *ev_rectangle_copy (EvRectangle *ev_rect); +void ev_rectangle_free (EvRectangle *ev_rect); + /* convenience macro to ease interface addition in the CODE * section of EV_BACKEND_REGISTER_WITH_CODE (this macro relies on * the g_define_type_id present within EV_BACKEND_REGISTER_WITH_CODE()). @@ -178,7 +191,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 */ \ @@ -216,6 +229,75 @@ register_evince_backend (GTypeModule *module) \ #define EV_BACKEND_REGISTER(BackendName, backend_name) \ EV_BACKEND_REGISTER_WITH_CODE(BackendName, backend_name, ;) +/* + * A convenience macro for boxed type implementations, which defines a + * type_name_get_type() function registering the boxed type. + */ +#define EV_DEFINE_BOXED_TYPE(TypeName, type_name, copy_func, free_func) \ +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_boxed_type_register_static (g_intern_static_string (#TypeName), \ + (GBoxedCopyFunc) copy_func, \ + (GBoxedFreeFunc) free_func); \ + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \ + } \ + 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; \ +} + +/* + * A convenience macro for boxed type implementations, which defines a + * type_name_get_type() function registering the boxed type. + */ +#define EV_DEFINE_BOXED_TYPE(TypeName, type_name, copy_func, free_func) \ +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_boxed_type_register_static (g_intern_static_string (#TypeName), \ + (GBoxedCopyFunc) copy_func, \ + (GBoxedFreeFunc) free_func); \ + 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 */