From e12e13eb0eabdc8dfbe99e958380df6779473c27 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 18 Jan 2009 19:43:07 +0000 Subject: [PATCH] Make EvDocumentInfo and enums definded in ev-document-info.h GTypes. Fixes 2009-01-18 Tomeu Vizoso * 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 | 12 ++++++ libdocument/Makefile.am | 19 +++++++++ libdocument/ev-document-info.h | 18 ++++---- .../ev-document-type-builtins.c.template | 42 +++++++++++++++++++ .../ev-document-type-builtins.h.template | 25 +++++++++++ libdocument/ev-document.c | 42 +++++++++++++++++++ 6 files changed, 151 insertions(+), 7 deletions(-) create mode 100644 libdocument/ev-document-type-builtins.c.template create mode 100644 libdocument/ev-document-type-builtins.h.template diff --git a/ChangeLog b/ChangeLog index 69550d02..ea430b6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2009-01-18 Tomeu Vizoso + + * 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 * shell/main.c (arguments_parse): Fix for a minor code typo. diff --git a/libdocument/Makefile.am b/libdocument/Makefile.am index 4ce98465..a8f33ad4 100644 --- a/libdocument/Makefile.am +++ b/libdocument/Makefile.am @@ -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 diff --git a/libdocument/ev-document-info.h b/libdocument/ev-document-info.h index b5e86543..c27f63a3 100644 --- a/libdocument/ev-document-info.h +++ b/libdocument/ev-document-info.h @@ -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 index 00000000..19968389 --- /dev/null +++ b/libdocument/ev-document-type-builtins.c.template @@ -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 index 00000000..91e3e61a --- /dev/null +++ b/libdocument/ev-document-type-builtins.h.template @@ -0,0 +1,25 @@ +/*** BEGIN file-header ***/ + +#ifndef EV_DOCUMENT_TYPE_BUILTINS_H +#define EV_DOCUMENT_TYPE_BUILTINS_H + +#include + +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 ***/ diff --git a/libdocument/ev-document.c b/libdocument/ev-document.c index 4ffd41c9..1ca362e0 100644 --- a/libdocument/ev-document.c +++ b/libdocument/ev-document.c @@ -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) { -- 2.43.5