]> www.fi.muni.cz Git - evince.git/blobdiff - libdocument/ev-document.h
Added Asturian translation on behalf of Mikel González
[evince.git] / libdocument / ev-document.h
index cfcccdbec72be67bbbc090aabf8e4ba8ac1c4358..3ab918adb6f6724e20a1c3d2c099a1efcf601ebe 100644 (file)
  *  $Id$
  */
 
+#if !defined (__EV_EVINCE_DOCUMENT_H_INSIDE__) && !defined (EVINCE_COMPILATION)
+#error "Only <evince-document.h> can be included directly."
+#endif
+
 #ifndef EV_DOCUMENT_H
 #define EV_DOCUMENT_H
 
@@ -101,11 +105,13 @@ GQuark           ev_document_error_quark      (void);
 GMutex          *ev_document_get_doc_mutex    (void);
 void             ev_document_doc_mutex_lock   (void);
 void             ev_document_doc_mutex_unlock (void);
+gboolean         ev_document_doc_mutex_trylock(void);
 
 /* FontConfig mutex */
 GMutex          *ev_document_get_fc_mutex     (void);
 void             ev_document_fc_mutex_lock    (void);
 void             ev_document_fc_mutex_unlock  (void);
+gboolean         ev_document_fc_mutex_trylock (void);
 
 EvDocumentInfo  *ev_document_get_info         (EvDocument      *document);
 gboolean         ev_document_load             (EvDocument      *document,
@@ -176,7 +182,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 */                                       \
@@ -214,6 +220,56 @@ 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 <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 */