Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/libdocument/ev-document.h
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2009-01-24 18:10:33 (GMT)
committer Carlos Garcia Campos <carlosgc@src.gnome.org>2009-01-24 18:10:33 (GMT)
commitab26fbf217460c766111850bf40725e5e65a5533 (patch)
tree2ed6ef16498d2b54292608e98796d7ecddfacc6f /libdocument/ev-document.h
parent95395e6b0e5e174a43931605043dba668232d331 (diff)
Add EV_DEFINE_INTERFACE macro.
2009-01-24 Carlos Garcia Campos <carlosgc@gnome.org> * libdocument/ev-document.h: Add EV_DEFINE_INTERFACE macro. * libdocument/ev-async-renderer.c: * libdocument/ev-document-find.c: * libdocument/ev-document-fonts.c: * libdocument/ev-document-forms.c: * libdocument/ev-document-images.c: * libdocument/ev-document-layers.c: * libdocument/ev-document-links.c: * libdocument/ev-document-security.c: * libdocument/ev-document-thumbnails.c: * libdocument/ev-document-transition.c: * libdocument/ev-document.c: * libdocument/ev-file-exporter.c: * libdocument/ev-selection.c: Use EV_DEFINE_INTERFACE macro to define interfaces in libdocument. See bug #568228. svn path=/trunk/; revision=3379
Diffstat (limited to 'libdocument/ev-document.h')
-rw-r--r--libdocument/ev-document.h32
1 files changed, 31 insertions, 1 deletions
diff --git a/libdocument/ev-document.h b/libdocument/ev-document.h
index e07e3a2..7cb6d84 100644
--- a/libdocument/ev-document.h
+++ b/libdocument/ev-document.h
@@ -234,8 +234,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 <literal>t_n ## _default_init</literal>, and the interface
+ * structure to have the name <literal>TN ## Interface</literal>.
+ */
+#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 */