+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.
+
2009-01-24 Carlos Garcia Campos <carlosgc@gnome.org>
* libdocument/ev-document.[ch]:
#include "config.h"
#include "ev-async-renderer.h"
-
-static void ev_async_renderer_class_init (gpointer g_class);
+#include "ev-document.h"
enum
{
static guint signals[LAST_SIGNAL] = { 0 };
-GType
-ev_async_renderer_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- const GTypeInfo our_info =
- {
- sizeof (EvAsyncRendererIface),
- NULL,
- NULL,
- (GClassInitFunc)ev_async_renderer_class_init
- };
-
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EvAsyncRenderer",
- &our_info, (GTypeFlags)0);
- }
-
- return type;
-}
+EV_DEFINE_INTERFACE (EvAsyncRenderer, ev_async_renderer, 0)
static void
-ev_async_renderer_class_init (gpointer g_class)
+ev_async_renderer_class_init (EvAsyncRendererIface *klass)
{
- signals[RENDER_FINISHED] =
- g_signal_new ("render_finished",
- EV_TYPE_ASYNC_RENDERER,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EvAsyncRendererIface, render_finished),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- GDK_TYPE_PIXBUF);
+ static gboolean initialized = FALSE;
+
+ if (!initialized) {
+ signals[RENDER_FINISHED] =
+ g_signal_new ("render_finished",
+ EV_TYPE_ASYNC_RENDERER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EvAsyncRendererIface, render_finished),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE,
+ 1,
+ GDK_TYPE_PIXBUF);
+ initialized = TRUE;
+ }
}
void
#include "ev-document-find.h"
-GType
-ev_document_find_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- const GTypeInfo our_info =
- {
- sizeof (EvDocumentFindIface),
- NULL,
- NULL,
- };
+EV_DEFINE_INTERFACE (EvDocumentFind, ev_document_find, 0)
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EvDocumentFind",
- &our_info, (GTypeFlags)0);
- }
-
- return type;
+static void
+ev_document_find_class_init (EvDocumentFindIface *klass)
+{
}
GList *
#include "ev-document-fonts.h"
-GType
-ev_document_fonts_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- const GTypeInfo our_info =
- {
- sizeof (EvDocumentFontsIface),
- NULL,
- NULL,
- };
+EV_DEFINE_INTERFACE (EvDocumentFonts, ev_document_fonts, 0)
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EvDocumentFonts",
- &our_info, (GTypeFlags)0);
- }
-
- return type;
+static void
+ev_document_fonts_class_init (EvDocumentFontsIface *klass)
+{
}
double
#include <config.h>
#include "ev-document-forms.h"
-GType
-ev_document_forms_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- const GTypeInfo our_info = {
- sizeof (EvDocumentFormsIface),
- NULL,
- NULL,
- };
+EV_DEFINE_INTERFACE (EvDocumentForms, ev_document_forms, 0)
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EvDocumentForms",
- &our_info, (GTypeFlags)0);
- }
-
- return type;
+static void
+ev_document_forms_class_init (EvDocumentFormsIface *klass)
+{
}
GList *
#include <config.h>
#include "ev-document-images.h"
-GType
-ev_document_images_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- const GTypeInfo our_info = {
- sizeof (EvDocumentImagesIface),
- NULL,
- NULL,
- };
+EV_DEFINE_INTERFACE (EvDocumentImages, ev_document_images, 0)
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EvDocumentImages",
- &our_info, (GTypeFlags)0);
- }
-
- return type;
+static void
+ev_document_images_class_init (EvDocumentImagesIface *klass)
+{
}
GList *
#include "config.h"
#include "ev-document-layers.h"
+#include "ev-document.h"
-GType
-ev_document_layers_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- const GTypeInfo our_info = {
- sizeof (EvDocumentLayersIface),
- NULL,
- NULL,
- };
+EV_DEFINE_INTERFACE (EvDocumentLayers, ev_document_layers, 0)
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EvDocumentLayers",
- &our_info, (GTypeFlags)0);
- }
-
- return type;
+static void
+ev_document_layers_class_init (EvDocumentLayersIface *klass)
+{
}
gboolean
#include "ev-document-links.h"
-GType
-ev_document_links_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- const GTypeInfo our_info = {
- sizeof (EvDocumentLinksIface),
- NULL,
- NULL,
- };
+EV_DEFINE_INTERFACE (EvDocumentLinks, ev_document_links, 0)
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EvDocumentLinks",
- &our_info, (GTypeFlags)0);
- }
-
- return type;
+static void
+ev_document_links_class_init (EvDocumentLinksIface *klass)
+{
}
gboolean
#include "ev-document-security.h"
-GType
-ev_document_security_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- const GTypeInfo our_info =
- {
- sizeof (EvDocumentSecurityIface),
- NULL,
- NULL,
- };
-
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EvDocumentSecurity",
- &our_info, (GTypeFlags)0);
- }
+EV_DEFINE_INTERFACE (EvDocumentSecurity, ev_document_security, 0)
- return type;
+static void
+ev_document_security_class_init (EvDocumentSecurityIface *klass)
+{
}
gboolean
#include <config.h>
#include "ev-document-thumbnails.h"
+#include "ev-document.h"
-GType
-ev_document_thumbnails_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- const GTypeInfo our_info =
- {
- sizeof (EvDocumentThumbnailsIface),
- NULL,
- NULL,
- };
+EV_DEFINE_INTERFACE (EvDocumentThumbnails, ev_document_thumbnails, 0)
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EvDocumentThumbnails",
- &our_info, (GTypeFlags)0);
- }
-
- return type;
+static void
+ev_document_thumbnails_class_init (EvDocumentThumbnailsIface *klass)
+{
}
GdkPixbuf *
#include <config.h>
#include "ev-document-transition.h"
-GType
-ev_document_transition_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- const GTypeInfo our_info = {
- sizeof (EvDocumentTransitionIface),
- NULL,
- NULL,
- };
+EV_DEFINE_INTERFACE (EvDocumentTransition, ev_document_transition, 0)
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EvDocumentTransition",
- &our_info, (GTypeFlags)0);
- }
-
- return type;
+static void
+ev_document_transition_class_init (EvDocumentTransitionIface *klass)
+{
}
gdouble
#include "ev-document.h"
-static void ev_document_class_init (gpointer g_class);
-
-
GMutex *ev_doc_mutex = NULL;
GMutex *ev_fc_mutex = NULL;
-GType
-ev_document_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- const GTypeInfo our_info =
- {
- sizeof (EvDocumentIface),
- NULL,
- NULL,
- (GClassInitFunc)ev_document_class_init
- };
-
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EvDocument",
- &our_info, (GTypeFlags)0);
-
- g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
- }
-
- return type;
-}
+EV_DEFINE_INTERFACE (EvDocument, ev_document, G_TYPE_OBJECT)
GQuark
ev_document_error_quark (void)
}
static void
-ev_document_class_init (gpointer g_class)
+ev_document_class_init (EvDocumentIface *klass)
{
}
} \
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 */
#include <config.h>
#include "ev-file-exporter.h"
+#include "ev-document.h"
-GType
-ev_file_exporter_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- const GTypeInfo our_info =
- {
- sizeof (EvFileExporterIface),
- NULL,
- NULL,
- };
+EV_DEFINE_INTERFACE (EvFileExporter, ev_file_exporter, 0)
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EvFileExporter",
- &our_info, (GTypeFlags)0);
- }
-
- return type;
+static void
+ev_file_exporter_class_init (EvFileExporterIface *klass)
+{
}
void
#include "ev-selection.h"
-static void ev_selection_base_init (gpointer g_class);
-
-GType
-ev_selection_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- const GTypeInfo our_info =
- {
- sizeof (EvSelectionIface),
- ev_selection_base_init,
- NULL,
- };
-
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EvSelection",
- &our_info, (GTypeFlags)0);
- }
-
- return type;
-}
+EV_DEFINE_INTERFACE (EvSelection, ev_selection, 0)
static void
-ev_selection_base_init (gpointer g_class)
+ev_selection_class_init (EvSelectionIface *klass)
{
- static gboolean initialized = FALSE;
-
- if (!initialized) {
- }
}
-
void
ev_selection_render_selection (EvSelection *selection,
EvRenderContext *rc,