]> www.fi.muni.cz Git - evince.git/commitdiff
Add EV_DEFINE_INTERFACE macro.
authorCarlos Garcia Campos <carlosgc@gnome.org>
Sat, 24 Jan 2009 18:10:33 +0000 (18:10 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Sat, 24 Jan 2009 18:10:33 +0000 (18:10 +0000)
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

15 files changed:
ChangeLog
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-document.h
libdocument/ev-file-exporter.c
libdocument/ev-selection.c

index 6ea1dadcb6e077d727f18fd8e55990ddf267b606..6edefe1316f2d79fdb625ee4dce7583bbcd6170a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+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]:
index f0ffce486f1f91b57649b4cf51d61159df835b76..5ff9e3eda4c95ed3642164451112435f5bc69b10 100644 (file)
@@ -21,8 +21,7 @@
 #include "config.h"
 
 #include "ev-async-renderer.h"
-
-static void ev_async_renderer_class_init (gpointer g_class);
+#include "ev-document.h"
 
 enum
 {
@@ -32,42 +31,26 @@ 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
index 59b8755a700959812e2bfa4b543eab741fe41d5e..bba5ea3d54f6b992cf71e358154d29aea2cf02f1 100644 (file)
 
 #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 *
index 929c21df3ef0d6c4f126dafa34998d91efb1fdd8..d53a86feae63ae6a02c9ddbd7b701dd1f3e09f19 100644 (file)
 
 #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
index d5d9c7094361834862a515ee5d20d81dcb96be65..6d702a3fa74704e7311ecfa5248ae5961e5fbc8b 100644 (file)
 #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 *
index 874a24da7c0851860714753c1c7ca049dd425043..1754ded2f4fe0a5e0591f116c6ae69136705bd47 100644 (file)
 #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 *
index f203565ea47a040520601a0f24e0ba295b091edc..909dbdaa39bd48a52dedb12f1650a78a2dbb3826 100644 (file)
 #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
index c7170963ea67bb8fd7fb7a079c92e4adfc63e0fa..d74804b020c69f2751bb901199ce7487e6fb8cfd 100644 (file)
 
 #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
index 49ded87365ea75046bba774fcac312ccb35aa436..1e9ed8ba8a383b9a40455fde25f21e8fc37ff9cd 100644 (file)
 
 #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
index 2e73af6201b24bfae7f4f9db9786bfcb908b862c..d51302ac9da65bf5c9af014717ea51940db13117 100644 (file)
 
 #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 *
index c8d136a2d2e8cef320567c04dd662117eb1fe783..495b1b9625451ccc955c0ab658038df5ffbd58f7 100644 (file)
 #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
index 163f2e266caa8c17d982ecd025d658c573e444d7..aa7d1d2e70ff362ed38ebaff0de0d5d96d2009d0 100644 (file)
 
 #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)
@@ -64,7 +38,7 @@ ev_document_error_quark (void)
 }
 
 static void
-ev_document_class_init (gpointer g_class)
+ev_document_class_init (EvDocumentIface *klass)
 {
 }
 
index e07e3a22a8a5e99a17c8c68aa59ea176669a4632..7cb6d8470551f96e4b5f6574d51dde3ef5dc3278 100644 (file)
@@ -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 */
index c74869fc76d98156b95c45db495dd4f18ec6251c..43f563bf143cfa1333df25e60085bd06c0a062c8 100644 (file)
 
 #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
index 9a7336c63765ed46e0ed18289e36668687fbc355..c19ac2a36a15938d041fc45b99ca38f7edf704fb 100644 (file)
 
 #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,