Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/libdocument
diff options
context:
space:
mode:
Diffstat (limited to 'libdocument')
-rw-r--r--libdocument/Makefile.am2
-rw-r--r--libdocument/ev-document-forms.c2
-rw-r--r--libdocument/ev-document-forms.h4
-rw-r--r--libdocument/ev-document.c28
-rw-r--r--libdocument/ev-document.h13
-rw-r--r--libdocument/ev-form-field.c16
-rw-r--r--libdocument/ev-form-field.h2
-rw-r--r--libdocument/ev-page.c62
-rw-r--r--libdocument/ev-page.h59
-rw-r--r--libdocument/ev-render-context.c22
-rw-r--r--libdocument/ev-render-context.h22
11 files changed, 195 insertions, 37 deletions
diff --git a/libdocument/Makefile.am b/libdocument/Makefile.am
index a00eeae..577c1c5 100644
--- a/libdocument/Makefile.am
+++ b/libdocument/Makefile.am
@@ -38,6 +38,7 @@ INST_H_FILES = \
ev-link-action.h \
ev-link-dest.h \
ev-link.h \
+ ev-page.h \
ev-render-context.h \
ev-selection.h \
ev-transition-effect.h
@@ -68,6 +69,7 @@ libevbackend_la_SOURCES= \
ev-file-exporter.c \
ev-file-helpers.c \
ev-module.c \
+ ev-page.c \
ev-render-context.c \
ev-selection.c \
ev-transition-effect.c \
diff --git a/libdocument/ev-document-forms.c b/libdocument/ev-document-forms.c
index db90bb8..d5d9c70 100644
--- a/libdocument/ev-document-forms.c
+++ b/libdocument/ev-document-forms.c
@@ -43,7 +43,7 @@ ev_document_forms_get_type (void)
GList *
ev_document_forms_get_form_fields (EvDocumentForms *document_forms,
- gint page)
+ EvPage *page)
{
EvDocumentFormsIface *iface = EV_DOCUMENT_FORMS_GET_IFACE (document_forms);
diff --git a/libdocument/ev-document-forms.h b/libdocument/ev-document-forms.h
index a1b192d..1337a5e 100644
--- a/libdocument/ev-document-forms.h
+++ b/libdocument/ev-document-forms.h
@@ -44,7 +44,7 @@ struct _EvDocumentFormsIface
/* Methods */
GList *(* get_form_fields) (EvDocumentForms *document_forms,
- gint page);
+ EvPage *page);
gchar *(* form_field_text_get_text) (EvDocumentForms *document_forms,
EvFormField *field);
void (* form_field_text_set_text) (EvDocumentForms *document_forms,
@@ -80,7 +80,7 @@ struct _EvDocumentFormsIface
GType ev_document_forms_get_type (void) G_GNUC_CONST;
GList *ev_document_forms_get_form_fields (EvDocumentForms *document_forms,
- gint page);
+ EvPage *page);
gchar *ev_document_forms_form_field_text_get_text (EvDocumentForms *document_forms,
EvFormField *field);
diff --git a/libdocument/ev-document.c b/libdocument/ev-document.c
index 2c6db95..5e582d0 100644
--- a/libdocument/ev-document.c
+++ b/libdocument/ev-document.c
@@ -150,11 +150,26 @@ ev_document_get_n_pages (EvDocument *document)
return retval;
}
+EvPage *
+ev_document_get_page (EvDocument *document,
+ gint index)
+{
+ EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+ EvPage *retval;
+
+ if (iface->get_page)
+ retval = iface->get_page (document, index);
+ else
+ retval = ev_page_new (index);
+
+ return retval;
+}
+
void
-ev_document_get_page_size (EvDocument *document,
- int page,
- double *width,
- double *height)
+ev_document_get_page_size (EvDocument *document,
+ EvPage *page,
+ double *width,
+ double *height)
{
EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
@@ -163,8 +178,8 @@ ev_document_get_page_size (EvDocument *document,
}
char *
-ev_document_get_page_label(EvDocument *document,
- int page)
+ev_document_get_page_label (EvDocument *document,
+ EvPage *page)
{
EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
@@ -239,7 +254,6 @@ ev_document_info_free (EvDocumentInfo *info)
g_free (info->linearized);
g_free (info->security);
-
g_free (info);
}
diff --git a/libdocument/ev-document.h b/libdocument/ev-document.h
index bc040d1..cfcccdb 100644
--- a/libdocument/ev-document.h
+++ b/libdocument/ev-document.h
@@ -28,6 +28,7 @@
#include <cairo.h>
#include "ev-document-info.h"
+#include "ev-page.h"
#include "ev-render-context.h"
G_BEGIN_DECLS
@@ -78,12 +79,14 @@ struct _EvDocumentIface
const char *uri,
GError **error);
int (* get_n_pages) (EvDocument *document);
+ EvPage * (* get_page) (EvDocument *document,
+ gint index);
void (* get_page_size) (EvDocument *document,
- int page,
+ EvPage *page,
double *width,
double *height);
char * (* get_page_label) (EvDocument *document,
- int page);
+ EvPage *page);
gboolean (* has_attachments) (EvDocument *document);
GList * (* get_attachments) (EvDocument *document);
cairo_surface_t * (* render) (EvDocument *document,
@@ -112,12 +115,14 @@ gboolean ev_document_save (EvDocument *document,
const char *uri,
GError **error);
int ev_document_get_n_pages (EvDocument *document);
+EvPage *ev_document_get_page (EvDocument *document,
+ gint index);
void ev_document_get_page_size (EvDocument *document,
- int page,
+ EvPage *page,
double *width,
double *height);
char *ev_document_get_page_label (EvDocument *document,
- int page);
+ EvPage *page);
gboolean ev_document_has_attachments (EvDocument *document);
GList *ev_document_get_attachments (EvDocument *document);
cairo_surface_t *ev_document_render (EvDocument *document,
diff --git a/libdocument/ev-form-field.c b/libdocument/ev-form-field.c
index cfa25f8..130b6c0 100644
--- a/libdocument/ev-form-field.c
+++ b/libdocument/ev-form-field.c
@@ -42,14 +42,28 @@ G_DEFINE_TYPE (EvFormFieldSignature, ev_form_field_signature, EV_TYPE_FORM_FIELD
static void
ev_form_field_init (EvFormField *field)
{
- field->page = -1;
+ field->page = NULL;
field->changed = FALSE;
field->is_read_only = FALSE;
}
static void
+ev_form_field_finalize (GObject *object)
+{
+ EvFormField *field = EV_FORM_FIELD (object);
+
+ g_object_unref (field->page);
+ field->page = NULL;
+
+ (* G_OBJECT_CLASS (ev_form_field_parent_class)->finalize) (object);
+}
+
+static void
ev_form_field_class_init (EvFormFieldClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = ev_form_field_finalize;
}
static void
diff --git a/libdocument/ev-form-field.h b/libdocument/ev-form-field.h
index 0b09af9..027bee6 100644
--- a/libdocument/ev-form-field.h
+++ b/libdocument/ev-form-field.h
@@ -105,7 +105,7 @@ struct _EvFormField
gboolean is_read_only;
gdouble font_size;
- gint page;
+ EvPage *page;
gboolean changed;
};
diff --git a/libdocument/ev-page.c b/libdocument/ev-page.c
new file mode 100644
index 0000000..c37e38f
--- /dev/null
+++ b/libdocument/ev-page.c
@@ -0,0 +1,62 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2008 Carlos Garcia Campos <carlosgc@gnome.org>
+ *
+ * Evince 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 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include "ev-page.h"
+
+G_DEFINE_TYPE (EvPage, ev_page, G_TYPE_OBJECT)
+
+static void
+ev_page_init (EvPage *page)
+{
+}
+
+static void
+ev_page_finalize (GObject *object)
+{
+ EvPage *page = EV_PAGE (object);
+
+ if (page->backend_destroy_func) {
+ page->backend_destroy_func (page->backend_page);
+ page->backend_destroy_func = NULL;
+ }
+ page->backend_page = NULL;
+
+ (* G_OBJECT_CLASS (ev_page_parent_class)->finalize) (object);
+}
+
+static void
+ev_page_class_init (EvPageClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = ev_page_finalize;
+}
+
+EvPage *
+ev_page_new (gint index)
+{
+ EvPage *page;
+
+ page = EV_PAGE (g_object_new (EV_TYPE_PAGE, NULL));
+ page->index = index;
+
+ return page;
+}
diff --git a/libdocument/ev-page.h b/libdocument/ev-page.h
new file mode 100644
index 0000000..801b3e1
--- /dev/null
+++ b/libdocument/ev-page.h
@@ -0,0 +1,59 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2008 Carlos Garcia Campos <carlosgc@gnome.org>
+ *
+ * Evince 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 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef EV_PAGE_H
+#define EV_PAGE_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define EV_TYPE_PAGE (ev_page_get_type())
+#define EV_PAGE(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_PAGE, EvPage))
+#define EV_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_PAGE, EvPageClass))
+#define EV_IS_PAGE(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_PAGE))
+#define EV_IS_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_PAGE))
+#define EV_PAGE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_PAGE, EvPageClass))
+
+typedef struct _EvPage EvPage;
+typedef struct _EvPageClass EvPageClass;
+
+typedef gpointer EvBackendPage;
+typedef GDestroyNotify EvBackendPageDestroyFunc;
+
+struct _EvPage {
+ GObject base_instance;
+
+ gint index;
+
+ EvBackendPage backend_page;
+ EvBackendPageDestroyFunc backend_destroy_func;
+};
+
+struct _EvPageClass {
+ GObjectClass base_class;
+};
+
+GType ev_page_get_type (void) G_GNUC_CONST;
+
+EvPage *ev_page_new (gint index);
+
+G_END_DECLS
+
+#endif /* EV_PAGE_H */
diff --git a/libdocument/ev-render-context.c b/libdocument/ev-render-context.c
index 5595651..4574066 100644
--- a/libdocument/ev-render-context.c
+++ b/libdocument/ev-render-context.c
@@ -35,9 +35,9 @@ ev_render_context_dispose (GObject *object)
rc = (EvRenderContext *) object;
- if (rc->destroy) {
- (*rc->destroy) (rc->data);
- rc->destroy = NULL;
+ if (rc->page) {
+ g_object_unref (rc->page);
+ rc->page = NULL;
}
(* G_OBJECT_CLASS (ev_render_context_parent_class)->dispose) (object);
@@ -53,18 +53,17 @@ ev_render_context_class_init (EvRenderContextClass *class)
oclass->dispose = ev_render_context_dispose;
}
-
EvRenderContext *
-ev_render_context_new (int rotation,
- gint page,
- gdouble scale)
+ev_render_context_new (EvPage *page,
+ gint rotation,
+ gdouble scale)
{
EvRenderContext *rc;
rc = (EvRenderContext *) g_object_new (EV_TYPE_RENDER_CONTEXT, NULL);
+ rc->page = page ? g_object_ref (page) : NULL;
rc->rotation = rotation;
- rc->page = page;
rc->scale = scale;
return rc;
@@ -72,11 +71,14 @@ ev_render_context_new (int rotation,
void
ev_render_context_set_page (EvRenderContext *rc,
- gint page)
+ EvPage *page)
{
g_return_if_fail (rc != NULL);
+ g_return_if_fail (EV_IS_PAGE (page));
- rc->page = page;
+ if (rc->page)
+ g_object_unref (rc->page);
+ rc->page = g_object_ref (page);
}
void
diff --git a/libdocument/ev-render-context.h b/libdocument/ev-render-context.h
index 636f02f..eb324e8 100644
--- a/libdocument/ev-render-context.h
+++ b/libdocument/ev-render-context.h
@@ -22,14 +22,16 @@
#include <glib-object.h>
+#include "ev-page.h"
+
G_BEGIN_DECLS
typedef struct _EvRenderContext EvRenderContext;
typedef struct _EvRenderContextClass EvRenderContextClass;
#define EV_TYPE_RENDER_CONTEXT (ev_render_context_get_type())
-#define EV_RENDER_CONTEXT(context) ((EvRenderContext *) (context))
-#define EV_RENDER_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_RENDER_CONTEXT, EvRenderContext))
+#define EV_RENDER_CONTEXT(context) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_RENDER_CONTEXT, EvRenderContext)
+#define EV_RENDER_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_RENDER_CONTEXT, EvRenderContextClass))
#define EV_IS_RENDER_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_RENDER_CONTEXT))
struct _EvRenderContextClass
@@ -40,23 +42,21 @@ struct _EvRenderContextClass
struct _EvRenderContext
{
GObject parent;
- int rotation;
- gint page;
+
+ EvPage *page;
+ gint rotation;
gdouble scale;
-
- gpointer data;
- GDestroyNotify destroy;
};
GType ev_render_context_get_type (void) G_GNUC_CONST;
-EvRenderContext *ev_render_context_new (int rotation,
- gint page,
+EvRenderContext *ev_render_context_new (EvPage *page,
+ gint rotation,
gdouble scale);
void ev_render_context_set_page (EvRenderContext *rc,
- gint page);
+ EvPage *page);
void ev_render_context_set_rotation (EvRenderContext *rc,
- int rotation);
+ gint rotation);
void ev_render_context_set_scale (EvRenderContext *rc,
gdouble scale);