]> www.fi.muni.cz Git - evince.git/commitdiff
Make EvDocumentInfo and enums definded in ev-document-info.h GTypes. Fixes
authorTomeu Vizoso <tomeu@sugarlabs.org>
Sun, 18 Jan 2009 19:43:07 +0000 (19:43 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Sun, 18 Jan 2009 19:43:07 +0000 (19:43 +0000)
2009-01-18  Tomeu Vizoso  <tomeu@sugarlabs.org>

* libdocument/Makefile.am:
* libdocument/ev-document-info.h:
* libdocument/ev-document-type-builtins.c.template:
* libdocument/ev-document-type-builtins.h.template:
* libdocument/ev-document.c: (ev_document_info_get_type),
(ev_document_info_copy):

Make EvDocumentInfo and enums definded in ev-document-info.h
GTypes. Fixes bug #567789.

svn path=/trunk/; revision=3356

ChangeLog
libdocument/Makefile.am
libdocument/ev-document-info.h
libdocument/ev-document-type-builtins.c.template [new file with mode: 0644]
libdocument/ev-document-type-builtins.h.template [new file with mode: 0644]
libdocument/ev-document.c

index 69550d02ab887a5d1cd2fc960dc23ec58dc07adf..ea430b6ca69fffda05f140d25078db7dd7d311ec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-01-18  Tomeu Vizoso  <tomeu@sugarlabs.org>
+
+       * libdocument/Makefile.am:
+       * libdocument/ev-document-info.h:
+       * libdocument/ev-document-type-builtins.c.template:
+       * libdocument/ev-document-type-builtins.h.template:
+       * libdocument/ev-document.c: (ev_document_info_get_type),
+       (ev_document_info_copy):
+
+       Make EvDocumentInfo and enums definded in ev-document-info.h
+       GTypes. Fixes bug #567789.
+       
 2009-01-18  Michal Vaner <vorner+evince@ucw.cz>
 
        * shell/main.c (arguments_parse): Fix for a minor code typo.
index 4ce98465c723f91646e05ce246e91902be64a662..a8f33ad485299089760a6ca11f072ab15438f603 100644 (file)
@@ -15,6 +15,7 @@ NOINST_H_FILES =                              \
        ev-backends-manager.h                   \
        ev-debug.h                              \
        ev-document-factory.h                   \
+       ev-document-type-builtins.h             \
        ev-module.h
 
 INST_H_FILES =                                         \
@@ -68,6 +69,7 @@ libevbackend_la_SOURCES=                      \
        ev-document-find.c                      \
        ev-document-transition.c                \
        ev-document-forms.c                     \
+       ev-document-type-builtins.c             \
        ev-form-field.c                         \
        ev-debug.c                              \
        ev-file-exporter.c                      \
@@ -81,6 +83,23 @@ libevbackend_la_SOURCES=                     \
        $(NOINST_H_FILES)                       \
        $(INST_H_FILES)
 
+BUILT_SOURCES =                        \
+       ev-document-type-builtins.c     \
+       ev-document-type-builtins.h
 
+CLEANFILES = $(BUILT_SOURCES)
 
+ev-document-type-builtins.h: stamp-ev-document-type-builtins.h
+       @true
+
+stamp-ev-document-type-builtins.h: ev-document-type-builtins.h.template ev-document-info.h
+       $(GLIB_MKENUMS) --template $< $(filter-out $<,$^) > xgen-etbh \
+       && (cmp -s xgen-etbh ev-document-type-builtins.h || cp xgen-etbh ev-document-type-builtins.h ) \
+       && rm -f xgen-etbh \
+       && echo timestamp > $(@F)
+
+ev-document-type-builtins.c: ev-document-type-builtins.c.template ev-document-info.h
+       $(GLIB_MKENUMS) --template $< $(filter-out $<,$^) > xgen-etbc \
+       && (cmp -s xgen-etbc ev-document-type-builtins.c || cp xgen-etbc ev-document-type-builtins.c ) \
+       && rm -f xgen-etbc
 
index b5e865430fb6b9019fbd489aa13ebe52471a516d..c27f63a37a34d72f8b910e1672deb24756ca56a0 100644 (file)
@@ -35,7 +35,7 @@ typedef enum
        EV_DOCUMENT_LAYOUT_TWO_COLUMN_LEFT,
        EV_DOCUMENT_LAYOUT_TWO_COLUMN_RIGHT,
        EV_DOCUMENT_LAYOUT_TWO_PAGE_LEFT,
-       EV_DOCUMENT_LAYOUT_TWO_PAGE_RIGHT,
+       EV_DOCUMENT_LAYOUT_TWO_PAGE_RIGHT
 } EvDocumentLayout;
 
 typedef enum
@@ -56,9 +56,14 @@ typedef enum
        EV_DOCUMENT_UI_HINT_FIT_WINDOW = 1 << 3,
        EV_DOCUMENT_UI_HINT_CENTER_WINDOW = 1 << 4,
        EV_DOCUMENT_UI_HINT_DISPLAY_DOC_TITLE = 1 << 5,
