]> www.fi.muni.cz Git - evince.git/commitdiff
Add EV_DEFINE_BOXED_TYPE macro to define boxed types. See bug #568228.
authorCarlos Garcia Campos <carlosgc@gnome.org>
Sat, 24 Jan 2009 18:10:21 +0000 (18:10 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Sat, 24 Jan 2009 18:10:21 +0000 (18:10 +0000)
2009-01-24  Carlos Garcia Campos  <carlosgc@gnome.org>

* libdocument/ev-document.[ch]:

Add EV_DEFINE_BOXED_TYPE macro to define boxed types. See bug
#568228.

svn path=/trunk/; revision=3378

ChangeLog
libdocument/ev-document.c
libdocument/ev-document.h

index 3de2a6a43bc844a1eb0f5c210a031b8f6f073b38..6ea1dadcb6e077d727f18fd8e55990ddf267b606 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-01-24  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * libdocument/ev-document.[ch]:
+
+       Add EV_DEFINE_BOXED_TYPE macro to define boxed types. See bug
+       #568228.
+       
 2009-01-24  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
 
        * cut-n-paste/toolbar-editor/egg-editable-toolbar.c
@@ -19,7 +26,7 @@
        respecting umask and any setgid bit on the directory. Uses the new
        G_FILE_COPY_TARGET_DEFAULT_PERMS flag in glib 2.19.0, if available.
        Bug #568593.
-
+       
 2009-01-21  Christian Persch  <chpe@gnome.org>
 
        * configure.ac:
index 1ca362e07c7f45355b0b0dc167d023641087ceba..163f2e266caa8c17d982ecd025d658c573e444d7 100644 (file)
@@ -244,16 +244,7 @@ ev_document_render (EvDocument      *document,
 }
 
 /* EvDocumentInfo */
-GType
-ev_document_info_get_type (void)
-{
-       static GType type = 0;
-       if (type == 0)
-               type = g_boxed_type_register_static ("EvDocumentInfo",
-                                                    (GBoxedCopyFunc)ev_document_info_copy,
-                                                    (GBoxedFreeFunc)ev_document_info_free);
-       return type;
-}
+EV_DEFINE_BOXED_TYPE (EvDocumentInfo, ev_document_info, ev_document_info_copy, ev_document_info_free)
 
 EvDocumentInfo *
 ev_document_info_copy (EvDocumentInfo *info)
index 367d6e6af39a518ab304fc98954c3ef05aeb8e9b..e07e3a22a8a5e99a17c8c68aa59ea176669a4632 100644 (file)
@@ -216,6 +216,26 @@ 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;                                            \
+}
+
 G_END_DECLS
 
 #endif /* EV_DOCUMENT_H */