[evince/wip/chpe/issue-1711: 1/3] libdocument: Move EvDocumentInfo to its own file
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/chpe/issue-1711: 1/3] libdocument: Move EvDocumentInfo to its own file
- Date: Thu, 2 Dec 2021 17:35:29 +0000 (UTC)
commit 6a9cd96802cf2609941984a1bf5bb2584bd05e53
Author: Christian Persch <chpe src gnome org>
Date: Thu Dec 2 18:35:18 2021 +0100
libdocument: Move EvDocumentInfo to its own file
Move EvDocumentInfo and EvDocumentLicense into ev-document-info.c,
and add missing docs.
i
libdocument/ev-document-info.c | 189 +++++++++++++++++++++++++++++++++++++++++
libdocument/ev-document.c | 117 -------------------------
libdocument/meson.build | 1 +
3 files changed, 190 insertions(+), 117 deletions(-)
---
diff --git a/libdocument/ev-document-info.c b/libdocument/ev-document-info.c
new file mode 100644
index 000000000..24e765f56
--- /dev/null
+++ b/libdocument/ev-document-info.c
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2009 Carlos Garcia Campos
+ * Copyright (C) 2004 Marco Pesenti Gritti
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "ev-document-info.h"
+
+G_DEFINE_BOXED_TYPE (EvDocumentInfo, ev_document_info, ev_document_info_copy, ev_document_info_free)
+
+/**
+ * ev_document_info_copy:
+ * @info: a #EvDocumentInfo
+ *
+ * Returns: (transfer full): a copy of @info
+ */
+EvDocumentInfo *
+ev_document_info_copy (EvDocumentInfo *info)
+{
+ EvDocumentInfo *copy;
+
+ g_return_val_if_fail (info != NULL, NULL);
+
+ copy = g_new0 (EvDocumentInfo, 1);
+ copy->title = g_strdup (info->title);
+ copy->format = g_strdup (info->format);
+ copy->author = g_strdup (info->author);
+ copy->subject = g_strdup (info->subject);
+ copy->keywords = g_strdup (info->keywords);
+ copy->security = g_strdup (info->security);
+ copy->creator = g_strdup (info->creator);
+ copy->producer = g_strdup (info->producer);
+ copy->linearized = g_strdup (info->linearized);
+
+ copy->creation_date = g_date_time_add (info->creation_date, 0);
+ copy->modified_date = g_date_time_add (info->modified_date, 0);
+ 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->license = ev_document_license_copy (info->license);
+
+ copy->fields_mask = info->fields_mask;
+
+ return copy;
+}
+
+/**
+ * ev_document_info_free:
+ * @info: (transfer full): a #EvDocumentInfo
+ *
+ * Frees @info.
+ */
+void
+ev_document_info_free (EvDocumentInfo *info)
+{
+ if (info == NULL)
+ return;
+
+ g_free (info->title);
+ g_free (info->format);
+ g_free (info->author);
+ g_free (info->subject);
+ g_free (info->keywords);
+ g_free (info->creator);
+ g_free (info->producer);
+ g_free (info->linearized);
+ g_free (info->security);
+ g_clear_pointer (&(info->creation_date), g_date_time_unref);
+ g_clear_pointer (&(info->modified_date), g_date_time_unref);
+ ev_document_license_free (info->license);
+
+ g_free (info);
+}
+
+/* EvDocumentLicense */
+G_DEFINE_BOXED_TYPE (EvDocumentLicense, ev_document_license, ev_document_license_copy,
ev_document_license_free)
+
+/**
+ * ev_document_license_new:
+ *
+ * Returns: (transfer full): a new, empty #EvDocumentLicense
+ */
+EvDocumentLicense *
+ev_document_license_new (void)
+{
+ return g_new0 (EvDocumentLicense, 1);
+}
+
+/**
+ * ev_document_license_copy:
+ * @license: (nullable): a #EvDocumentLicense
+ *
+ * Returns: (transfer full): a copy of @license, or %NULL
+ */
+EvDocumentLicense *
+ev_document_license_copy (EvDocumentLicense *license)
+{
+ EvDocumentLicense *new_license;
+
+ if (!license)
+ return NULL;
+
+ new_license = ev_document_license_new ();
+
+ if (license->text)
+ new_license->text = g_strdup (license->text);
+ if (license->uri)
+ new_license->uri = g_strdup (license->uri);
+ if (license->web_statement)
+ new_license->web_statement = g_strdup (license->web_statement);
+
+ return new_license;
+}
+
+/**
+ * ev_document_license_free:
+ * @license: (transfer full): a #EvDocumentLicense
+ *
+ * Frees @license.
+ */
+void
+ev_document_license_free (EvDocumentLicense *license)
+{
+ if (!license)
+ return;
+
+ g_free (license->text);
+ g_free (license->uri);
+ g_free (license->web_statement);
+
+ g_free (license);
+}
+
+/**
+ * ev_document_license_get_text:
+ * @license: (transfer full): a #EvDocumentLicense
+ *
+ * Returns: (transfer none) (nullable): the license text
+ */
+const gchar *
+ev_document_license_get_text (EvDocumentLicense *license)
+{
+ return license->text;
+}
+
+/**
+ * ev_document_license_get_uri:
+ * @license: (transfer full): a #EvDocumentLicense
+ *
+ * Returns: (transfer none) (nullable): the license URI
+ */
+const gchar *
+ev_document_license_get_uri (EvDocumentLicense *license)
+{
+ return license->uri;
+}
+
+/**
+ * ev_document_license_get_web_statement
+ * @license: (transfer full): a #EvDocumentLicense
+ *
+ * Returns: (transfer none) (nullable): the license web statement
+ */
+const gchar *
+ev_document_license_get_web_statement (EvDocumentLicense *license)
+{
+ return license->web_statement;
+}
diff --git a/libdocument/ev-document.c b/libdocument/ev-document.c
index 3751f28a0..dc7eca3f6 100644
--- a/libdocument/ev-document.c
+++ b/libdocument/ev-document.c
@@ -1166,123 +1166,6 @@ ev_source_link_free (EvSourceLink *link)
g_slice_free (EvSourceLink, link);
}
-/* EvDocumentInfo */
-G_DEFINE_BOXED_TYPE (EvDocumentInfo, ev_document_info, ev_document_info_copy, ev_document_info_free)
-
-EvDocumentInfo *
-ev_document_info_copy (EvDocumentInfo *info)
-{
- EvDocumentInfo *copy;
-
- g_return_val_if_fail (info != NULL, NULL);
-
- copy = g_new0 (EvDocumentInfo, 1);
- copy->title = g_strdup (info->title);
- copy->format = g_strdup (info->format);
- copy->author = g_strdup (info->author);
- copy->subject = g_strdup (info->subject);
- copy->keywords = g_strdup (info->keywords);
- copy->security = g_strdup (info->security);
- copy->creator = g_strdup (info->creator);
- copy->producer = g_strdup (info->producer);
- copy->linearized = g_strdup (info->linearized);
-
- copy->creation_date = g_date_time_add (info->creation_date, 0);
- copy->modified_date = g_date_time_add (info->modified_date, 0);
- 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->license = ev_document_license_copy (info->license);
-
- copy->fields_mask = info->fields_mask;
-
- return copy;
-}
-
-void
-ev_document_info_free (EvDocumentInfo *info)
-{
- if (info == NULL)
- return;
-
- g_free (info->title);
- g_free (info->format);
- g_free (info->author);
- g_free (info->subject);
- g_free (info->keywords);
- g_free (info->creator);
- g_free (info->producer);
- g_free (info->linearized);
- g_free (info->security);
- g_clear_pointer (&(info->creation_date), g_date_time_unref);
- g_clear_pointer (&(info->modified_date), g_date_time_unref);
- ev_document_license_free (info->license);
-
- g_free (info);
-}
-
-/* EvDocumentLicense */
-G_DEFINE_BOXED_TYPE (EvDocumentLicense, ev_document_license, ev_document_license_copy,
ev_document_license_free)
-
-EvDocumentLicense *
-ev_document_license_new (void)
-{
- return g_new0 (EvDocumentLicense, 1);
-}
-
-EvDocumentLicense *
-ev_document_license_copy (EvDocumentLicense *license)
-{
- EvDocumentLicense *new_license;
-
- if (!license)
- return NULL;
-
- new_license = ev_document_license_new ();
-
- if (license->text)
- new_license->text = g_strdup (license->text);
- if (license->uri)
- new_license->uri = g_strdup (license->uri);
- if (license->web_statement)
- new_license->web_statement = g_strdup (license->web_statement);
-
- return new_license;
-}
-
-void
-ev_document_license_free (EvDocumentLicense *license)
-{
- if (!license)
- return;
-
- g_free (license->text);
- g_free (license->uri);
- g_free (license->web_statement);
-
- g_free (license);
-}
-
-const gchar *
-ev_document_license_get_text (EvDocumentLicense *license)
-{
- return license->text;
-}
-
-const gchar *
-ev_document_license_get_uri (EvDocumentLicense *license)
-{
- return license->uri;
-}
-
-const gchar *
-ev_document_license_get_web_statement (EvDocumentLicense *license)
-{
- return license->web_statement;
-}
-
/* EvRectangle */
G_DEFINE_BOXED_TYPE (EvRectangle, ev_rectangle, ev_rectangle_copy, ev_rectangle_free)
diff --git a/libdocument/meson.build b/libdocument/meson.build
index 58b454e27..11143f788 100644
--- a/libdocument/meson.build
+++ b/libdocument/meson.build
@@ -61,6 +61,7 @@ sources = files(
'ev-document-fonts.c',
'ev-document-forms.c',
'ev-document-images.c',
+ 'ev-document-info.c',
'ev-document-layers.c',
'ev-document-links.c',
'ev-document-media.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]