-       EV_DOCUMENT_UI_HINT_DIRECTION_RTL = 1 << 6,
+       EV_DOCUMENT_UI_HINT_DIRECTION_RTL = 1 << 6
 } EvDocumentUIHints;
 
+/* This define is needed because glib-mkenums chokes with multiple lines */
+#define PERMISSIONS_FULL (EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT  \
+                       | EV_DOCUMENT_PERMISSIONS_OK_TO_MODIFY \
+                       | EV_DOCUMENT_PERMISSIONS_OK_TO_COPY   \
+                       | EV_DOCUMENT_PERMISSIONS_OK_TO_ADD_NOTES)
 
 typedef enum
 {
@@ -66,10 +71,7 @@ typedef enum
        EV_DOCUMENT_PERMISSIONS_OK_TO_MODIFY = 1 << 1,
        EV_DOCUMENT_PERMISSIONS_OK_TO_COPY = 1 << 2,
        EV_DOCUMENT_PERMISSIONS_OK_TO_ADD_NOTES = 1 << 3,
-       EV_DOCUMENT_PERMISSIONS_FULL = (EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT
-                                       | EV_DOCUMENT_PERMISSIONS_OK_TO_MODIFY
-                                       | EV_DOCUMENT_PERMISSIONS_OK_TO_COPY
-                                       | EV_DOCUMENT_PERMISSIONS_OK_TO_ADD_NOTES),
+       EV_DOCUMENT_PERMISSIONS_FULL = PERMISSIONS_FULL
 } EvDocumentPermissions;
 
 typedef enum
@@ -118,7 +120,9 @@ struct _EvDocumentInfo
        guint fields_mask;
 };
 
-void ev_document_info_free (EvDocumentInfo *info);
+GType           ev_document_info_get_type (void) G_GNUC_CONST;
+EvDocumentInfo *ev_document_info_copy     (EvDocumentInfo *info);
+void            ev_document_info_free     (EvDocumentInfo *info);
 
 G_END_DECLS
 
diff --git a/libdocument/ev-document-type-builtins.c.template b/libdocument/ev-document-type-builtins.c.template
new file mode 100644 (file)
index 0000000..1996838
--- /dev/null
@@ -0,0 +1,42 @@
+/*** BEGIN file-header ***/
+#include "ev-document-type-builtins.h"
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+#include "@filename@"
+/*** END file-production ***/
+
+
+/*** BEGIN value-header ***/
+GType
+@enum_name@_get_type (void)
+{
+  static volatile gsize g_define_type_id__volatile = 0;
+  if (g_once_init_enter (&g_define_type_id__volatile)) {
+    static const G@Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+      { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+      { 0, NULL, NULL }
+    };
+    GType g_define_type_id = \
+       g_@type@_register_static (/* g_intern_static_string */ ("@EnumName@"), values);
+      
+    g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
+  }
+    
+  return g_define_type_id__volatile;
+}
+
+/*** END value-tail ***/
+
+/*** BEGIN file-tail ***/
+
+/*** END file-tail ***/
diff --git a/libdocument/ev-document-type-builtins.h.template b/libdocument/ev-document-type-builtins.h.template
new file mode 100644 (file)
index 0000000..91e3e61
--- /dev/null
@@ -0,0 +1,25 @@
+/*** BEGIN file-header ***/
+
+#ifndef EV_DOCUMENT_TYPE_BUILTINS_H
+#define EV_DOCUMENT_TYPE_BUILTINS_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define EV_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* !EV_DOCUMENT_TYPE_BUILTINS_H */
+/*** END file-tail ***/
index 4ffd41c989d81119a3abee15659e2e83a6a18224..1ca362e07c7f45355b0b0dc167d023641087ceba 100644 (file)
@@ -243,6 +243,48 @@ ev_document_render (EvDocument      *document,
        return retval;
 }
 
+/* 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;
+}
+
+EvDocumentInfo *
+ev_document_info_copy (EvDocumentInfo *info)
+{
+       EvDocumentInfo *copy;
+       
+       g_return_val_if_fail (info != NULL, NULL);
+
+       copy = g_new0 (EvDocumentInfo, 1);
+       copy->title = info->title ? g_strdup (info->title) : NULL;
+       copy->format = info->format ? g_strdup (info->format) : NULL;
+       copy->author = info->author ? g_strdup (info->author) : NULL;
+       copy->subject = info->subject ? g_strdup (info->subject) : NULL;
+       copy->keywords = info->keywords ? g_strdup (info->keywords) : NULL;
+       copy->security = info->security ? g_strdup (info->security) : NULL;
+       copy->creator = info->creator ? g_strdup (info->creator) : NULL;
+       copy->producer = info->producer ? g_strdup (info->producer) : NULL;
+       copy->linearized = info->linearized ? g_strdup (info->linearized) : NULL;
+       
+       copy->creation_date = info->creation_date;
+       copy->modified_date = info->modified_date;
+       copy->layout = info->layout;
+       copy->mode = info->mode;
+       copy->ui_hints = info->ui_hints;
+       copy->permissions = info->permissions;
+       copy->n_pages = info->n_pages;
+       copy->fields_mask = info->fields_mask;
+
+       return copy;
+}
+
 void
 ev_document_info_free (EvDocumentInfo *info)
 {