Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/libdocument
diff options
context:
space:
mode:
authorNickolay V. Shmyrev <nshmyrev@yandex.ru>2007-01-08 12:25:31 (GMT)
committer Nickolay V. Shmyrev <nshmyrev@src.gnome.org>2007-01-08 12:25:31 (GMT)
commit13a06349251874bd35d2f03c3fc93217cee749a2 (patch)
treea681279b008acb19f686ee265aaed2be0da8d9e8 /libdocument
parentafb550ab779e00918d8fe24742abee3a81ebfe93 (diff)
Reorganize source tree.
2007-01-08 Nickolay V. Shmyrev <nshmyrev@yandex.ru> * Makefile.am: * backend/Makefile.am: * backend/comics/Makefile.am: * backend/djvu/Makefile.am: * backend/dvi/Makefile.am: * backend/ev-async-renderer.c: * backend/ev-async-renderer.h: * backend/ev-attachment.c: * backend/ev-attachment.h: * backend/ev-backend-marshal.c: * backend/ev-document-factory.c: * backend/ev-document-factory.h: * backend/ev-document-find.c: * backend/ev-document-find.h: * backend/ev-document-fonts.c: * backend/ev-document-fonts.h: * backend/ev-document-images.c: * backend/ev-document-images.h: * backend/ev-document-info.h: * backend/ev-document-links.c: * backend/ev-document-links.h: * backend/ev-document-misc.c: * backend/ev-document-misc.h: * backend/ev-document-security.c: * backend/ev-document-security.h: * backend/ev-document-thumbnails.c: * backend/ev-document-thumbnails.h: * backend/ev-document-transition.c: * backend/ev-document-transition.h: * backend/ev-document.c: * backend/ev-document.h: * backend/ev-file-exporter.c: * backend/ev-file-exporter.h: * backend/ev-image.c: * backend/ev-image.h: * backend/ev-link-action.c: * backend/ev-link-action.h: * backend/ev-link-dest.c: * backend/ev-link-dest.h: * backend/ev-link.c: * backend/ev-link.h: * backend/ev-render-context.c: * backend/ev-render-context.h: * backend/ev-selection.c: * backend/ev-selection.h: * backend/impress/Makefile.am: * backend/pdf/Makefile.am: * backend/pixbuf/Makefile.am: * backend/ps/Makefile.am: * backend/ps/ps-document.c: (push_pixbuf), (interpreter_failed), (ps_document_widget_event), (setup_pixmap), (setup_page), (input), (start_interpreter), (stop_interpreter), (document_load), (ps_document_next_page), (render_page): * backend/tiff/Makefile.am: * comics/Makefile.am: * comics/comics-document.c: * comics/comics-document.h: * configure.ac: * cut-n-paste/zoom-control/ephy-zoom-control.c: * djvu/Makefile.am: * djvu/djvu-document-private.h: * djvu/djvu-document.c: * djvu/djvu-document.h: * djvu/djvu-links.c: * djvu/djvu-links.h: * djvu/djvu-text-page.c: * djvu/djvu-text-page.h: * djvu/djvu-text.c: * djvu/djvu-text.h: * dvi/Makefile.am: * dvi/dvi-document.c: * dvi/dvi-document.h: * dvi/fonts.c: * dvi/fonts.h: * dvi/mdvi-lib/Makefile.am: * dvi/mdvi-lib/afmparse.c: * dvi/mdvi-lib/afmparse.h: * dvi/mdvi-lib/bitmap.c: * dvi/mdvi-lib/bitmap.h: * dvi/mdvi-lib/color.c: * dvi/mdvi-lib/color.h: * dvi/mdvi-lib/common.c: * dvi/mdvi-lib/common.h: * dvi/mdvi-lib/defaults.h: * dvi/mdvi-lib/dvimisc.c: * dvi/mdvi-lib/dviopcodes.h: * dvi/mdvi-lib/dviread.c: * dvi/mdvi-lib/files.c: * dvi/mdvi-lib/font.c: * dvi/mdvi-lib/fontmap.c: * dvi/mdvi-lib/fontmap.h: * dvi/mdvi-lib/fontsrch.c: * dvi/mdvi-lib/gf.c: * dvi/mdvi-lib/hash.c: * dvi/mdvi-lib/hash.h: * dvi/mdvi-lib/list.c: * dvi/mdvi-lib/mdvi.h: * dvi/mdvi-lib/pagesel.c: * dvi/mdvi-lib/paper.c: * dvi/mdvi-lib/paper.h: * dvi/mdvi-lib/pk.c: * dvi/mdvi-lib/private.h: * dvi/mdvi-lib/setup.c: * dvi/mdvi-lib/sp-epsf.c: * dvi/mdvi-lib/special.c: * dvi/mdvi-lib/sysdeps.h: * dvi/mdvi-lib/t1.c: * dvi/mdvi-lib/tfm.c: * dvi/mdvi-lib/tfmfile.c: * dvi/mdvi-lib/tt.c: * dvi/mdvi-lib/util.c: * dvi/mdvi-lib/vf.c: * dvi/pixbuf-device.c: * dvi/pixbuf-device.h: * impress/Makefile.am: * impress/common.h: * impress/document.c: * impress/f_oasis.c: * impress/f_oo13.c: * impress/iksemel.c: * impress/iksemel.h: * impress/imposter.h: * impress/impress-document.c: * impress/impress-document.h: * impress/internal.h: * impress/r_back.c: * impress/r_draw.c: * impress/r_geometry.c: * impress/r_gradient.c: * impress/r_style.c: * impress/r_text.c: * impress/render.c: * impress/render.h: * impress/zip.c: * impress/zip.h: * lib/Makefile.am: * lib/ev-debug.c: * lib/ev-debug.h: * lib/ev-file-helpers.c: * lib/ev-file-helpers.h: * lib/ev-gui.c: * lib/ev-gui.h: * lib/ev-tooltip.c: * lib/ev-tooltip.h: * libdocument/Makefile.am: * libdocument/ev-file-helpers.c: * pdf/Makefile.am: * pdf/ev-poppler.cc: * pdf/ev-poppler.h: * pixbuf/Makefile.am: * pixbuf/pixbuf-document.c: * pixbuf/pixbuf-document.h: * properties/Makefile.am: * ps/Makefile.am: * ps/gsdefaults.c: * ps/gsdefaults.h: * ps/gsio.c: * ps/gsio.h: * ps/gstypes.h: * ps/ps-document.c: * ps/ps-document.h: * ps/ps.c: * ps/ps.h: * shell/Makefile.am: * shell/ev-application.h: * shell/ev-sidebar-links.c: * shell/ev-sidebar-links.h: * shell/ev-utils.c: (ev_gui_sanitise_popup_position), (ev_gui_menu_position_tree_selection): * shell/ev-utils.h: * shell/ev-view.c: (ev_view_finalize): * shell/ev-window.c: * shell/main.c: (main): * thumbnailer/Makefile.am: * tiff/Makefile.am: * tiff/tiff-document.c: * tiff/tiff-document.h: * tiff/tiff2ps.c: * tiff/tiff2ps.h: Reorganize source tree. svn path=/trunk/; revision=2197
Diffstat (limited to 'libdocument')
-rw-r--r--libdocument/Makefile.am122
-rw-r--r--libdocument/ev-async-renderer.c82
-rw-r--r--libdocument/ev-async-renderer.h61
-rw-r--r--libdocument/ev-attachment.c409
-rw-r--r--libdocument/ev-attachment.h72
-rw-r--r--libdocument/ev-backend-marshal.c2
-rw-r--r--libdocument/ev-backend-marshalers.list0
-rw-r--r--libdocument/ev-document-factory.c463
-rw-r--r--libdocument/ev-document-factory.h46
-rw-r--r--libdocument/ev-document-find.c126
-rw-r--r--libdocument/ev-document-find.h98
-rw-r--r--libdocument/ev-document-fonts.c74
-rw-r--r--libdocument/ev-document-fonts.h74
-rw-r--r--libdocument/ev-document-images.c55
-rw-r--r--libdocument/ev-document-images.h55
-rw-r--r--libdocument/ev-document-info.h126
-rw-r--r--libdocument/ev-document-links.c94
-rw-r--r--libdocument/ev-document-links.h78
-rw-r--r--libdocument/ev-document-misc.c141
-rw-r--r--libdocument/ev-document-misc.h47
-rw-r--r--libdocument/ev-document-security.c63
-rw-r--r--libdocument/ev-document-security.h63
-rw-r--r--libdocument/ev-document-thumbnails.c79
-rw-r--r--libdocument/ev-document-thumbnails.h77
-rw-r--r--libdocument/ev-document-transition.c55
-rw-r--r--libdocument/ev-document-transition.h56
-rw-r--r--libdocument/ev-document.c281
-rw-r--r--libdocument/ev-document.h140
-rw-r--r--libdocument/ev-file-exporter.c91
-rw-r--r--libdocument/ev-file-exporter.h84
-rw-r--r--libdocument/ev-file-helpers.c169
-rw-r--r--libdocument/ev-file-helpers.h44
-rw-r--r--libdocument/ev-image.c167
-rw-r--r--libdocument/ev-image.h74
-rw-r--r--libdocument/ev-link-action.c360
-rw-r--r--libdocument/ev-link-action.h72
-rw-r--r--libdocument/ev-link-dest.c467
-rw-r--r--libdocument/ev-link-dest.h86
-rw-r--r--libdocument/ev-link.c226
-rw-r--r--libdocument/ev-link.h64
-rw-r--r--libdocument/ev-render-context.c79
-rw-r--r--libdocument/ev-render-context.h66
-rw-r--r--libdocument/ev-selection.c93
-rw-r--r--libdocument/ev-selection.h76
44 files changed, 5257 insertions, 0 deletions
diff --git a/libdocument/Makefile.am b/libdocument/Makefile.am
new file mode 100644
index 0000000..73340ff
--- /dev/null
+++ b/libdocument/Makefile.am
@@ -0,0 +1,122 @@
+INCLUDES= \
+ -DEVINCE_UIDIR=\"$(pkgdatadir)\" \
+ -DGNOMELOCALEDIR=\"$(datadir)/locale\" \
+ -I$(top_srcdir)/backend/pdf \
+ -I$(top_srcdir)/backend/pixbuf \
+ -I$(top_srcdir)/backend/tiff \
+ -I$(top_srcdir)/backend/ps \
+ -I$(top_srcdir)/backend/djvu \
+ -I$(top_srcdir)/backend/dvi \
+ -I$(top_srcdir)/backend/impress \
+ -I$(top_srcdir)/backend/comics \
+ $(BACKEND_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(DISABLE_DEPRECATED)
+
+noinst_LTLIBRARIES = libevbackend.la
+
+libevbackend_la_SOURCES= \
+ ev-async-renderer.c \
+ ev-async-renderer.h \
+ ev-attachment.c \
+ ev-attachment.h \
+ ev-backend-marshal.c \
+ ev-link.c \
+ ev-link.h \
+ ev-link-action.c \
+ ev-link-action.h \
+ ev-link-dest.c \
+ ev-link-dest.h \
+ ev-image.c \
+ ev-image.h \
+ ev-document.c \
+ ev-document.h \
+ ev-document-factory.c \
+ ev-document-factory.h \
+ ev-document-thumbnails.c \
+ ev-document-thumbnails.h \
+ ev-document-fonts.c \
+ ev-document-fonts.h \
+ ev-document-links.c \
+ ev-document-links.h \
+ ev-document-images.c \
+ ev-document-images.h \
+ ev-document-security.c \
+ ev-document-security.h \
+ ev-document-find.c \
+ ev-document-find.h \
+ ev-document-info.h \
+ ev-document-transition.h \
+ ev-document-transition.c \
+ ev-file-exporter.c \
+ ev-file-exporter.h \
+ ev-file-helpers.c \
+ ev-file-helpers.h \
+ ev-render-context.h \
+ ev-render-context.c \
+ ev-selection.h \
+ ev-selection.c \
+ ev-document-misc.h \
+ ev-document-misc.c
+
+libevbackend_la_LIBADD =
+
+if ENABLE_PDF
+libevbackend_la_LIBADD += \
+ $(top_builddir)/backend/pdf/libpdfdocument.la
+endif
+
+if ENABLE_PS
+libevbackend_la_LIBADD += \
+ $(top_builddir)/backend/ps/libpsdocument.la
+endif
+
+if ENABLE_PIXBUF
+libevbackend_la_LIBADD += \
+ $(top_builddir)/backend/pixbuf/libpixbufdocument.la
+endif
+
+if ENABLE_DJVU
+libevbackend_la_LIBADD += \
+ $(top_builddir)/backend/djvu/libgtkdjvu.la
+endif
+
+if ENABLE_TIFF
+libevbackend_la_LIBADD += \
+ $(top_builddir)/backend/tiff/libtiffdocument.la
+endif
+
+if ENABLE_DVI
+libevbackend_la_LIBADD += \
+ $(top_builddir)/backend/dvi/libgtkdvi.la
+endif
+
+if ENABLE_COMICS
+libevbackend_la_LIBADD += \
+ $(top_builddir)/backend/comics/libcomicsdocument.la
+endif
+
+if ENABLE_IMPRESS
+libevbackend_la_LIBADD += \
+ $(top_builddir)/backend/impress/libimpressdocument.la
+endif
+
+BUILT_SOURCES= \
+ ev-backend-marshalers.h \
+ ev-backend-marshalers.c
+
+CLEANFILES = $(BUILT_SOURCES)
+
+ev-backend-marshalers.h: ev-backend-marshalers.list
+ $(GLIB_GENMARSHAL) --prefix=_ev_backend_marshal $(srcdir)/ev-backend-marshalers.list --header > $@
+
+ev-backend-marshalers.c: ev-backend-marshalers.list
+ $(GLIB_GENMARSHAL) --prefix=_ev_backend_marshal $(srcdir)/ev-backend-marshalers.list --body > $@
+
+ev-backend-marshal.c: ev-backend-marshalers.h ev-backend-marshalers.c
+
+noinst_HEADERS = \
+ ev-backend-marshalers.h
+
+EXTRA_DIST= \
+ ev-backend-marshalers.list
diff --git a/libdocument/ev-async-renderer.c b/libdocument/ev-async-renderer.c
new file mode 100644
index 0000000..f0ffce4
--- /dev/null
+++ b/libdocument/ev-async-renderer.c
@@ -0,0 +1,82 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include "ev-async-renderer.h"
+
+static void ev_async_renderer_class_init (gpointer g_class);
+
+enum
+{
+ RENDER_FINISHED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+GType
+ev_async_renderer_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ {
+ const GTypeInfo our_info =
+ {
+ sizeof (EvAsyncRendererIface),
+ NULL,
+ NULL,
+ (GClassInitFunc)ev_async_renderer_class_init
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EvAsyncRenderer",
+ &our_info, (GTypeFlags)0);
+ }
+
+ return type;
+}
+
+static void
+ev_async_renderer_class_init (gpointer g_class)
+{
+ signals[RENDER_FINISHED] =
+ g_signal_new ("render_finished",
+ EV_TYPE_ASYNC_RENDERER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EvAsyncRendererIface, render_finished),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE,
+ 1,
+ GDK_TYPE_PIXBUF);
+}
+
+void
+ev_async_renderer_render_pixbuf (EvAsyncRenderer *async_renderer,
+ int page,
+ double scale,
+ int rotation)
+{
+ EvAsyncRendererIface *iface = EV_ASYNC_RENDERER_GET_IFACE (async_renderer);
+
+ iface->render_pixbuf (async_renderer, page, scale, rotation);
+}
diff --git a/libdocument/ev-async-renderer.h b/libdocument/ev-async-renderer.h
new file mode 100644
index 0000000..9aa9657
--- /dev/null
+++ b/libdocument/ev-async-renderer.h
@@ -0,0 +1,61 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * Copyright (C) 2000-2003 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef EV_ASYNC_RENDERER_H
+#define EV_ASYNC_RENDERER_H
+
+#include <glib-object.h>
+#include <glib.h>
+#include <gdk/gdkpixbuf.h>
+
+G_BEGIN_DECLS
+
+#define EV_TYPE_ASYNC_RENDERER (ev_async_renderer_get_type ())
+#define EV_ASYNC_RENDERER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_ASYNC_RENDERER, EvAsyncRenderer))
+#define EV_ASYNC_RENDERER_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_ASYNC_RENDERER, EvAsyncRendererIface))
+#define EV_IS_ASYNC_RENDERER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_ASYNC_RENDERER))
+#define EV_IS_ASYNC_RENDERER_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_ASYNC_RENDERER))
+#define EV_ASYNC_RENDERER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_ASYNC_RENDERER, EvAsyncRendererIface))
+
+typedef struct _EvAsyncRenderer EvAsyncRenderer;
+typedef struct _EvAsyncRendererIface EvAsyncRendererIface;
+
+struct _EvAsyncRendererIface
+{
+ GTypeInterface base_iface;
+
+ void (* render_finished) (EvAsyncRenderer *renderer,
+ GdkPixbuf *pixbuf);
+
+ void (* render_pixbuf) (EvAsyncRenderer *renderer,
+ int page,
+ double scale,
+ int rotation);
+};
+
+GType ev_async_renderer_get_type (void);
+void ev_async_renderer_render_pixbuf (EvAsyncRenderer *renderer,
+ int page,
+ double scale,
+ int rotation);
+
+G_END_DECLS
+
+#endif
diff --git a/libdocument/ev-attachment.c b/libdocument/ev-attachment.c
new file mode 100644
index 0000000..7e7ca12
--- /dev/null
+++ b/libdocument/ev-attachment.c
@@ -0,0 +1,409 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2006 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 <glib/gi18n.h>
+#include <glib/gstdio.h>
+#include <libgnomevfs/gnome-vfs.h>
+#include <libgnomevfs/gnome-vfs-mime-handlers.h>
+#include <libgnomevfs/gnome-vfs-mime-utils.h>
+#include "ev-file-helpers.h"
+#include "ev-attachment.h"
+
+enum
+{
+ PROP_0,
+ PROP_NAME,
+ PROP_DESCRIPTION,
+ PROP_MTIME,
+ PROP_CTIME,
+ PROP_SIZE,
+ PROP_DATA
+};
+
+struct _EvAttachmentPrivate {
+ gchar *name;
+ gchar *description;
+ GTime mtime;
+ GTime ctime;
+ gsize size;
+ gchar *data;
+ gchar *mime_type;
+
+ GnomeVFSMimeApplication *app;
+ gchar *tmp_uri;
+};
+
+#define EV_ATTACHMENT_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_ATTACHMENT, EvAttachmentPrivate))
+
+G_DEFINE_TYPE (EvAttachment, ev_attachment, G_TYPE_OBJECT)
+
+GQuark
+ev_attachment_error_quark (void)
+{
+ static GQuark error_quark = 0;
+
+ if (error_quark == 0)
+ error_quark =
+ g_quark_from_static_string ("ev-attachment-error-quark");
+
+ return error_quark;
+}
+
+static void
+ev_attachment_finalize (GObject *object)
+{
+ EvAttachment *attachment = EV_ATTACHMENT (object);
+
+ if (attachment->priv->name) {
+ g_free (attachment->priv->name);
+ attachment->priv->name = NULL;
+ }
+
+ if (attachment->priv->description) {
+ g_free (attachment->priv->description);
+ attachment->priv->description = NULL;
+ }
+
+ if (attachment->priv->data) {
+ g_free (attachment->priv->data);
+ attachment->priv->data = NULL;
+ }
+
+ if (attachment->priv->mime_type) {
+ g_free (attachment->priv->mime_type);
+ attachment->priv->mime_type = NULL;
+ }
+
+ if (attachment->priv->app) {
+ gnome_vfs_mime_application_free (attachment->priv->app);
+ attachment->priv->app = NULL;
+ }
+
+ if (attachment->priv->tmp_uri) {
+ g_unlink (attachment->priv->tmp_uri);
+ g_free (attachment->priv->tmp_uri);
+ attachment->priv->tmp_uri = NULL;
+ }
+
+ (* G_OBJECT_CLASS (ev_attachment_parent_class)->finalize) (object);
+}
+
+static void
+ev_attachment_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *param_spec)
+{
+ EvAttachment *attachment = EV_ATTACHMENT (object);
+
+ switch (prop_id) {
+ case PROP_NAME:
+ attachment->priv->name = g_value_dup_string (value);
+ break;
+ case PROP_DESCRIPTION:
+ attachment->priv->description = g_value_dup_string (value);
+ break;
+ case PROP_MTIME:
+ attachment->priv->mtime = g_value_get_ulong (value);
+ break;
+ case PROP_CTIME:
+ attachment->priv->ctime = g_value_get_ulong (value);
+ break;
+ case PROP_SIZE:
+ attachment->priv->size = g_value_get_uint (value);
+ break;
+ case PROP_DATA:
+ attachment->priv->data = g_value_get_pointer (value);
+ attachment->priv->mime_type =
+ g_strdup (gnome_vfs_get_mime_type_for_data (attachment->priv->data,
+ attachment->priv->size));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+ prop_id,
+ param_spec);
+ break;
+ }
+}
+
+static void
+ev_attachment_class_init (EvAttachmentClass *klass)
+{
+ GObjectClass *g_object_class;
+
+ g_object_class = G_OBJECT_CLASS (klass);
+
+ g_object_class->set_property = ev_attachment_set_property;
+
+ g_type_class_add_private (g_object_class, sizeof (EvAttachmentPrivate));
+
+ /* Properties */
+ g_object_class_install_property (g_object_class,
+ PROP_NAME,
+ g_param_spec_string ("name",
+ "Name",
+ "The attachment name",
+ NULL,
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_DESCRIPTION,
+ g_param_spec_string ("description",
+ "Description",
+ "The attachment description",
+ NULL,
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_MTIME,
+ g_param_spec_ulong ("mtime",
+ "ModifiedTime",
+ "The attachment modification date",
+ 0, G_MAXULONG, 0,
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_CTIME,
+ g_param_spec_ulong ("ctime",
+ "CreationTime",
+ "The attachment creation date",
+ 0, G_MAXULONG, 0,
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_SIZE,
+ g_param_spec_uint ("size",
+ "Size",
+ "The attachment size",
+ 0, G_MAXUINT, 0,
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_DATA,
+ g_param_spec_pointer ("data",
+ "Data",
+ "The attachment data",
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class->finalize = ev_attachment_finalize;
+}
+
+static void
+ev_attachment_init (EvAttachment *attachment)
+{
+ attachment->priv = EV_ATTACHMENT_GET_PRIVATE (attachment);
+
+ attachment->priv->name = NULL;
+ attachment->priv->description = NULL;
+ attachment->priv->data = NULL;
+ attachment->priv->mime_type = NULL;
+
+ attachment->priv->tmp_uri = NULL;
+}
+
+EvAttachment *
+ev_attachment_new (const gchar *name,
+ const gchar *description,
+ GTime mtime,
+ GTime ctime,
+ gsize size,
+ gpointer data)
+{
+ EvAttachment *attachment;
+
+ attachment = g_object_new (EV_TYPE_ATTACHMENT,
+ "name", name,
+ "description", description,
+ "mtime", mtime,
+ "ctime", ctime,
+ "size", size,
+ "data", data,
+ NULL);
+
+ return attachment;
+}
+
+const gchar *
+ev_attachment_get_name (EvAttachment *attachment)
+{
+ g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), NULL);
+
+ return attachment->priv->name;
+}
+
+const gchar *
+ev_attachment_get_description (EvAttachment *attachment)
+{
+ g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), NULL);
+
+ return attachment->priv->description;
+}
+
+GTime
+ev_attachment_get_modification_date (EvAttachment *attachment)
+{
+ g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), 0);
+
+ return attachment->priv->mtime;
+}
+
+GTime
+ev_attachment_get_creation_date (EvAttachment *attachment)
+{
+ g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), 0);
+
+ return attachment->priv->ctime;
+}
+
+const gchar *
+ev_attachment_get_mime_type (EvAttachment *attachment)
+{
+ g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), NULL);
+
+ return attachment->priv->mime_type;
+}
+
+gboolean
+ev_attachment_save (EvAttachment *attachment,
+ const gchar *uri,
+ GError **error)
+{
+ GnomeVFSHandle *handle = NULL;
+ GnomeVFSFileSize written;
+ GnomeVFSResult result;
+
+ g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), FALSE);
+ g_return_val_if_fail (uri != NULL, FALSE);
+
+ result = gnome_vfs_create (&handle, uri,
+ GNOME_VFS_OPEN_WRITE,
+ FALSE, 0644);
+ if (result != GNOME_VFS_OK) {
+ g_set_error (error,
+ EV_ATTACHMENT_ERROR,
+ (gint) result,
+ _("Couldn't save attachment “%s”: %s"),
+ uri,
+ gnome_vfs_result_to_string (result));
+
+ return FALSE;
+ }
+
+ result = gnome_vfs_write (handle, attachment->priv->data,
+ attachment->priv->size, &written);
+ if (result != GNOME_VFS_OK || written < attachment->priv->size){
+ g_set_error (error,
+ EV_ATTACHMENT_ERROR,
+ (gint) result,
+ _("Couldn't save attachment “%s”: %s"),
+ uri,
+ gnome_vfs_result_to_string (result));
+
+ gnome_vfs_close (handle);
+
+ return FALSE;
+ }
+
+ gnome_vfs_close (handle);
+
+ return TRUE;
+}
+
+static gboolean
+ev_attachment_launch_app (EvAttachment *attachment,
+ GError **error)
+{
+ GnomeVFSResult result;
+ GList *uris = NULL;
+
+ g_assert (attachment->priv->tmp_uri != NULL);
+ g_assert (attachment->priv->app != NULL);
+
+ uris = g_list_prepend (uris, attachment->priv->tmp_uri);
+ result = gnome_vfs_mime_application_launch (attachment->priv->app,
+ uris);
+
+ if (result != GNOME_VFS_OK) {
+ g_set_error (error,
+ EV_ATTACHMENT_ERROR,
+ (gint) result,
+ _("Couldn't open attachment “%s”: %s"),
+ attachment->priv->name,
+ gnome_vfs_result_to_string (result));
+
+ g_list_free (uris);
+
+ return FALSE;
+ }
+
+ g_list_free (uris);
+
+ return TRUE;
+}
+
+gboolean
+ev_attachment_open (EvAttachment *attachment,
+ GError **error)
+{
+
+ gboolean retval = FALSE;
+ GnomeVFSMimeApplication *default_app = NULL;
+
+ g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), FALSE);
+
+ if (!attachment->priv->app) {
+ default_app = gnome_vfs_mime_get_default_application (attachment->priv->mime_type);
+ attachment->priv->app = default_app;
+ }
+
+ if (!attachment->priv->app) {
+ g_set_error (error,
+ EV_ATTACHMENT_ERROR,
+ 0,
+ _("Couldn't open attachment “%s”"),
+ attachment->priv->name);
+
+ return FALSE;
+ }
+
+ if (attachment->priv->tmp_uri &&
+ g_file_test (attachment->priv->tmp_uri, G_FILE_TEST_EXISTS)) {
+ retval = ev_attachment_launch_app (attachment, error);
+ } else {
+ gchar *uri, *filename;
+
+ filename = g_build_filename (ev_tmp_dir (), attachment->priv->name, NULL);
+ uri = g_filename_to_uri (filename, NULL, NULL);
+
+ if (ev_attachment_save (attachment, uri, error)) {
+ if (attachment->priv->tmp_uri)
+ g_free (attachment->priv->tmp_uri);
+ attachment->priv->tmp_uri = g_strdup (filename);
+
+ retval = ev_attachment_launch_app (attachment, error);
+ }
+
+ g_free (filename);
+ g_free (uri);
+ }
+
+ return retval;
+}
diff --git a/libdocument/ev-attachment.h b/libdocument/ev-attachment.h
new file mode 100644
index 0000000..994b654
--- /dev/null
+++ b/libdocument/ev-attachment.h
@@ -0,0 +1,72 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2006 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_ATTACHMENT_H__
+#define __EV_ATTACHMENT_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef struct _EvAttachment EvAttachment;
+typedef struct _EvAttachmentClass EvAttachmentClass;
+typedef struct _EvAttachmentPrivate EvAttachmentPrivate;
+
+#define EV_TYPE_ATTACHMENT (ev_attachment_get_type())
+#define EV_ATTACHMENT(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_ATTACHMENT, EvAttachment))
+#define EV_ATTACHMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_ATTACHMENT, EvAttachmentClass))
+#define EV_IS_ATTACHMENT(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_ATTACHMENT))
+#define EV_IS_ATTACHMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_ATTACHMENT))
+#define EV_ATTACHMENT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_ATTACHMENT, EvAttachmentClass))
+
+#define EV_ATTACHMENT_ERROR (ev_attachment_error_quark ())
+
+struct _EvAttachment {
+ GObject base_instance;
+
+ EvAttachmentPrivate *priv;
+};
+
+struct _EvAttachmentClass {
+ GObjectClass base_class;
+};
+
+GType ev_attachment_get_type (void) G_GNUC_CONST;
+GQuark ev_attachment_error_quark (void) G_GNUC_CONST;
+EvAttachment *ev_attachment_new (const gchar *name,
+ const gchar *description,
+ GTime mtime,
+ GTime ctime,
+ gsize size,
+ gpointer data);
+
+const gchar *ev_attachment_get_name (EvAttachment *attachment);
+const gchar *ev_attachment_get_description (EvAttachment *attachment);
+GTime ev_attachment_get_modification_date (EvAttachment *attachment);
+GTime ev_attachment_get_creation_date (EvAttachment *attachment);
+const gchar *ev_attachment_get_mime_type (EvAttachment *attachment);
+gboolean ev_attachment_save (EvAttachment *attachment,
+ const gchar *uri,
+ GError **error);
+gboolean ev_attachment_open (EvAttachment *attachment,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* __EV_ATTACHMENT_H__ */
diff --git a/libdocument/ev-backend-marshal.c b/libdocument/ev-backend-marshal.c
new file mode 100644
index 0000000..2bc7b6a
--- /dev/null
+++ b/libdocument/ev-backend-marshal.c
@@ -0,0 +1,2 @@
+#include "ev-backend-marshalers.h"
+#include "ev-backend-marshalers.c"
diff --git a/libdocument/ev-backend-marshalers.list b/libdocument/ev-backend-marshalers.list
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libdocument/ev-backend-marshalers.list
diff --git a/libdocument/ev-document-factory.c b/libdocument/ev-document-factory.c
new file mode 100644
index 0000000..348cb80
--- /dev/null
+++ b/libdocument/ev-document-factory.c
@@ -0,0 +1,463 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * Copyright (C) 2005, Red Hat, Inc.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "ev-document-factory.h"
+
+/* The various document type backends: */
+#ifdef ENABLE_PDF
+#include "ev-poppler.h"
+#endif
+#ifdef ENABLE_PS
+#include "ps-document.h"
+#endif
+#ifdef ENABLE_TIFF
+#include "tiff-document.h"
+#endif
+#ifdef ENABLE_DVI
+#include "dvi-document.h"
+#endif
+#ifdef ENABLE_PIXBUF
+#include "pixbuf-document.h"
+#endif
+#ifdef ENABLE_DJVU
+#include "djvu-document.h"
+#endif
+#ifdef ENABLE_COMICS
+#include "comics-document.h"
+#endif
+#ifdef ENABLE_IMPRESS
+#include "impress-document.h"
+#endif
+
+#include <string.h>
+#include <glib/gi18n.h>
+#include <libgnomevfs/gnome-vfs-mime-utils.h>
+#include <libgnomevfs/gnome-vfs-file-info.h>
+#include <libgnomevfs/gnome-vfs-ops.h>
+#include <gtk/gtkfilechooserdialog.h>
+
+typedef struct _EvDocumentType EvDocumentType;
+struct _EvDocumentType
+{
+ const char *mime_type;
+ EvBackend backend;
+ GType (*document_type_factory_callback)();
+};
+
+const EvDocumentType document_types[] = {
+#ifdef ENABLE_PDF
+ /* PDF: */
+ {"application/pdf", EV_BACKEND_PDF, pdf_document_get_type},
+#endif
+
+#ifdef ENABLE_PS
+ /* Postscript: */
+ {"application/postscript", EV_BACKEND_PS, ps_document_get_type},
+ {"application/x-gzpostscript", EV_BACKEND_PS, ps_document_get_type},
+ {"image/x-eps", EV_BACKEND_PS, ps_document_get_type},
+#endif
+
+#ifdef ENABLE_TIFF
+ /* Tiff: */
+ {"image/tiff", EV_BACKEND_TIFF, tiff_document_get_type},
+#endif
+
+#ifdef ENABLE_DJVU
+ /* djvu: */
+ {"image/vnd.djvu", EV_BACKEND_DJVU, djvu_document_get_type},
+#endif
+
+#ifdef ENABLE_DVI
+ /* dvi: */
+ {"application/x-dvi", EV_BACKEND_DVI, dvi_document_get_type},
+#endif
+
+#ifdef ENABLE_COMICS
+ /* cbr/cbz: */
+ {"application/x-cbr", EV_BACKEND_COMICS, comics_document_get_type},
+ {"application/x-cbz", EV_BACKEND_COMICS, comics_document_get_type},
+#endif
+
+#ifdef ENABLE_IMPRESS
+ /* Impress slides: */
+ {"application/vnd.sun.xml.impress", EV_BACKEND_IMPRESS, impress_document_get_type},
+ {"application/vnd.oasis.opendocument.presentation", EV_BACKEND_IMPRESS, impress_document_get_type},
+#endif
+
+};
+
+#ifdef ENABLE_PIXBUF
+
+static GList*
+gdk_pixbuf_mime_type_list ()
+{
+ GSList *formats, *list;
+ GList *result;
+
+ formats = gdk_pixbuf_get_formats ();
+ result = NULL;
+
+ for (list = formats; list != NULL; list = list->next) {
+ GdkPixbufFormat *format = list->data;
+ int i;
+ gchar **mime_types;
+
+ if (gdk_pixbuf_format_is_disabled (format))
+ continue;
+
+ mime_types = gdk_pixbuf_format_get_mime_types (format);
+
+ for (i = 0; mime_types[i] != NULL; i++) {
+ result = g_list_append (result, mime_types[i]);
+ }
+ }
+ g_slist_free (formats);
+
+ return result;
+}
+
+/* Would be nice to have this in gdk-pixbuf */
+static gboolean
+mime_type_supported_by_gdk_pixbuf (const gchar *mime_type)
+{
+ GList *mime_types;
+ GList *list;
+ gboolean retval = FALSE;
+
+ mime_types = gdk_pixbuf_mime_type_list ();
+ for (list = mime_types; list; list = list->next) {
+ if (strcmp ((char *)list->data, mime_type) == 0) {
+ retval = TRUE;
+ break;
+ }
+ }
+
+ g_list_foreach (mime_types, (GFunc)g_free, NULL);
+ g_list_free (mime_types);
+
+ return retval;
+}
+#endif
+
+static EvDocument*
+ev_document_factory_get_from_mime (const char *mime_type)
+{
+ int i;
+ GType type = G_TYPE_INVALID;
+ EvDocument *document = NULL;
+
+ g_return_val_if_fail (mime_type, G_TYPE_INVALID);
+
+ for (i = 0; i < G_N_ELEMENTS (document_types); i++) {
+ if (strcmp (mime_type, document_types[i].mime_type) == 0) {
+ g_assert (document_types[i].document_type_factory_callback != NULL);
+ type = document_types[i].document_type_factory_callback();
+ break;
+ }
+ }
+#ifdef ENABLE_PIXBUF
+ if (type == G_TYPE_INVALID && mime_type_supported_by_gdk_pixbuf (mime_type)) {
+ type = pixbuf_document_get_type ();
+ }
+#endif
+ if (type != G_TYPE_INVALID) {
+ document = g_object_new (type, NULL);
+ }
+
+ return document;
+}
+
+EvBackend
+ev_document_factory_get_backend (EvDocument *document)
+{
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS (document_types); i++) {
+ GType type = document_types[i].document_type_factory_callback ();
+ if (type == G_TYPE_FROM_INSTANCE (document)) {
+ return document_types[i].backend;
+ }
+ }
+
+#ifdef ENABLE_PIXBUF
+ if (G_TYPE_FROM_INSTANCE (document) == pixbuf_document_get_type ())
+ return EV_BACKEND_PIXBUF;
+#endif
+ g_assert_not_reached ();
+
+ return 0;
+}
+
+static GList *
+ev_document_factory_get_mime_types (EvBackend backend)
+{
+ GList *types = NULL;
+ int i;
+
+#ifdef ENABLE_PIXBUF
+ if (backend == EV_BACKEND_PIXBUF) {
+ return gdk_pixbuf_mime_type_list ();
+ }
+#endif
+
+ for (i = 0; i < G_N_ELEMENTS (document_types); i++) {
+ if (document_types[i].backend == backend) {
+ types = g_list_append (types, g_strdup (document_types[i].mime_type));
+ }
+ }
+
+ return types;
+}
+
+static GList *
+ev_document_factory_get_all_mime_types (void)
+{
+ GList *types = NULL;
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS (document_types); i++) {
+ types = g_list_append (types, g_strdup (document_types[i].mime_type));
+ }
+
+#ifdef ENABLE_PIXBUF
+ types = g_list_concat (types, gdk_pixbuf_mime_type_list ());
+#endif
+
+ return types;
+}
+
+static EvDocument *
+get_document_from_uri (const char *uri, gboolean slow, GError **error)
+{
+ EvDocument *document = NULL;
+
+ GnomeVFSFileInfo *info;
+ GnomeVFSResult result;
+
+ info = gnome_vfs_file_info_new ();
+ result = gnome_vfs_get_file_info (uri, info,
+ GNOME_VFS_FILE_INFO_GET_MIME_TYPE |
+ GNOME_VFS_FILE_INFO_FOLLOW_LINKS |
+ (slow ? GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE : 0));
+ if (result != GNOME_VFS_OK) {
+ g_set_error (error,
+ EV_DOCUMENT_ERROR,
+ 0,
+ gnome_vfs_result_to_string (result));
+ gnome_vfs_file_info_unref (info);
+ return NULL;
+ }
+
+ if (info->mime_type == NULL) {
+ g_set_error (error,
+ EV_DOCUMENT_ERROR,
+ 0,
+ _("Unknown MIME Type"));
+ gnome_vfs_file_info_unref (info);
+ return NULL;
+ }
+
+ document = ev_document_factory_get_from_mime (info->mime_type);
+
+ if (document == NULL) {
+ g_set_error (error,
+ EV_DOCUMENT_ERROR,
+ 0,
+ _("Unhandled MIME type: “%s”"), info->mime_type);
+ gnome_vfs_file_info_unref (info);
+ return NULL;
+ }
+
+ gnome_vfs_file_info_unref (info);
+
+ return document;
+}
+
+EvDocument *
+ev_document_factory_get_document (const char *uri, GError **error)
+{
+ EvDocument *document;
+ int result;
+
+ document = get_document_from_uri (uri, FALSE, error);
+
+ if (*error == NULL) {
+ result = ev_document_load (document, uri, error);
+
+ if (result == FALSE || *error) {
+ if (*error &&
+ (*error)->domain == EV_DOCUMENT_ERROR &&
+ (*error)->code == EV_DOCUMENT_ERROR_ENCRYPTED)
+ return document;
+ } else {
+ return document;
+ }
+ }
+
+ /* Try again with slow mime detection */
+ if (document)
+ g_object_unref (document);
+ document = NULL;
+
+ if (*error)
+ g_error_free (*error);
+ *error = NULL;
+
+ document = get_document_from_uri (uri, TRUE, error);
+
+ if (*error != NULL) {
+ return NULL;
+ }
+
+ result = ev_document_load (document, uri, error);
+
+ if (result == FALSE) {
+ if (*error == NULL) {
+ g_set_error (error,
+ EV_DOCUMENT_ERROR,
+ 0,
+ _("Unknown MIME Type"));
+ } else if ((*error)->domain == EV_DOCUMENT_ERROR &&
+ (*error)->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
+ return document;
+ }
+
+ if (document)
+ g_object_unref (document);
+ document = NULL;
+ }
+
+ return document;
+}
+
+static void
+file_filter_add_mime_list_and_free (GtkFileFilter *filter, GList *mime_types)
+{
+ GList *l;
+
+ for (l = mime_types; l != NULL; l = l->next) {
+ gtk_file_filter_add_mime_type (filter, l->data);
+ }
+
+ g_list_foreach (mime_types, (GFunc)g_free, NULL);
+ g_list_free (mime_types);
+}
+
+void
+ev_document_factory_add_filters (GtkWidget *chooser, EvDocument *document)
+{
+ EvBackend backend = 0;
+ GList *mime_types;
+ GtkFileFilter *filter;
+ GtkFileFilter *default_filter;
+ GtkFileFilter *document_filter;
+
+ if (document != NULL) {
+ backend = ev_document_factory_get_backend (document);
+ }
+
+ default_filter = document_filter = filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("All Documents"));
+ mime_types = ev_document_factory_get_all_mime_types ();
+ file_filter_add_mime_list_and_free (filter, mime_types);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
+
+#ifdef ENABLE_PS
+ if (document == NULL || backend == EV_BACKEND_PS) {
+ default_filter = filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("PostScript Documents"));
+ mime_types = ev_document_factory_get_mime_types (EV_BACKEND_PS);
+ file_filter_add_mime_list_and_free (filter, mime_types);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
+ }
+#endif
+
+#ifdef ENABLE_PDF
+ if (document == NULL || backend == EV_BACKEND_PDF) {
+ default_filter = filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("PDF Documents"));
+ mime_types = ev_document_factory_get_mime_types (EV_BACKEND_PDF);
+ file_filter_add_mime_list_and_free (filter, mime_types);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
+ }
+#endif
+
+#ifdef ENABLE_PIXBUF
+ if (document == NULL || backend == EV_BACKEND_PIXBUF) {
+ default_filter = filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Images"));
+ mime_types = ev_document_factory_get_mime_types (EV_BACKEND_PIXBUF);
+ file_filter_add_mime_list_and_free (filter, mime_types);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
+ }
+#endif
+
+#ifdef ENABLE_DVI
+ if (document == NULL || backend == EV_BACKEND_DVI) {
+ default_filter = filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("DVI Documents"));
+ mime_types = ev_document_factory_get_mime_types (EV_BACKEND_DVI);
+ file_filter_add_mime_list_and_free (filter, mime_types);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
+ }
+#endif
+
+#ifdef ENABLE_DJVU
+ if (document == NULL || backend == EV_BACKEND_DJVU) {
+ default_filter = filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Djvu Documents"));
+ mime_types = ev_document_factory_get_mime_types (EV_BACKEND_DJVU);
+ file_filter_add_mime_list_and_free (filter, mime_types);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
+ }
+#endif
+
+#ifdef ENABLE_COMICS
+ if (document == NULL || backend == EV_BACKEND_COMICS) {
+ default_filter = filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Comic Books"));
+ mime_types = ev_document_factory_get_mime_types (EV_BACKEND_COMICS);
+ file_filter_add_mime_list_and_free (filter, mime_types);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
+ }
+#endif
+
+#ifdef ENABLE_IMPRESS
+ if (document == NULL || backend == EV_BACKEND_IMPRESS) {
+ default_filter = filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Impress Slides"));
+ mime_types = ev_document_factory_get_mime_types (EV_BACKEND_IMPRESS);
+ file_filter_add_mime_list_and_free (filter, mime_types);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
+ }
+#endif
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("All Files"));
+ gtk_file_filter_add_pattern (filter, "*");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
+
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser),
+ document == NULL ? document_filter : default_filter);
+}
diff --git a/libdocument/ev-document-factory.h b/libdocument/ev-document-factory.h
new file mode 100644
index 0000000..886be69
--- /dev/null
+++ b/libdocument/ev-document-factory.h
@@ -0,0 +1,46 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * Copyright (C) 2005, Red Hat, Inc.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef EV_DOCUMENT_FACTORY_H
+#define EV_DOCUMENT_FACTORY_H
+
+#include <gtk/gtk.h>
+#include "ev-document.h"
+
+G_BEGIN_DECLS
+
+typedef enum {
+ EV_BACKEND_PDF,
+ EV_BACKEND_PS,
+ EV_BACKEND_TIFF,
+ EV_BACKEND_PIXBUF,
+ EV_BACKEND_DJVU,
+ EV_BACKEND_DVI,
+ EV_BACKEND_COMICS,
+ EV_BACKEND_IMPRESS
+} EvBackend;
+
+EvDocument* ev_document_factory_get_document (const char *uri, GError **error);
+EvBackend ev_document_factory_get_backend (EvDocument *document);
+void ev_document_factory_add_filters (GtkWidget *chooser, EvDocument *document);
+
+G_END_DECLS
+
+#endif
diff --git a/libdocument/ev-document-find.c b/libdocument/ev-document-find.c
new file mode 100644
index 0000000..02fbae2
--- /dev/null
+++ b/libdocument/ev-document-find.c
@@ -0,0 +1,126 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * Copyright (C) 2004 Red Hat, Inc.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include "ev-document-find.h"
+#include "ev-backend-marshalers.h"
+
+static void ev_document_find_base_init (gpointer g_class);
+
+GType
+ev_document_find_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ {
+ const GTypeInfo our_info =
+ {
+ sizeof (EvDocumentFindIface),
+ ev_document_find_base_init,
+ NULL,
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EvDocumentFind",
+ &our_info, (GTypeFlags)0);
+ }
+
+ return type;
+}
+
+static void
+ev_document_find_base_init (gpointer g_class)
+{
+ static gboolean initialized = FALSE;
+
+ if (!initialized) {
+ g_signal_new ("find_changed",
+ EV_TYPE_DOCUMENT_FIND,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EvDocumentFindIface, find_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE, 1,
+ G_TYPE_INT);
+
+ initialized = TRUE;
+ }
+}
+
+void
+ev_document_find_begin (EvDocumentFind *document_find,
+ int page,
+ const char *search_string,
+ gboolean case_sensitive)
+{
+ EvDocumentFindIface *iface = EV_DOCUMENT_FIND_GET_IFACE (document_find);
+
+ g_return_if_fail (search_string != NULL);
+
+ iface->begin (document_find, page, search_string, case_sensitive);
+}
+
+void
+ev_document_find_cancel (EvDocumentFind *document_find)
+{
+ EvDocumentFindIface *iface = EV_DOCUMENT_FIND_GET_IFACE (document_find);
+ iface->cancel (document_find);
+}
+
+int
+ev_document_find_page_has_results (EvDocumentFind *document_find,
+ int page)
+{
+ EvDocumentFindIface *iface = EV_DOCUMENT_FIND_GET_IFACE (document_find);
+ return iface->page_has_results (document_find, page);
+}
+
+int
+ev_document_find_get_n_results (EvDocumentFind *document_find,
+ int page)
+{
+ EvDocumentFindIface *iface = EV_DOCUMENT_FIND_GET_IFACE (document_find);
+ return iface->get_n_results (document_find, page);
+}
+
+gboolean
+ev_document_find_get_result (EvDocumentFind *document_find,
+ int page,
+ int n_result,
+ EvRectangle *rectangle)
+{
+ EvDocumentFindIface *iface = EV_DOCUMENT_FIND_GET_IFACE (document_find);
+ return iface->get_result (document_find, page, n_result, rectangle);
+}
+
+double
+ev_document_find_get_progress (EvDocumentFind *document_find)
+{
+ EvDocumentFindIface *iface = EV_DOCUMENT_FIND_GET_IFACE (document_find);
+ return iface->get_progress (document_find);
+}
+
+void
+ev_document_find_changed (EvDocumentFind *document_find, int page)
+{
+ g_signal_emit_by_name (document_find, "find_changed", page);
+}
diff --git a/libdocument/ev-document-find.h b/libdocument/ev-document-find.h
new file mode 100644
index 0000000..f365df1
--- /dev/null
+++ b/libdocument/ev-document-find.h
@@ -0,0 +1,98 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * Copyright (C) 2004 Red Hat, Inc.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef EV_DOCUMENT_FIND_H
+#define EV_DOCUMENT_FIND_H
+
+#include <glib-object.h>
+#include <glib.h>
+#include <gdk/gdk.h>
+
+#include "ev-document.h" /* For EvRectangle */
+
+G_BEGIN_DECLS
+
+#define EV_TYPE_DOCUMENT_FIND (ev_document_find_get_type ())
+#define EV_DOCUMENT_FIND(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT_FIND, EvDocumentFind))
+#define EV_DOCUMENT_FIND_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT_FIND, EvDocumentFindIface))
+#define EV_IS_DOCUMENT_FIND(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT_FIND))
+#define EV_IS_DOCUMENT_FIND_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT_FIND))
+#define EV_DOCUMENT_FIND_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_DOCUMENT_FIND, EvDocumentFindIface))
+
+typedef struct _EvDocumentFind EvDocumentFind;
+typedef struct _EvDocumentFindIface EvDocumentFindIface;
+
+struct _EvDocumentFindIface
+{
+ GTypeInterface base_iface;
+
+ /* Methods */
+
+ void (* begin) (EvDocumentFind *document_find,
+ int page,
+ const char *search_string,
+ gboolean case_sensitive);
+ void (* cancel) (EvDocumentFind *document_find);
+ int (* page_has_results) (EvDocumentFind *document_find,
+ int page);
+ int (* get_n_results) (EvDocumentFind *document_find,
+ int page);
+ gboolean (* get_result) (EvDocumentFind *document_find,
+ int page,
+ int n_result,
+ EvRectangle *rectangle);
+ double (* get_progress) (EvDocumentFind *document_find);
+
+ /* Signals */
+
+ void (* find_changed) (EvDocumentFind *document_find,
+ int page);
+};
+
+GType ev_document_find_get_type (void);
+void ev_document_find_begin (EvDocumentFind *document_find,
+ int page,
+ const char *search_string,
+ gboolean case_sensitive);
+void ev_document_find_cancel (EvDocumentFind *document_find);
+int ev_document_find_page_has_results (EvDocumentFind *document_find,
+ int page);
+int ev_document_find_get_n_results (EvDocumentFind *document_find,
+ int page);
+gboolean ev_document_find_get_result (EvDocumentFind *document_find,
+ int page,
+ int n_result,
+ EvRectangle *rectangle);
+double ev_document_find_get_progress (EvDocumentFind *document_find);
+void ev_document_find_changed (EvDocumentFind *document_find,
+ int page);
+
+/* How this interface works:
+ *
+ * begin() begins a new search, canceling any previous search.
+ *
+ * cancel() cancels a search if any, otherwise does nothing.
+ *
+ */
+
+G_END_DECLS
+
+#endif
diff --git a/libdocument/ev-document-fonts.c b/libdocument/ev-document-fonts.c
new file mode 100644
index 0000000..929c21d
--- /dev/null
+++ b/libdocument/ev-document-fonts.c
@@ -0,0 +1,74 @@
+/* ev-document-fonts.h
+ * this file is part of evince, a gnome document_fonts viewer
+ *
+ * Copyright (C) 2004 Red Hat, Inc.
+ *
+ * Author:
+ * Marco Pesenti Gritti <mpg@redhat.com>
+ *
+ * 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-document-fonts.h"
+
+GType
+ev_document_fonts_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ {
+ const GTypeInfo our_info =
+ {
+ sizeof (EvDocumentFontsIface),
+ NULL,
+ NULL,
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EvDocumentFonts",
+ &our_info, (GTypeFlags)0);
+ }
+
+ return type;
+}
+
+double
+ev_document_fonts_get_progress (EvDocumentFonts *document_fonts)
+{
+ EvDocumentFontsIface *iface = EV_DOCUMENT_FONTS_GET_IFACE (document_fonts);
+
+ return iface->get_progress (document_fonts);
+}
+
+gboolean
+ev_document_fonts_scan (EvDocumentFonts *document_fonts,
+ int n_pages)
+{
+ EvDocumentFontsIface *iface = EV_DOCUMENT_FONTS_GET_IFACE (document_fonts);
+
+ return iface->scan (document_fonts, n_pages);
+}
+
+void
+ev_document_fonts_fill_model (EvDocumentFonts *document_fonts,
+ GtkTreeModel *model)
+{
+ EvDocumentFontsIface *iface = EV_DOCUMENT_FONTS_GET_IFACE (document_fonts);
+
+ iface->fill_model (document_fonts, model);
+}
diff --git a/libdocument/ev-document-fonts.h b/libdocument/ev-document-fonts.h
new file mode 100644
index 0000000..c9f58f5
--- /dev/null
+++ b/libdocument/ev-document-fonts.h
@@ -0,0 +1,74 @@
+/* ev-document-fonts.h
+ * this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2004 Red Hat, Inc.
+ *
+ * Author:
+ * Marco Pesenti Gritti <mpg@redhat.com>
+ *
+ * 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_DOCUMENT_FONTS_H
+#define EV_DOCUMENT_FONTS_H
+
+#include <glib-object.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "ev-document.h"
+#include "ev-link.h"
+
+G_BEGIN_DECLS
+
+
+#define EV_TYPE_DOCUMENT_FONTS (ev_document_fonts_get_type ())
+#define EV_DOCUMENT_FONTS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT_FONTS, EvDocumentFonts))
+#define EV_DOCUMENT_FONTS_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT_FONTS, EvDocumentFontsIface))
+#define EV_IS_DOCUMENT_FONTS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT_FONTS))
+#define EV_IS_DOCUMENT_FONTS_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT_FONTS))
+#define EV_DOCUMENT_FONTS_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_DOCUMENT_FONTS, EvDocumentFontsIface))
+
+typedef struct _EvDocumentFonts EvDocumentFonts;
+typedef struct _EvDocumentFontsIface EvDocumentFontsIface;
+
+enum {
+ EV_DOCUMENT_FONTS_COLUMN_NAME,
+ EV_DOCUMENT_FONTS_COLUMN_DETAILS,
+ EV_DOCUMENT_FONTS_COLUMN_NUM_COLUMNS
+};
+
+struct _EvDocumentFontsIface
+{
+ GTypeInterface base_iface;
+
+ /* Methods */
+ gboolean (* scan) (EvDocumentFonts *document_fonts,
+ int n_pages);
+ double (* get_progress) (EvDocumentFonts *document_fonts);
+ void (* fill_model) (EvDocumentFonts *document_fonts,
+ GtkTreeModel *model);
+};
+
+GType ev_document_fonts_get_type (void);
+gboolean ev_document_fonts_scan (EvDocumentFonts *document_fonts,
+ int n_pages);
+double ev_document_fonts_get_progress (EvDocumentFonts *document_fonts);
+void ev_document_fonts_fill_model (EvDocumentFonts *document_fonts,
+ GtkTreeModel *model);
+
+G_END_DECLS
+
+#endif
diff --git a/libdocument/ev-document-images.c b/libdocument/ev-document-images.c
new file mode 100644
index 0000000..117b104
--- /dev/null
+++ b/libdocument/ev-document-images.c
@@ -0,0 +1,55 @@
+/* ev-document-images.c
+ * this file is part of evince, a gnome document_links viewer
+ *
+ * Copyright (C) 2006 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 "ev-document-images.h"
+
+GType
+ev_document_images_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo our_info = {
+ sizeof (EvDocumentImagesIface),
+ NULL,
+ NULL,
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EvDocumentImages",
+ &our_info, (GTypeFlags)0);
+ }
+
+ return type;
+}
+
+GList *
+ev_document_images_get_images (EvDocumentImages *document_images,
+ gint page)
+{
+ EvDocumentImagesIface *iface = EV_DOCUMENT_IMAGES_GET_IFACE (document_images);
+ GList *retval;
+
+ retval = iface->get_images (document_images, page);
+
+ return retval;
+}
+
+
diff --git a/libdocument/ev-document-images.h b/libdocument/ev-document-images.h
new file mode 100644
index 0000000..28eee46
--- /dev/null
+++ b/libdocument/ev-document-images.h
@@ -0,0 +1,55 @@
+/* ev-document-images.h
+ * this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2006 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_DOCUMENT_IMAGES_H
+#define EV_DOCUMENT_IMAGES_H
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include "ev-document.h"
+
+G_BEGIN_DECLS
+
+#define EV_TYPE_DOCUMENT_IMAGES (ev_document_images_get_type ())
+#define EV_DOCUMENT_IMAGES(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT_IMAGES, EvDocumentImages))
+#define EV_DOCUMENT_IMAGES_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT_IMAGES, EvDocumentImagesIface))
+#define EV_IS_DOCUMENT_IMAGES(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT_IMAGES))
+#define EV_IS_DOCUMENT_IMAGES_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT_IMAGES))
+#define EV_DOCUMENT_IMAGES_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_DOCUMENT_IMAGES, EvDocumentImagesIface))
+
+typedef struct _EvDocumentImages EvDocumentImages;
+typedef struct _EvDocumentImagesIface EvDocumentImagesIface;
+
+struct _EvDocumentImagesIface {
+ GTypeInterface base_iface;
+
+ /* Methods */
+ GList *(* get_images) (EvDocumentImages *document_images,
+ gint page);
+};
+
+GType ev_document_images_get_type (void) G_GNUC_CONST;
+GList *ev_document_images_get_images (EvDocumentImages *document_images,
+ gint page);
+
+G_END_DECLS
+
+#endif /* EV_DOCUMENT_IMAGES_H */
diff --git a/libdocument/ev-document-info.h b/libdocument/ev-document-info.h
new file mode 100644
index 0000000..0cd1ef8
--- /dev/null
+++ b/libdocument/ev-document-info.h
@@ -0,0 +1,126 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * Copyright (C) 2000-2003 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef EV_DOCUMENT_INFO_H
+#define EV_DOCUMENT_INFO_H
+
+#include <glib-object.h>
+#include <glib.h>
+#include "ev-link.h"
+
+G_BEGIN_DECLS
+
+typedef struct _EvDocumentInfo EvDocumentInfo;
+
+typedef enum
+{
+ EV_DOCUMENT_LAYOUT_SINGLE_PAGE,
+ EV_DOCUMENT_LAYOUT_ONE_COLUMN,
+ EV_DOCUMENT_LAYOUT_TWO_COLUMN_LEFT,
+ EV_DOCUMENT_LAYOUT_TWO_COLUMN_RIGHT,
+ EV_DOCUMENT_LAYOUT_TWO_PAGE_LEFT,
+ EV_DOCUMENT_LAYOUT_TWO_PAGE_RIGHT,
+} EvDocumentLayout;
+
+typedef enum
+{
+ EV_DOCUMENT_MODE_NONE,
+ EV_DOCUMENT_MODE_USE_OC,
+ EV_DOCUMENT_MODE_USE_THUMBS,
+ EV_DOCUMENT_MODE_FULL_SCREEN,
+ EV_DOCUMENT_MODE_USE_ATTACHMENTS,
+ EV_DOCUMENT_MODE_PRESENTATION = EV_DOCUMENT_MODE_FULL_SCREEN /* Will these be different? */
+} EvDocumentMode;
+
+typedef enum
+{
+ EV_DOCUMENT_UI_HINT_HIDE_TOOLBAR = 1 << 0,
+ EV_DOCUMENT_UI_HINT_HIDE_MENUBAR = 1 << 1,
+ EV_DOCUMENT_UI_HINT_HIDE_WINDOWUI = 1 << 2,
+ 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,
+} EvDocumentUIHints;
+
+
+typedef enum
+{
+ EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT = 1 << 0,
+ 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),
+} EvDocumentPermissions;
+
+typedef enum
+{
+ EV_DOCUMENT_INFO_TITLE = 1 << 0,
+ EV_DOCUMENT_INFO_FORMAT = 1 << 1,
+ EV_DOCUMENT_INFO_AUTHOR = 1 << 2,
+ EV_DOCUMENT_INFO_SUBJECT = 1 << 3,
+ EV_DOCUMENT_INFO_KEYWORDS = 1 << 4,
+ EV_DOCUMENT_INFO_LAYOUT = 1 << 5,
+ EV_DOCUMENT_INFO_CREATOR = 1 << 6,
+ EV_DOCUMENT_INFO_PRODUCER = 1 << 7,
+ EV_DOCUMENT_INFO_CREATION_DATE = 1 << 8,
+ EV_DOCUMENT_INFO_MOD_DATE = 1 << 9,
+ EV_DOCUMENT_INFO_LINEARIZED = 1 << 10,
+ EV_DOCUMENT_INFO_START_MODE = 1 << 11,
+ EV_DOCUMENT_INFO_UI_HINTS = 1 << 12,
+ EV_DOCUMENT_INFO_PERMISSIONS = 1 << 13,
+ EV_DOCUMENT_INFO_N_PAGES = 1 << 14,
+ EV_DOCUMENT_INFO_SECURITY = 1 << 15,
+ EV_DOCUMENT_INFO_PAPER_SIZE = 1 << 16
+} EvDocumentInfoFields;
+
+struct _EvDocumentInfo
+{
+ char *title;
+ char *format; /* eg, "pdf-1.5" */
+ char *author;
+ char *subject;
+ char *keywords;
+ char *creator;
+ char *producer;
+ char *linearized;
+ char *security;
+ GTime creation_date;
+ GTime modified_date;
+ EvDocumentLayout layout;
+ EvDocumentMode mode;
+ guint ui_hints;
+ guint permissions;
+ int n_pages;
+ double paper_height;
+ double paper_width;
+
+ /* Mask of all the valid fields */
+ guint fields_mask;
+};
+
+void ev_document_info_free (EvDocumentInfo *info);
+
+G_END_DECLS
+
+#endif /* EV_DOCUMENT_INFO_H */
diff --git a/libdocument/ev-document-links.c b/libdocument/ev-document-links.c
new file mode 100644
index 0000000..c717096
--- /dev/null
+++ b/libdocument/ev-document-links.c
@@ -0,0 +1,94 @@
+/* ev-document-links.h
+ * this file is part of evince, a gnome document_links viewer
+ *
+ * Copyright (C) 2004 Red Hat, Inc.
+ *
+ * Author:
+ * Jonathan Blandford <jrb@alum.mit.edu>
+ *
+ * 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-document-links.h"
+
+GType
+ev_document_links_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo our_info = {
+ sizeof (EvDocumentLinksIface),
+ NULL,
+ NULL,
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EvDocumentLinks",
+ &our_info, (GTypeFlags)0);
+ }
+
+ return type;
+}
+
+gboolean
+ev_document_links_has_document_links (EvDocumentLinks *document_links)
+{
+ EvDocumentLinksIface *iface = EV_DOCUMENT_LINKS_GET_IFACE (document_links);
+ gboolean retval;
+
+ retval = iface->has_document_links (document_links);
+
+ return retval;
+}
+
+GtkTreeModel *
+ev_document_links_get_links_model (EvDocumentLinks *document_links)
+{
+ EvDocumentLinksIface *iface = EV_DOCUMENT_LINKS_GET_IFACE (document_links);
+ GtkTreeModel *retval;
+
+ retval = iface->get_links_model (document_links);
+
+ return retval;
+}
+
+GList *
+ev_document_links_get_links (EvDocumentLinks *document_links,
+ gint page)
+{
+ EvDocumentLinksIface *iface = EV_DOCUMENT_LINKS_GET_IFACE (document_links);
+ GList *retval;
+
+ retval = iface->get_links (document_links, page);
+
+ return retval;
+}
+
+EvLinkDest *
+ev_document_links_find_link_dest (EvDocumentLinks *document_links,
+ const gchar *link_name)
+{
+ EvDocumentLinksIface *iface = EV_DOCUMENT_LINKS_GET_IFACE (document_links);
+ EvLinkDest *retval;
+
+ ev_document_doc_mutex_lock ();
+ retval = iface->find_link_dest (document_links, link_name);
+ ev_document_doc_mutex_unlock ();
+
+ return retval;
+}
diff --git a/libdocument/ev-document-links.h b/libdocument/ev-document-links.h
new file mode 100644
index 0000000..8e8f20a
--- /dev/null
+++ b/libdocument/ev-document-links.h
@@ -0,0 +1,78 @@
+/* ev-document-links.h
+ * this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2004 Red Hat, Inc.
+ *
+ * Author:
+ * Jonathan Blandford <jrb@alum.mit.edu>
+ *
+ * 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_DOCUMENT_LINKS_H
+#define EV_DOCUMENT_LINKS_H
+
+#include <glib-object.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "ev-document.h"
+#include "ev-link.h"
+
+G_BEGIN_DECLS
+
+
+#define EV_TYPE_DOCUMENT_LINKS (ev_document_links_get_type ())
+#define EV_DOCUMENT_LINKS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT_LINKS, EvDocumentLinks))
+#define EV_DOCUMENT_LINKS_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT_LINKS, EvDocumentLinksIface))
+#define EV_IS_DOCUMENT_LINKS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT_LINKS))
+#define EV_IS_DOCUMENT_LINKS_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT_LINKS))
+#define EV_DOCUMENT_LINKS_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_DOCUMENT_LINKS, EvDocumentLinksIface))
+
+typedef struct _EvDocumentLinks EvDocumentLinks;
+typedef struct _EvDocumentLinksIface EvDocumentLinksIface;
+
+enum {
+ EV_DOCUMENT_LINKS_COLUMN_MARKUP,
+ EV_DOCUMENT_LINKS_COLUMN_LINK,
+ EV_DOCUMENT_LINKS_COLUMN_EXPAND,
+ EV_DOCUMENT_LINKS_COLUMN_NUM_COLUMNS
+};
+
+struct _EvDocumentLinksIface
+{
+ GTypeInterface base_iface;
+
+ /* Methods */
+ gboolean (* has_document_links) (EvDocumentLinks *document_links);
+ GtkTreeModel *(* get_links_model) (EvDocumentLinks *document_links);
+ GList *(* get_links) (EvDocumentLinks *document_links,
+ gint page);
+ EvLinkDest *(* find_link_dest) (EvDocumentLinks *document_links,
+ const gchar *link_name);
+};
+
+GType ev_document_links_get_type (void);
+gboolean ev_document_links_has_document_links (EvDocumentLinks *document_links);
+GtkTreeModel *ev_document_links_get_links_model (EvDocumentLinks *document_links);
+
+GList *ev_document_links_get_links (EvDocumentLinks *document_links,
+ gint page);
+EvLinkDest *ev_document_links_find_link_dest (EvDocumentLinks *document_links,
+ const gchar *link_name);
+
+G_END_DECLS
+
+#endif
diff --git a/libdocument/ev-document-misc.c b/libdocument/ev-document-misc.c
new file mode 100644
index 0000000..fd6f449
--- /dev/null
+++ b/libdocument/ev-document-misc.c
@@ -0,0 +1,141 @@
+
+#include "ev-document-misc.h"
+#include <string.h>
+#include <gtk/gtk.h>
+
+/* Returns a new GdkPixbuf that is suitable for placing in the thumbnail view.
+ * It is four pixels wider and taller than the source. If source_pixbuf is not
+ * NULL, then it will fill the return pixbuf with the contents of
+ * source_pixbuf.
+ */
+
+GdkPixbuf *
+ev_document_misc_get_thumbnail_frame (int width,
+ int height,
+ int rotation,
+ GdkPixbuf *source_pixbuf)
+{
+ GdkPixbuf *retval;
+ guchar *data;
+ gint rowstride;
+ int i;
+ int width_r, height_r;
+
+ rotation = rotation % 360;
+
+
+ if (source_pixbuf)
+ g_return_val_if_fail (GDK_IS_PIXBUF (source_pixbuf), NULL);
+
+ if (source_pixbuf) {
+ width_r = gdk_pixbuf_get_width (source_pixbuf);
+ height_r = gdk_pixbuf_get_height (source_pixbuf);
+ } else {
+ if (rotation == 0 || rotation == 180) {
+ width_r = width;
+ height_r = height;
+ } else if (rotation == 90 || rotation == 270) {
+ width_r = height;
+ height_r = width;
+ } else {
+ g_assert_not_reached ();
+ }
+ }
+
+ /* make sure no one is passing us garbage */
+ g_assert (width_r >= 0 && height_r >= 0);
+
+ retval = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ TRUE, 8,
+ width_r + 4,
+ height_r + 4);
+
+ /* make it black and fill in the middle */
+ data = gdk_pixbuf_get_pixels (retval);
+ rowstride = gdk_pixbuf_get_rowstride (retval);
+
+ gdk_pixbuf_fill (retval, 0x000000ff);
+ for (i = 1; i < height_r + 1; i++)
+ memset (data + (rowstride * i) + 4, 0xffffffff, width_r * 4);
+
+ /* copy the source pixbuf */
+ if (source_pixbuf)
+ gdk_pixbuf_copy_area (source_pixbuf, 0, 0,
+ width_r,
+ height_r,
+ retval,
+ 1, 1);
+ /* Add the corner */
+ data [(width_r + 2) * 4 + 3] = 0;
+ data [(width_r + 3) * 4 + 3] = 0;
+ data [(width_r + 2) * 4 + (rowstride * 1) + 3] = 0;
+ data [(width_r + 3) * 4 + (rowstride * 1) + 3] = 0;
+
+ data [(height_r + 2) * rowstride + 3] = 0;
+ data [(height_r + 3) * rowstride + 3] = 0;
+ data [(height_r + 2) * rowstride + 4 + 3] = 0;
+ data [(height_r + 3) * rowstride + 4 + 3] = 0;
+
+ return retval;
+}
+
+void
+ev_document_misc_get_page_border_size (gint page_width,
+ gint page_height,
+ GtkBorder *border)
+{
+ g_assert (border);
+
+ border->left = 1;
+ border->top = 1;
+ if (page_width < 100) {
+ border->right = 2;
+ border->bottom = 2;
+ } else if (page_width < 500) {
+ border->right = 3;
+ border->bottom = 3;
+ } else {
+ border->right = 4;
+ border->bottom = 4;
+ }
+}
+
+
+void
+ev_document_misc_paint_one_page (GdkDrawable *drawable,
+ GtkWidget *widget,
+ GdkRectangle *area,
+ GtkBorder *border,
+ gboolean highlight)
+{
+ gdk_draw_rectangle (drawable,
+ highlight ?
+ widget->style->text_gc[widget->state] : widget->style->dark_gc[widget->state],
+ TRUE,
+ area->x,
+ area->y,
+ area->width,
+ area->height);
+ gdk_draw_rectangle (drawable,
+ widget->style->white_gc,
+ TRUE,
+ area->x + border->left,
+ area->y + border->top,
+ area->width - (border->left + border->right),
+ area->height - (border->top + border->bottom));
+ gdk_draw_rectangle (drawable,
+ widget->style->mid_gc[widget->state],
+ TRUE,
+ area->x,
+ area->y + area->height - (border->bottom - border->top),
+ border->bottom - border->top,
+ border->bottom - border->top);
+ gdk_draw_rectangle (drawable,
+ widget->style->mid_gc[widget->state],
+ TRUE,
+ area->x + area->width - (border->right - border->left),
+ area->y,
+ border->right - border->left,
+ border->right - border->left);
+
+}
diff --git a/libdocument/ev-document-misc.h b/libdocument/ev-document-misc.h
new file mode 100644
index 0000000..41f1cae
--- /dev/null
+++ b/libdocument/ev-document-misc.h
@@ -0,0 +1,47 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * Copyright (C) 2000-2003 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef EV_DOCUMENT_MISC_H
+#define EV_DOCUMENT_MISC_H
+
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gtk/gtkstyle.h>
+
+G_BEGIN_DECLS
+
+
+GdkPixbuf *ev_document_misc_get_thumbnail_frame (int width,
+ int height,
+ int rotation,
+ GdkPixbuf *source_pixbuf);
+void ev_document_misc_get_page_border_size (gint page_width,
+ gint page_height,
+ GtkBorder *border);
+void ev_document_misc_paint_one_page (GdkDrawable *drawable,
+ GtkWidget *widget,
+ GdkRectangle *area,
+ GtkBorder *border,
+ gboolean highlight);
+
+G_END_DECLS
+
+#endif /* EV_DOCUMENT_MISC_H */
diff --git a/libdocument/ev-document-security.c b/libdocument/ev-document-security.c
new file mode 100644
index 0000000..49ded87
--- /dev/null
+++ b/libdocument/ev-document-security.c
@@ -0,0 +1,63 @@
+/* ev-document-links.h
+ * this file is part of evince, a gnome document_links viewer
+ *
+ * Copyright (C) 2004 Red Hat, Inc.
+ *
+ * Author:
+ * Jonathan Blandford <jrb@alum.mit.edu>
+ *
+ * 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-document-security.h"
+
+GType
+ev_document_security_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ {
+ const GTypeInfo our_info =
+ {
+ sizeof (EvDocumentSecurityIface),
+ NULL,
+ NULL,
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EvDocumentSecurity",
+ &our_info, (GTypeFlags)0);
+ }
+
+ return type;
+}
+
+gboolean
+ev_document_security_has_document_security (EvDocumentSecurity *document_security)
+{
+ EvDocumentSecurityIface *iface = EV_DOCUMENT_SECURITY_GET_IFACE (document_security);
+ return iface->has_document_security (document_security);
+}
+
+void
+ev_document_security_set_password (EvDocumentSecurity *document_security,
+ const char *password)
+{
+ EvDocumentSecurityIface *iface = EV_DOCUMENT_SECURITY_GET_IFACE (document_security);
+ iface->set_password (document_security, password);
+}
diff --git a/libdocument/ev-document-security.h b/libdocument/ev-document-security.h
new file mode 100644
index 0000000..154a3b1
--- /dev/null
+++ b/libdocument/ev-document-security.h
@@ -0,0 +1,63 @@
+/* ev-document-security.h
+ * this file is part of evince, a gnome pdf viewer
+ *
+ * Copyright (C) 2005 Red Hat, Inc.
+ *
+ * Author:
+ * Jonathan Blandford <jrb@alum.mit.edu>
+ *
+ * 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_DOCUMENT_SECURITY_H
+#define EV_DOCUMENT_SECURITY_H
+
+#include <glib-object.h>
+#include <glib.h>
+#include <gdk/gdk.h>
+
+#include "ev-document.h"
+
+G_BEGIN_DECLS
+
+
+#define EV_TYPE_DOCUMENT_SECURITY (ev_document_security_get_type ())
+#define EV_DOCUMENT_SECURITY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT_SECURITY, EvDocumentSecurity))
+#define EV_DOCUMENT_SECURITY_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT_SECURITY, EvDocumentSecurityIface))
+#define EV_IS_DOCUMENT_SECURITY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT_SECURITY))
+#define EV_IS_DOCUMENT_SECURITY_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT_SECURITY))
+#define EV_DOCUMENT_SECURITY_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_DOCUMENT_SECURITY, EvDocumentSecurityIface))
+
+typedef struct _EvDocumentSecurity EvDocumentSecurity;
+typedef struct _EvDocumentSecurityIface EvDocumentSecurityIface;
+
+struct _EvDocumentSecurityIface
+{
+ GTypeInterface base_iface;
+
+ /* Methods */
+ gboolean (* has_document_security) (EvDocumentSecurity *document_security);
+ void (* set_password) (EvDocumentSecurity *document_security,
+ const char *password);
+};
+
+GType ev_document_security_get_type (void);
+gboolean ev_document_security_has_document_security (EvDocumentSecurity *document_security);
+void ev_document_security_set_password (EvDocumentSecurity *document_security,
+ const char *password);
+
+G_END_DECLS
+
+#endif
diff --git a/libdocument/ev-document-thumbnails.c b/libdocument/ev-document-thumbnails.c
new file mode 100644
index 0000000..c560cec
--- /dev/null
+++ b/libdocument/ev-document-thumbnails.c
@@ -0,0 +1,79 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * Copyright (C) 2004 Anders Carlsson <andersca@gnome.org>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include "ev-document-thumbnails.h"
+
+GType
+ev_document_thumbnails_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ {
+ const GTypeInfo our_info =
+ {
+ sizeof (EvDocumentThumbnailsIface),
+ NULL,
+ NULL,
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EvDocumentThumbnails",
+ &our_info, (GTypeFlags)0);
+ }
+
+ return type;
+}
+
+GdkPixbuf *
+ev_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
+ gint page,
+ int rotation,
+ gint size,
+ gboolean border)
+{
+ EvDocumentThumbnailsIface *iface;
+
+ g_return_val_if_fail (EV_IS_DOCUMENT_THUMBNAILS (document), NULL);
+
+ iface = EV_DOCUMENT_THUMBNAILS_GET_IFACE (document);
+
+ return iface->get_thumbnail (document, page, rotation, size, border);
+}
+
+void
+ev_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
+ gint page,
+ gint suggested_width,
+ gint *width,
+ gint *height)
+{
+ EvDocumentThumbnailsIface *iface;
+
+ g_return_if_fail (EV_IS_DOCUMENT_THUMBNAILS (document));
+ g_return_if_fail (width != NULL);
+ g_return_if_fail (height != NULL);
+
+ iface = EV_DOCUMENT_THUMBNAILS_GET_IFACE (document);
+ iface->get_dimensions (document, page, suggested_width, width, height);
+}
+
diff --git a/libdocument/ev-document-thumbnails.h b/libdocument/ev-document-thumbnails.h
new file mode 100644
index 0000000..6e15a32
--- /dev/null
+++ b/libdocument/ev-document-thumbnails.h
@@ -0,0 +1,77 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * Copyright (C) 2004 Anders Carlsson
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef EV_DOCUMENT_THUMBNAILS_H
+#define EV_DOCUMENT_THUMBNAILS_H
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+#include "ev-render-context.h"
+
+G_BEGIN_DECLS
+
+#define EV_TYPE_DOCUMENT_THUMBNAILS (ev_document_thumbnails_get_type ())
+#define EV_DOCUMENT_THUMBNAILS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT_THUMBNAILS, EvDocumentThumbnails))
+#define EV_DOCUMENT_THUMBNAILS_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT_THUMBNAILS, EvDocumentThumbnailsIface))
+#define EV_IS_DOCUMENT_THUMBNAILS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT_THUMBNAILS))
+#define EV_IS_DOCUMENT_THUMBNAILS_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT_THUMBNAILS))
+#define EV_DOCUMENT_THUMBNAILS_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_DOCUMENT_THUMBNAILS, EvDocumentThumbnailsIface))
+
+typedef struct _EvDocumentThumbnails EvDocumentThumbnails;
+typedef struct _EvDocumentThumbnailsIface EvDocumentThumbnailsIface;
+
+struct _EvDocumentThumbnailsIface
+{
+ GTypeInterface base_iface;
+
+ /* Methods */
+ GdkPixbuf * (* get_thumbnail) (EvDocumentThumbnails *document,
+ gint page,
+ gint rotation,
+ gint size,
+ gboolean border);
+ void (* get_dimensions) (EvDocumentThumbnails *document,
+ gint page,
+ gint suggested_width,
+ gint *width,
+ gint *height);
+};
+
+GType ev_document_thumbnails_get_type (void);
+
+/* FIXME: This is a little bit busted. We call get_thumbnail w/ a suggested
+ * width, but we should call it with a scale so that different sized pages get
+ * sized proportionally.
+ */
+
+GdkPixbuf *ev_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
+ gint page,
+ gint rotation,
+ gint size,
+ gboolean border);
+void ev_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
+ gint page,
+ gint size,
+ gint *width,
+ gint *height);
+
+G_END_DECLS
+
+#endif
diff --git a/libdocument/ev-document-transition.c b/libdocument/ev-document-transition.c
new file mode 100644
index 0000000..274da7c
--- /dev/null
+++ b/libdocument/ev-document-transition.c
@@ -0,0 +1,55 @@
+/* ev-document-transition.c
+ * this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2006 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 "ev-document-transition.h"
+
+GType
+ev_document_transition_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo our_info = {
+ sizeof (EvDocumentTransitionIface),
+ NULL,
+ NULL,
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EvDocumentTransition",
+ &our_info, (GTypeFlags)0);
+ }
+
+ return type;
+}
+
+gdouble
+ev_document_transition_get_page_duration (EvDocumentTransition *document_trans,
+ gint page)
+{
+ EvDocumentTransitionIface *iface = EV_DOCUMENT_TRANSITION_GET_IFACE (document_trans);
+
+ if (iface->get_page_duration)
+ return iface->get_page_duration (document_trans, page);
+
+ return -1;
+}
+
+
diff --git a/libdocument/ev-document-transition.h b/libdocument/ev-document-transition.h
new file mode 100644
index 0000000..3ca55ab
--- /dev/null
+++ b/libdocument/ev-document-transition.h
@@ -0,0 +1,56 @@
+/* ev-document-transition.h
+ * this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2006 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_DOCUMENT_TRANSITION_H
+#define EV_DOCUMENT_TRANSITION_H
+
+#include <glib-object.h>
+
+#include "ev-document.h"
+
+G_BEGIN_DECLS
+
+#define EV_TYPE_DOCUMENT_TRANSITION (ev_document_transition_get_type ())
+#define EV_DOCUMENT_TRANSITION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT_TRANSITION, EvDocumentTransition))
+#define EV_DOCUMENT_TRANSITION_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT_TRANSITION, EvDocumentTransitionIface))
+#define EV_IS_DOCUMENT_TRANSITION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT_TRANSITION))
+#define EV_IS_DOCUMENT_TRANSITION_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT_TRANSITION))
+#define EV_DOCUMENT_TRANSITION_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_DOCUMENT_TRANSITION, EvDocumentTransitionIface))
+
+typedef struct _EvDocumentTransition EvDocumentTransition;
+typedef struct _EvDocumentTransitionIface EvDocumentTransitionIface;
+
+struct _EvDocumentTransitionIface
+{
+ GTypeInterface base_iface;
+
+ /* Methods */
+ gdouble (* get_page_duration) (EvDocumentTransition *document_trans,
+ gint page);
+ /* TODO: Support page transition effects (page 562 PDF Reference 1.6) */
+};
+
+GType ev_document_transition_get_type (void) G_GNUC_CONST;
+gdouble ev_document_transition_get_page_duration (EvDocumentTransition *document_trans,
+ gint page);
+
+G_END_DECLS
+
+#endif /* EV_DOCUMENT_TRANSITION_H */
diff --git a/libdocument/ev-document.c b/libdocument/ev-document.c
new file mode 100644
index 0000000..a951bfa
--- /dev/null
+++ b/libdocument/ev-document.c
@@ -0,0 +1,281 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include "ev-document.h"
+
+#include "ev-backend-marshalers.h"
+
+static void ev_document_class_init (gpointer g_class);
+
+
+GMutex *ev_doc_mutex = NULL;
+GMutex *ev_fc_mutex = NULL;
+
+#define LOG(x)
+GType
+ev_document_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ {
+ const GTypeInfo our_info =
+ {
+ sizeof (EvDocumentIface),
+ NULL,
+ NULL,
+ (GClassInitFunc)ev_document_class_init
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EvDocument",
+ &our_info, (GTypeFlags)0);
+ }
+
+ return type;
+}
+
+GQuark
+ev_document_error_quark (void)
+{
+ static GQuark q = 0;
+ if (q == 0)
+ q = g_quark_from_static_string ("ev-document-error-quark");
+
+ return q;
+}
+
+static void
+ev_document_class_init (gpointer g_class)
+{
+}
+
+GMutex *
+ev_document_get_doc_mutex (void)
+{
+ if (ev_doc_mutex == NULL) {
+ ev_doc_mutex = g_mutex_new ();
+ }
+ return ev_doc_mutex;
+}
+
+void
+ev_document_doc_mutex_lock (void)
+{
+ g_mutex_lock (ev_document_get_doc_mutex ());
+}
+
+void
+ev_document_doc_mutex_unlock (void)
+{
+ g_mutex_unlock (ev_document_get_doc_mutex ());
+}
+
+GMutex *
+ev_document_get_fc_mutex (void)
+{
+ if (ev_fc_mutex == NULL) {
+ ev_fc_mutex = g_mutex_new ();
+ }
+ return ev_fc_mutex;
+}
+
+void
+ev_document_fc_mutex_lock (void)
+{
+ g_mutex_lock (ev_document_get_fc_mutex ());
+}
+
+void
+ev_document_fc_mutex_unlock (void)
+{
+ g_mutex_unlock (ev_document_get_fc_mutex ());
+}
+
+gboolean
+ev_document_load (EvDocument *document,
+ const char *uri,
+ GError **error)
+{
+ EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+ gboolean retval;
+ LOG ("ev_document_load");
+ retval = iface->load (document, uri, error);
+
+ return retval;
+}
+
+gboolean
+ev_document_save (EvDocument *document,
+ const char *uri,
+ GError **error)
+{
+ EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+ gboolean retval;
+
+ LOG ("ev_document_save");
+ retval = iface->save (document, uri, error);
+
+ return retval;
+}
+
+int
+ev_document_get_n_pages (EvDocument *document)
+{
+ EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+ gint retval;
+
+ LOG ("ev_document_get_n_pages");
+ retval = iface->get_n_pages (document);
+
+ return retval;
+}
+
+void
+ev_document_get_page_size (EvDocument *document,
+ int page,
+ double *width,
+ double *height)
+{
+ EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+
+ LOG ("ev_document_get_page_size");
+ iface->get_page_size (document, page, width, height);
+}
+
+char *
+ev_document_get_page_label(EvDocument *document,
+ int page)
+{
+ EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+
+ LOG ("ev_document_get_page_label");
+ if (iface->get_page_label == NULL)
+ return NULL;
+
+ return iface->get_page_label (document, page);
+}
+
+gboolean
+ev_document_can_get_text (EvDocument *document)
+{
+ EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+
+ return iface->can_get_text (document);
+}
+
+EvDocumentInfo *
+ev_document_get_info (EvDocument *document)
+{
+ EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+
+ return iface->get_info (document);
+}
+
+char *
+ev_document_get_text (EvDocument *document,
+ int page,
+ EvRectangle *rect)
+{
+ EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+ char *retval;
+
+ LOG ("ev_document_get_text");
+ retval = iface->get_text (document, page, rect);
+
+ return retval;
+}
+
+gboolean
+ev_document_has_attachments (EvDocument *document)
+{
+ EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+
+ if (iface->has_attachments == NULL)
+ return FALSE;
+
+ return iface->has_attachments (document);
+}
+
+GList *
+ev_document_get_attachments (EvDocument *document)
+{
+ EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+ GList *retval;
+
+ LOG ("ev_document_get_attachments");
+ if (iface->get_attachments == NULL)
+ return NULL;
+ retval = iface->get_attachments (document);
+
+ return retval;
+}
+
+GdkPixbuf *
+ev_document_render_pixbuf (EvDocument *document,
+ EvRenderContext *rc)
+{
+ EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+ GdkPixbuf *retval;
+
+ LOG ("ev_document_render_pixbuf");
+ g_assert (iface->render_pixbuf);
+
+ retval = iface->render_pixbuf (document, rc);
+
+ return retval;
+}
+
+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->security);
+
+ g_free (info);
+}
+
+
+/* Compares two rects. returns 0 if they're equal */
+#define EPSILON 0.0000001
+
+gint
+ev_rect_cmp (EvRectangle *a,
+ EvRectangle *b)
+{
+ if (a == b)
+ return 0;
+ if (a == NULL || b == NULL)
+ return 1;
+
+ return ! ((ABS (a->x1 - b->x1) < EPSILON) &&
+ (ABS (a->y1 - b->y1) < EPSILON) &&
+ (ABS (a->x2 - b->x2) < EPSILON) &&
+ (ABS (a->y2 - b->y2) < EPSILON));
+}
diff --git a/libdocument/ev-document.h b/libdocument/ev-document.h
new file mode 100644
index 0000000..828ca25
--- /dev/null
+++ b/libdocument/ev-document.h
@@ -0,0 +1,140 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * Copyright (C) 2000-2003 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef EV_DOCUMENT_H
+#define EV_DOCUMENT_H
+
+#include <glib-object.h>
+#include <glib.h>
+#include <gdk/gdk.h>
+
+#include "ev-link.h"
+#include "ev-document-info.h"
+#include "ev-render-context.h"
+
+G_BEGIN_DECLS
+
+#define EV_TYPE_DOCUMENT (ev_document_get_type ())
+#define EV_DOCUMENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT, EvDocument))
+#define EV_DOCUMENT_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT, EvDocumentIface))
+#define EV_IS_DOCUMENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT))
+#define EV_IS_DOCUMENT_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT))
+#define EV_DOCUMENT_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_DOCUMENT, EvDocumentIface))
+
+typedef struct _EvDocument EvDocument;
+typedef struct _EvDocumentIface EvDocumentIface;
+typedef struct _EvPageCache EvPageCache;
+typedef struct _EvPageCacheClass EvPageCacheClass;
+
+#define EV_DOCUMENT_ERROR ev_document_error_quark ()
+#define EV_DOC_MUTEX_LOCK (ev_document_doc_mutex_lock ())
+#define EV_DOC_MUTEX_UNLOCK (ev_document_doc_mutex_unlock ())
+
+typedef enum
+{
+ EV_DOCUMENT_ERROR_INVALID,
+ EV_DOCUMENT_ERROR_ENCRYPTED
+} EvDocumentError;
+
+typedef struct {
+ double x;
+ double y;
+} EvPoint;
+
+typedef struct {
+ double x1;
+ double y1;
+ double x2;
+ double y2;
+} EvRectangle;
+
+struct _EvDocumentIface
+{
+ GTypeInterface base_iface;
+
+ /* Methods */
+ gboolean (* load) (EvDocument *document,
+ const char *uri,
+ GError **error);
+ gboolean (* save) (EvDocument *document,
+ const char *uri,
+ GError **error);
+ int (* get_n_pages) (EvDocument *document);
+ void (* get_page_size) (EvDocument *document,
+ int page,
+ double *width,
+ double *height);
+ char * (* get_page_label) (EvDocument *document,
+ int page);
+ gboolean (* can_get_text) (EvDocument *document);
+ char * (* get_text) (EvDocument *document,
+ int page,
+ EvRectangle *rect);
+ gboolean (* has_attachments) (EvDocument *document);
+ GList * (* get_attachments) (EvDocument *document);
+ GdkPixbuf * (* render_pixbuf) (EvDocument *document,
+ EvRenderContext *rc);
+ EvDocumentInfo * (* get_info) (EvDocument *document);
+};
+
+GType ev_document_get_type (void);
+GQuark ev_document_error_quark (void);
+
+/* Document mutex */
+GMutex *ev_document_get_doc_mutex (void);
+void ev_document_doc_mutex_lock (void);
+void ev_document_doc_mutex_unlock (void);
+
+/* FontConfig mutex */
+GMutex *ev_document_fc_doc_mutex (void);
+void ev_document_fc_mutex_lock (void);
+void ev_document_fc_mutex_unlock (void);
+
+EvDocumentInfo *ev_document_get_info (EvDocument *document);
+gboolean ev_document_load (EvDocument *document,
+ const char *uri,
+ GError **error);
+gboolean ev_document_save (EvDocument *document,
+ const char *uri,
+ GError **error);
+int ev_document_get_n_pages (EvDocument *document);
+void ev_document_get_page_size (EvDocument *document,
+ int page,
+ double *width,
+ double *height);
+char *ev_document_get_page_label (EvDocument *document,
+ int page);
+gboolean ev_document_can_get_text (EvDocument *document);
+char *ev_document_get_text (EvDocument *document,
+ int page,
+ EvRectangle *rect);
+gboolean ev_document_has_attachments (EvDocument *document);
+GList *ev_document_get_attachments (EvDocument *document);
+GdkPixbuf *ev_document_render_pixbuf (EvDocument *document,
+ EvRenderContext *rc);
+
+gint ev_rect_cmp (EvRectangle *a,
+ EvRectangle *b);
+
+
+G_END_DECLS
+
+#endif
diff --git a/libdocument/ev-file-exporter.c b/libdocument/ev-file-exporter.c
new file mode 100644
index 0000000..7a4e902
--- /dev/null
+++ b/libdocument/ev-file-exporter.c
@@ -0,0 +1,91 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2004 Martin Kretzschmar
+ *
+ * Author:
+ * Martin Kretzschmar <martink@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 "ev-file-exporter.h"
+
+GType
+ev_file_exporter_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo our_info =
+ {
+ sizeof (EvFileExporterIface),
+ NULL,
+ NULL,
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EvFileExporter",
+ &our_info, (GTypeFlags)0);
+ }
+
+ return type;
+}
+
+gboolean
+ev_file_exporter_format_supported (EvFileExporter *exporter,
+ EvFileExporterFormat format)
+{
+ EvFileExporterIface *iface = EV_FILE_EXPORTER_GET_IFACE (exporter);
+
+ if (format < EV_FILE_FORMAT_PS ||
+ format > EV_FILE_FORMAT_PDF)
+ return FALSE;
+
+ return iface->format_supported (exporter, format);
+}
+
+void
+ev_file_exporter_begin (EvFileExporter *exporter,
+ EvFileExporterFormat format,
+ const gchar *filename,
+ gint first_page,
+ gint last_page,
+ gdouble paper_width,
+ gdouble paper_height,
+ gboolean duplex)
+{
+ EvFileExporterIface *iface = EV_FILE_EXPORTER_GET_IFACE (exporter);
+
+ g_return_if_fail (ev_file_exporter_format_supported (exporter, format));
+
+ iface->begin (exporter, format, filename, first_page, last_page,
+ paper_width, paper_height, duplex);
+}
+
+void
+ev_file_exporter_do_page (EvFileExporter *exporter, EvRenderContext *rc)
+{
+ EvFileExporterIface *iface = EV_FILE_EXPORTER_GET_IFACE (exporter);
+
+ iface->do_page (exporter, rc);
+}
+
+void
+ev_file_exporter_end (EvFileExporter *exporter)
+{
+ EvFileExporterIface *iface = EV_FILE_EXPORTER_GET_IFACE (exporter);
+
+ iface->end (exporter);
+}
diff --git a/libdocument/ev-file-exporter.h b/libdocument/ev-file-exporter.h
new file mode 100644
index 0000000..f0e517c
--- /dev/null
+++ b/libdocument/ev-file-exporter.h
@@ -0,0 +1,84 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2004 Martin Kretzschmar
+ *
+ * Author:
+ * Martin Kretzschmar <martink@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_FILE_EXPORTER_H
+#define EV_FILE_EXPORTER_H
+
+#include <glib-object.h>
+
+#include "ev-render-context.h"
+
+G_BEGIN_DECLS
+
+typedef enum {
+ EV_FILE_FORMAT_PS,
+ EV_FILE_FORMAT_PDF,
+ EV_FILE_FORMAT_UNKNOWN
+} EvFileExporterFormat;
+
+#define EV_TYPE_FILE_EXPORTER (ev_file_exporter_get_type ())
+#define EV_FILE_EXPORTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_FILE_EXPORTER, EvFileExporter))
+#define EV_FILE_EXPORTER_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_FILE_EXPORTER, EvFileExporterIface))
+#define EV_IS_FILE_EXPORTER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_FILE_EXPORTER))
+#define EV_IS_FILE_EXPORTER_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_FILE_EXPORTER))
+#define EV_FILE_EXPORTER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_FILE_EXPORTER, EvFileExporterIface))
+
+typedef struct _EvFileExporter EvFileExporter;
+typedef struct _EvFileExporterIface EvFileExporterIface;
+
+struct _EvFileExporterIface {
+ GTypeInterface base_iface;
+
+ /* Methods */
+ gboolean (* format_supported) (EvFileExporter *exporter,
+ EvFileExporterFormat format);
+ void (* begin) (EvFileExporter *exporter,
+ EvFileExporterFormat format,
+ const gchar *filename,
+ gint first_page,
+ gint last_page,
+ gdouble paper_width,
+ gdouble paper_height,
+ gboolean duplex);
+ void (* do_page) (EvFileExporter *exporter,
+ EvRenderContext *rc);
+ void (* end) (EvFileExporter *exporter);
+};
+
+GType ev_file_exporter_get_type (void) G_GNUC_CONST;
+gboolean ev_file_exporter_format_supported (EvFileExporter *exporter,
+ EvFileExporterFormat format);
+void ev_file_exporter_begin (EvFileExporter *exporter,
+ EvFileExporterFormat format,
+ const gchar *filename,
+ gint first_page,
+ gint last_page,
+ gdouble paper_width,
+ gdouble paper_height,
+ gboolean duplex);
+void ev_file_exporter_do_page (EvFileExporter *exporter,
+ EvRenderContext *rc);
+void ev_file_exporter_end (EvFileExporter *exporter);
+
+G_END_DECLS
+
+#endif
diff --git a/libdocument/ev-file-helpers.c b/libdocument/ev-file-helpers.c
new file mode 100644
index 0000000..b6a50b6
--- /dev/null
+++ b/libdocument/ev-file-helpers.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2002 Jorn Baayen
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <errno.h>
+#include <libgnomevfs/gnome-vfs-uri.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
+#include <libgnomevfs/gnome-vfs-ops.h>
+#include <libgnomevfs/gnome-vfs-xfer.h>
+
+#include "ev-file-helpers.h"
+
+static gchar *dot_dir = NULL;
+static gchar *tmp_dir = NULL;
+static gint count = 0;
+
+static gboolean
+ensure_dir_exists (const char *dir)
+{
+ if (g_file_test (dir, G_FILE_TEST_IS_DIR))
+ return TRUE;
+
+ if (g_mkdir (dir, 488) == 0)
+ return TRUE;
+
+ if (errno == EEXIST)
+ return g_file_test (dir, G_FILE_TEST_IS_DIR);
+
+ g_warning ("Failed to create directory %s: %s", dir, strerror (errno));
+ return FALSE;
+}
+
+const gchar *
+ev_dot_dir (void)
+{
+ if (dot_dir == NULL) {
+ gboolean exists;
+
+ dot_dir = g_build_filename (gnome_user_dir_get (),
+ "evince",
+ NULL);
+
+ exists = ensure_dir_exists (dot_dir);
+ if (!exists)
+ exit (1);
+ }
+
+ return dot_dir;
+}
+
+const gchar *
+ev_tmp_dir (void)
+{
+ if (tmp_dir == NULL) {
+ gboolean exists;
+ gchar *dirname;
+
+ dirname = g_strdup_printf ("evince-%u", getpid ());
+ tmp_dir = g_build_filename (g_get_tmp_dir (),
+ dirname,
+ NULL);
+ g_free (dirname);
+
+ exists = ensure_dir_exists (tmp_dir);
+ g_assert (exists);
+ }
+
+ return tmp_dir;
+}
+
+void
+ev_file_helpers_init (void)
+{
+}
+
+void
+ev_file_helpers_shutdown (void)
+{
+ if (tmp_dir != NULL)
+ g_rmdir (tmp_dir);
+
+ g_free (tmp_dir);
+ g_free (dot_dir);
+
+ dot_dir = NULL;
+ tmp_dir = NULL;
+}
+
+gchar *
+ev_tmp_filename (const gchar *prefix)
+{
+ gchar *basename;
+ gchar *filename = NULL;
+
+ do {
+ if (filename != NULL)
+ g_free (filename);
+
+ basename = g_strdup_printf ("%s-%d",
+ prefix ? prefix : "document",
+ count ++);
+
+ filename = g_build_filename (ev_tmp_dir (),
+ basename, NULL);
+
+ g_free (basename);
+ } while (g_file_test (filename, G_FILE_TEST_EXISTS));
+
+ return filename;
+}
+
+gboolean
+ev_xfer_uri_simple (const char *from,
+ const char *to,
+ GError **error)
+{
+ GnomeVFSResult result;
+ GnomeVFSURI *source_uri;
+ GnomeVFSURI *target_uri;
+
+ if (!from)
+ return FALSE;
+
+ source_uri = gnome_vfs_uri_new (from);
+ target_uri = gnome_vfs_uri_new (to);
+
+ result = gnome_vfs_xfer_uri (source_uri, target_uri,
+ GNOME_VFS_XFER_DEFAULT | GNOME_VFS_XFER_FOLLOW_LINKS,
+ GNOME_VFS_XFER_ERROR_MODE_ABORT,
+ GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
+ NULL,
+ NULL);
+ gnome_vfs_uri_unref (target_uri);
+ gnome_vfs_uri_unref (source_uri);
+
+ if (result != GNOME_VFS_OK)
+ g_set_error (error,
+ G_FILE_ERROR,
+ G_FILE_ERROR_FAILED,
+ gnome_vfs_result_to_string (result));
+ return (result == GNOME_VFS_OK);
+
+}
diff --git a/libdocument/ev-file-helpers.h b/libdocument/ev-file-helpers.h
new file mode 100644
index 0000000..4e75a14
--- /dev/null
+++ b/libdocument/ev-file-helpers.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2002 Jorn Baayen
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef EPHY_FILE_HELPERS_H
+#define EPHY_FILE_HELPERS_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+const gchar *ev_dot_dir (void);
+
+const gchar *ev_tmp_dir (void);
+
+void ev_file_helpers_init (void);
+
+void ev_file_helpers_shutdown (void);
+
+gchar* ev_tmp_filename (const char *prefix);
+
+gboolean ev_xfer_uri_simple (const char *from,
+ const char *to,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* EPHY_FILE_HELPERS_H */
diff --git a/libdocument/ev-image.c b/libdocument/ev-image.c
new file mode 100644
index 0000000..f906b00
--- /dev/null
+++ b/libdocument/ev-image.c
@@ -0,0 +1,167 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2006 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 <glib/gstdio.h>
+#include "ev-file-helpers.h"
+#include "ev-image.h"
+
+struct _EvImagePrivate {
+ GdkPixbuf *pixbuf;
+ gchar *tmp_uri;
+};
+
+#define EV_IMAGE_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_IMAGE, EvImagePrivate))
+
+G_DEFINE_TYPE (EvImage, ev_image, G_TYPE_OBJECT)
+
+static void
+ev_image_finalize (GObject *object)
+{
+ EvImage *image = EV_IMAGE (object);
+
+ if (image->priv->pixbuf) {
+ g_object_unref (image->priv->pixbuf);
+ image->priv->pixbuf = NULL;
+ }
+
+ if (image->priv->tmp_uri) {
+ g_unlink (image->priv->tmp_uri);
+ g_free (image->priv->tmp_uri);
+ image->priv->tmp_uri = NULL;
+ }
+
+ (* G_OBJECT_CLASS (ev_image_parent_class)->finalize) (object);
+}
+
+static void
+ev_image_class_init (EvImageClass *klass)
+{
+ GObjectClass *g_object_class;
+
+ g_object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (g_object_class, sizeof (EvImagePrivate));
+
+ g_object_class->finalize = ev_image_finalize;
+}
+
+static void
+ev_image_init (EvImage *image)
+{
+ image->priv = EV_IMAGE_GET_PRIVATE (image);
+}
+
+EvImage *
+ev_image_new_from_pixbuf (GdkPixbuf *pixbuf)
+{
+ EvImage *image;
+
+ g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
+
+ image = EV_IMAGE (g_object_new (EV_TYPE_IMAGE, NULL));
+ image->priv->pixbuf = g_object_ref (pixbuf);
+
+ return image;
+}
+
+GdkPixbuf *
+ev_image_get_pixbuf (EvImage *image)
+{
+ g_return_val_if_fail (EV_IS_IMAGE (image), NULL);
+ g_return_val_if_fail (GDK_IS_PIXBUF (image->priv->pixbuf), NULL);
+
+ return image->priv->pixbuf;
+}
+
+const gchar *
+ev_image_save_tmp (EvImage *image)
+{
+ GError *error = NULL;
+
+ g_return_val_if_fail (EV_IS_IMAGE (image), NULL);
+ g_return_val_if_fail (GDK_IS_PIXBUF (image->priv->pixbuf), NULL);
+
+ if (image->priv->tmp_uri)
+ return image->priv->tmp_uri;
+
+ image->priv->tmp_uri = ev_tmp_filename ("image");
+ gdk_pixbuf_save (image->priv->pixbuf,
+ image->priv->tmp_uri, "png", &error,
+ "compression", "3", NULL);
+ if (!error)
+ return image->priv->tmp_uri;
+
+ /* Erro saving image */
+ g_warning (error->message);
+ g_error_free (error);
+ g_free (image->priv->tmp_uri);
+ image->priv->tmp_uri = NULL;
+
+ return NULL;
+}
+
+const gchar *
+ev_image_get_tmp_uri (EvImage *image)
+{
+ g_return_val_if_fail (EV_IS_IMAGE (image), NULL);
+
+ return image->priv->tmp_uri;
+}
+
+/* EvImageMapping */
+static void
+ev_image_mapping_free_foreach (EvImageMapping *mapping)
+{
+ g_object_unref (mapping->image);
+ g_free (mapping);
+}
+
+void
+ev_image_mapping_free (GList *image_mapping)
+{
+ if (!image_mapping)
+ return;
+
+ g_list_foreach (image_mapping, (GFunc) ev_image_mapping_free_foreach, NULL);
+ g_list_free (image_mapping);
+}
+
+EvImage *
+ev_image_mapping_find (GList *image_mapping,
+ gdouble x,
+ gdouble y)
+{
+ GList *list;
+
+ for (list = image_mapping; list; list = list->next) {
+ EvImageMapping *mapping = list->data;
+
+ if ((x >= mapping->x1) &&
+ (y >= mapping->y1) &&
+ (x <= mapping->x2) &&
+ (y <= mapping->y2)) {
+ return mapping->image;
+ }
+ }
+
+ return NULL;
+}
+
+
diff --git a/libdocument/ev-image.h b/libdocument/ev-image.h
new file mode 100644
index 0000000..6688e7a
--- /dev/null
+++ b/libdocument/ev-image.h
@@ -0,0 +1,74 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2006 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_IMAGE_H__
+#define __EV_IMAGE_H__
+
+#include <glib-object.h>
+#include <gdk/gdkpixbuf.h>
+
+G_BEGIN_DECLS
+
+typedef struct _EvImage EvImage;
+typedef struct _EvImageClass EvImageClass;
+typedef struct _EvImagePrivate EvImagePrivate;
+
+#define EV_TYPE_IMAGE (ev_image_get_type())
+#define EV_IMAGE(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_IMAGE, EvImage))
+#define EV_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_IMAGE, EvImageClass))
+#define EV_IS_IMAGE(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_IMAGE))
+#define EV_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_IMAGE))
+#define EV_IMAGE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_IMAGE, EvImageClass))
+
+struct _EvImage {
+ GObject base_instance;
+
+ EvImagePrivate *priv;
+};
+
+struct _EvImageClass {
+ GObjectClass base_class;
+};
+
+GType ev_image_get_type (void) G_GNUC_CONST;
+EvImage *ev_image_new_from_pixbuf (GdkPixbuf *pixbuf);
+
+GdkPixbuf *ev_image_get_pixbuf (EvImage *image);
+const gchar *ev_image_save_tmp (EvImage *image);
+const gchar *ev_image_get_tmp_uri (EvImage *image);
+
+
+/* Image Mapping stuff */
+typedef struct _EvImageMapping EvImageMapping;
+struct _EvImageMapping {
+ EvImage *image;
+ gdouble x1;
+ gdouble y1;
+ gdouble x2;
+ gdouble y2;
+};
+
+void ev_image_mapping_free (GList *image_mapping);
+EvImage *ev_image_mapping_find (GList *image_mapping,
+ gdouble x,
+ gdouble y);
+
+G_END_DECLS
+
+#endif /* __EV_IMAGE_H__ */
diff --git a/libdocument/ev-link-action.c b/libdocument/ev-link-action.c
new file mode 100644
index 0000000..bc0a8fc
--- /dev/null
+++ b/libdocument/ev-link-action.c
@@ -0,0 +1,360 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2006 Carlos Garcia Campos <carlosgc@gnome.org>
+ * Copyright (C) 2005 Red Hat, Inc.
+ *
+ * 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 "ev-link-action.h"
+
+enum {
+ PROP_0,
+ PROP_TYPE,
+ PROP_DEST,
+ PROP_URI,
+ PROP_FILENAME,
+ PROP_PARAMS,
+ PROP_NAME
+};
+
+struct _EvLinkAction {
+ GObject base_instance;
+
+ EvLinkActionPrivate *priv;
+};
+
+struct _EvLinkActionClass {
+ GObjectClass base_class;
+};
+
+struct _EvLinkActionPrivate {
+ EvLinkActionType type;
+ EvLinkDest *dest;
+ gchar *uri;
+ gchar *filename;
+ gchar *params;
+ gchar *name;
+};
+
+G_DEFINE_TYPE (EvLinkAction, ev_link_action, G_TYPE_OBJECT)
+
+#define EV_LINK_ACTION_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_LINK_ACTION, EvLinkActionPrivate))
+
+GType
+ev_link_action_type_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GEnumValue values[] = {
+ { EV_LINK_ACTION_TYPE_GOTO_DEST, "EV_LINK_ACTION_TYPE_GOTO_DEST", "goto-dest" },
+ { EV_LINK_ACTION_TYPE_GOTO_REMOTE, "EV_LINK_ACTION_TYPE_GOTO_REMOTE", "goto-remote" },
+ { EV_LINK_ACTION_TYPE_LAUNCH, "EV_LINK_ACTION_TYPE_LAUNCH", "launch" },
+ { EV_LINK_ACTION_TYPE_EXTERNAL_URI, "EV_LINK_ACTION_TYPE_EXTERNAL_URI", "external-uri"},
+ { EV_LINK_ACTION_TYPE_NAMED, "EV_LINK_ACTION_TYPE_NAMED", "named"},
+ { 0, NULL, NULL }
+ };
+
+ type = g_enum_register_static ("EvLinkActionType", values);
+ }
+
+ return type;
+}
+
+EvLinkActionType
+ev_link_action_get_action_type (EvLinkAction *self)
+{
+ g_return_val_if_fail (EV_IS_LINK_ACTION (self), 0);
+
+ return self->priv->type;
+}
+
+EvLinkDest *
+ev_link_action_get_dest (EvLinkAction *self)
+{
+ g_return_val_if_fail (EV_IS_LINK_ACTION (self), NULL);
+
+ return self->priv->dest;
+}
+
+const gchar *
+ev_link_action_get_uri (EvLinkAction *self)
+{
+ g_return_val_if_fail (EV_IS_LINK_ACTION (self), NULL);
+
+ return self->priv->uri;
+}
+
+const gchar *
+ev_link_action_get_filename (EvLinkAction *self)
+{
+ g_return_val_if_fail (EV_IS_LINK_ACTION (self), NULL);
+
+ return self->priv->filename;
+}
+
+const gchar *
+ev_link_action_get_params (EvLinkAction *self)
+{
+ g_return_val_if_fail (EV_IS_LINK_ACTION (self), NULL);
+
+ return self->priv->params;
+}
+
+const gchar *
+ev_link_action_get_name (EvLinkAction *self)
+{
+ g_return_val_if_fail (EV_IS_LINK_ACTION (self), NULL);
+
+ return self->priv->name;
+}
+
+static void
+ev_link_action_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *param_spec)
+{
+ EvLinkAction *self;
+
+ self = EV_LINK_ACTION (object);
+
+ switch (prop_id) {
+ case PROP_TYPE:
+ g_value_set_enum (value, self->priv->type);
+ break;
+ case PROP_DEST:
+ g_value_set_pointer (value, self->priv->dest);
+ break;
+ case PROP_URI:
+ g_value_set_string (value, self->priv->uri);
+ break;
+ case PROP_FILENAME:
+ g_value_set_string (value, self->priv->filename);
+ break;
+ case PROP_PARAMS:
+ g_value_set_string (value, self->priv->params);
+ break;
+ case PROP_NAME:
+ g_value_set_string (value, self->priv->name);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+ prop_id,
+ param_spec);
+ break;
+ }
+}
+
+static void
+ev_link_action_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *param_spec)
+{
+ EvLinkAction *self = EV_LINK_ACTION (object);
+
+ switch (prop_id) {
+ case PROP_TYPE:
+ self->priv->type = g_value_get_enum (value);
+ break;
+ case PROP_DEST:
+ self->priv->dest = g_value_get_pointer (value);
+ break;
+ case PROP_URI:
+ g_free (self->priv->uri);
+ self->priv->uri = g_value_dup_string (value);
+ break;
+ case PROP_FILENAME:
+ g_free (self->priv->filename);
+ self->priv->filename = g_value_dup_string (value);
+ break;
+ case PROP_PARAMS:
+ g_free (self->priv->params);
+ self->priv->params = g_value_dup_string (value);
+ break;
+ case PROP_NAME:
+ g_free (self->priv->name);
+ self->priv->name = g_value_dup_string (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+ prop_id,
+ param_spec);
+ break;
+ }
+}
+
+static void
+ev_link_action_finalize (GObject *object)
+{
+ EvLinkActionPrivate *priv;
+
+ priv = EV_LINK_ACTION (object)->priv;
+
+ if (priv->dest) {
+ g_object_unref (priv->dest);
+ priv->dest = NULL;
+ }
+
+ if (priv->uri) {
+ g_free (priv->uri);
+ priv->uri = NULL;
+ }
+
+ if (priv->filename) {
+ g_free (priv->filename);
+ priv->filename = NULL;
+ }
+
+ if (priv->params) {
+ g_free (priv->params);
+ priv->params = NULL;
+ }
+
+ if (priv->name) {
+ g_free (priv->name);
+ priv->name = NULL;
+ }
+
+ G_OBJECT_CLASS (ev_link_action_parent_class)->finalize (object);
+}
+
+static void
+ev_link_action_init (EvLinkAction *ev_link_action)
+{
+ ev_link_action->priv = EV_LINK_ACTION_GET_PRIVATE (ev_link_action);
+
+ ev_link_action->priv->dest = NULL;
+ ev_link_action->priv->uri = NULL;
+ ev_link_action->priv->filename = NULL;
+ ev_link_action->priv->params = NULL;
+ ev_link_action->priv->name = NULL;
+}
+
+static void
+ev_link_action_class_init (EvLinkActionClass *ev_link_action_class)
+{
+ GObjectClass *g_object_class;
+
+ g_object_class = G_OBJECT_CLASS (ev_link_action_class);
+
+ g_object_class->set_property = ev_link_action_set_property;
+ g_object_class->get_property = ev_link_action_get_property;
+
+ g_object_class->finalize = ev_link_action_finalize;
+
+ g_type_class_add_private (g_object_class, sizeof (EvLinkActionPrivate));
+
+ g_object_class_install_property (g_object_class,
+ PROP_TYPE,
+ g_param_spec_enum ("type",
+ "Action Type",
+ "The link action type",
+ EV_TYPE_LINK_ACTION_TYPE,
+ EV_LINK_ACTION_TYPE_GOTO_DEST,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_DEST,
+ g_param_spec_pointer ("dest",
+ "Action destination",
+ "The link action destination",
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_URI,
+ g_param_spec_string ("uri",
+ "Link Action URI",
+ "The link action URI",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_FILENAME,
+ g_param_spec_string ("filename",
+ "Filename",
+ "The link action filename",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_PARAMS,
+ g_param_spec_string ("params",
+ "Params",
+ "The link action params",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_NAME,
+ g_param_spec_string ("name",
+ "Name",
+ "The link action name",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+}
+
+EvLinkAction *
+ev_link_action_new_dest (EvLinkDest *dest)
+{
+ return EV_LINK_ACTION (g_object_new (EV_TYPE_LINK_ACTION,
+ "dest", dest,
+ "type", EV_LINK_ACTION_TYPE_GOTO_DEST,
+ NULL));
+}
+
+EvLinkAction *
+ev_link_action_new_remote (EvLinkDest *dest,
+ const gchar *filename)
+{
+ return EV_LINK_ACTION (g_object_new (EV_TYPE_LINK_ACTION,
+ "dest", dest,
+ "filename", filename,
+ "type", EV_LINK_ACTION_TYPE_GOTO_REMOTE,
+ NULL));
+}
+
+EvLinkAction *
+ev_link_action_new_external_uri (const gchar *uri)
+{
+ return EV_LINK_ACTION (g_object_new (EV_TYPE_LINK_ACTION,
+ "uri", uri,
+ "type", EV_LINK_ACTION_TYPE_EXTERNAL_URI,
+ NULL));
+}
+
+EvLinkAction *
+ev_link_action_new_launch (const gchar *filename,
+ const gchar *params)
+{
+ return EV_LINK_ACTION (g_object_new (EV_TYPE_LINK_ACTION,
+ "filename", filename,
+ "params", params,
+ "type", EV_LINK_ACTION_TYPE_LAUNCH,
+ NULL));
+}
+
+EvLinkAction *
+ev_link_action_new_named (const gchar *name)
+{
+ return EV_LINK_ACTION (g_object_new (EV_TYPE_LINK_ACTION,
+ "name", name,
+ "type", EV_LINK_ACTION_TYPE_NAMED,
+ NULL));
+}
diff --git a/libdocument/ev-link-action.h b/libdocument/ev-link-action.h
new file mode 100644
index 0000000..32211fe
--- /dev/null
+++ b/libdocument/ev-link-action.h
@@ -0,0 +1,72 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2006 Carlos Garcia Campos <carlosgc@gnome.org>
+ * Copyright (C) 2005 Red Hat, Inc.
+ *
+ * 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_LINK_ACTION_H
+#define EV_LINK_ACTION_H
+
+#include <glib-object.h>
+#include "ev-link-dest.h"
+
+G_BEGIN_DECLS
+
+typedef struct _EvLinkAction EvLinkAction;
+typedef struct _EvLinkActionClass EvLinkActionClass;
+typedef struct _EvLinkActionPrivate EvLinkActionPrivate;
+
+#define EV_TYPE_LINK_ACTION (ev_link_action_get_type())
+#define EV_LINK_ACTION(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_LINK_ACTION, EvLinkAction))
+#define EV_LINK_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_LINK_ACTION, EvLinkActionClass))
+#define EV_IS_LINK_ACTION(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_LINK_ACTION))
+#define EV_IS_LINK_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_LINK_ACTION))
+#define EV_LINK_ACTION_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_LINK_ACTION, EvLinkActionClass))
+
+#define EV_TYPE_LINK_ACTION_TYPE (ev_link_action_type_get_type ())
+
+typedef enum {
+ EV_LINK_ACTION_TYPE_GOTO_DEST,
+ EV_LINK_ACTION_TYPE_GOTO_REMOTE,
+ EV_LINK_ACTION_TYPE_EXTERNAL_URI,
+ EV_LINK_ACTION_TYPE_LAUNCH,
+ EV_LINK_ACTION_TYPE_NAMED
+ /* We'll probably fill this in more as we support the other types of
+ * actions */
+} EvLinkActionType;
+
+GType ev_link_action_type_get_type (void) G_GNUC_CONST;
+GType ev_link_action_get_type (void) G_GNUC_CONST;
+
+EvLinkActionType ev_link_action_get_action_type (EvLinkAction *self);
+EvLinkDest *ev_link_action_get_dest (EvLinkAction *self);
+const gchar *ev_link_action_get_uri (EvLinkAction *self);
+const gchar *ev_link_action_get_filename (EvLinkAction *self);
+const gchar *ev_link_action_get_params (EvLinkAction *self);
+const gchar *ev_link_action_get_name (EvLinkAction *self);
+
+EvLinkAction *ev_link_action_new_dest (EvLinkDest *dest);
+EvLinkAction *ev_link_action_new_remote (EvLinkDest *dest,
+ const gchar *filename);
+EvLinkAction *ev_link_action_new_external_uri (const gchar *uri);
+EvLinkAction *ev_link_action_new_launch (const gchar *filename,
+ const gchar *params);
+EvLinkAction *ev_link_action_new_named (const gchar *name);
+
+G_END_DECLS
+
+#endif /* EV_LINK_ACTION_H */
diff --git a/libdocument/ev-link-dest.c b/libdocument/ev-link-dest.c
new file mode 100644
index 0000000..09f840a
--- /dev/null
+++ b/libdocument/ev-link-dest.c
@@ -0,0 +1,467 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2006 Carlos Garcia Campos <carlosgc@gnome.org>
+ * Copyright (C) 2005 Red Hat, Inc.
+ *
+ * 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 "ev-link-dest.h"
+
+enum {
+ PROP_0,
+ PROP_TYPE,
+ PROP_PAGE,
+ PROP_LEFT,
+ PROP_TOP,
+ PROP_BOTTOM,
+ PROP_RIGHT,
+ PROP_ZOOM,
+ PROP_NAMED,
+ PROP_PAGE_LABEL
+};
+
+struct _EvLinkDest {
+ GObject base_instance;
+
+ EvLinkDestPrivate *priv;
+};
+
+struct _EvLinkDestClass {
+ GObjectClass base_class;
+};
+
+struct _EvLinkDestPrivate {
+ EvLinkDestType type;
+ int page;
+ double top;
+ double left;
+ double bottom;
+ double right;
+ double zoom;
+ gchar *named;
+ gchar *page_label;
+};
+
+G_DEFINE_TYPE (EvLinkDest, ev_link_dest, G_TYPE_OBJECT)
+
+#define EV_LINK_DEST_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_LINK_DEST, EvLinkDestPrivate))
+
+GType
+ev_link_dest_type_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GEnumValue values[] = {
+ { EV_LINK_DEST_TYPE_PAGE, "EV_LINK_DEST_TYPE_PAGE", "page" },
+ { EV_LINK_DEST_TYPE_XYZ, "EV_LINK_DEST_TYPE_XYZ", "xyz" },
+ { EV_LINK_DEST_TYPE_FIT, "EV_LINK_DEST_TYPE_FIT", "fit" },
+ { EV_LINK_DEST_TYPE_FITH, "EV_LINK_DEST_TYPE_FITH", "fith" },
+ { EV_LINK_DEST_TYPE_FITV, "EV_LINK_DEST_TYPE_FITV", "fitv" },
+ { EV_LINK_DEST_TYPE_FITR, "EV_LINK_DEST_TYPE_FITR", "fitr" },
+ { EV_LINK_DEST_TYPE_NAMED, "EV_LINK_DEST_TYPE_NAMED", "named" },
+ { EV_LINK_DEST_TYPE_PAGE_LABEL, "EV_LINK_DEST_TYPE_PAGE_LABEL", "page_label" },
+ { EV_LINK_DEST_TYPE_UNKNOWN, "EV_LINK_DEST_TYPE_UNKNOWN", "unknown" },
+ { 0, NULL, NULL }
+ };
+
+ type = g_enum_register_static ("EvLinkDestType", values);
+ }
+
+ return type;
+}
+
+EvLinkDestType
+ev_link_dest_get_dest_type (EvLinkDest *self)
+{
+ g_return_val_if_fail (EV_IS_LINK_DEST (self), 0);
+
+ return self->priv->type;
+}
+
+gint
+ev_link_dest_get_page (EvLinkDest *self)
+{
+ g_return_val_if_fail (EV_IS_LINK_DEST (self), -1);
+
+ return self->priv->page;
+}
+
+gdouble
+ev_link_dest_get_top (EvLinkDest *self)
+{
+ g_return_val_if_fail (EV_IS_LINK_DEST (self), 0);
+
+ return self->priv->top;
+}
+
+gdouble
+ev_link_dest_get_left (EvLinkDest *self)
+{
+ g_return_val_if_fail (EV_IS_LINK_DEST (self), 0);
+
+ return self->priv->left;
+}
+
+gdouble
+ev_link_dest_get_bottom (EvLinkDest *self)
+{
+ g_return_val_if_fail (EV_IS_LINK_DEST (self), 0);
+
+ return self->priv->bottom;
+}
+
+gdouble
+ev_link_dest_get_right (EvLinkDest *self)
+{
+ g_return_val_if_fail (EV_IS_LINK_DEST (self), 0);
+
+ return self->priv->right;
+}
+
+gdouble
+ev_link_dest_get_zoom (EvLinkDest *self)
+{
+ g_return_val_if_fail (EV_IS_LINK_DEST (self), 0);
+
+ return self->priv->zoom;
+}
+
+const gchar *
+ev_link_dest_get_named_dest (EvLinkDest *self)
+{
+ g_return_val_if_fail (EV_IS_LINK_DEST (self), NULL);
+
+ return self->priv->named;
+}
+
+const gchar *
+ev_link_dest_get_page_label (EvLinkDest *self)
+{
+ g_return_val_if_fail (EV_IS_LINK_DEST (self), NULL);
+
+ return self->priv->page_label;
+}
+
+static void
+ev_link_dest_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *param_spec)
+{
+ EvLinkDest *self;
+
+ self = EV_LINK_DEST (object);
+
+ switch (prop_id) {
+ case PROP_TYPE:
+ g_value_set_enum (value, self->priv->type);
+ break;
+ case PROP_PAGE:
+ g_value_set_int (value, self->priv->page);
+ break;
+ case PROP_TOP:
+ g_value_set_double (value, self->priv->top);
+ break;
+ case PROP_LEFT:
+ g_value_set_double (value, self->priv->left);
+ break;
+ case PROP_BOTTOM:
+ g_value_set_double (value, self->priv->bottom);
+ break;
+ case PROP_RIGHT:
+ g_value_set_double (value, self->priv->left);
+ break;
+ case PROP_ZOOM:
+ g_value_set_double (value, self->priv->zoom);
+ break;
+ case PROP_NAMED:
+ g_value_set_string (value, self->priv->named);
+ break;
+ case PROP_PAGE_LABEL:
+ g_value_set_string (value, self->priv->page_label);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+ prop_id,
+ param_spec);
+ break;
+ }
+}
+
+static void
+ev_link_dest_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *param_spec)
+{
+ EvLinkDest *self = EV_LINK_DEST (object);
+
+ switch (prop_id) {
+ case PROP_TYPE:
+ self->priv->type = g_value_get_enum (value);
+ break;
+ case PROP_PAGE:
+ self->priv->page = g_value_get_int (value);
+ break;
+ case PROP_TOP:
+ self->priv->top = g_value_get_double (value);
+ break;
+ case PROP_LEFT:
+ self->priv->left = g_value_get_double (value);
+ break;
+ case PROP_BOTTOM:
+ self->priv->bottom = g_value_get_double (value);
+ break;
+ case PROP_RIGHT:
+ self->priv->right = g_value_get_double (value);
+ break;
+ case PROP_ZOOM:
+ self->priv->zoom = g_value_get_double (value);
+ break;
+ case PROP_NAMED:
+ self->priv->named = g_value_dup_string (value);
+ break;
+ case PROP_PAGE_LABEL:
+ self->priv->page_label = g_value_dup_string (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+ prop_id,
+ param_spec);
+ break;
+ }
+}
+
+static void
+ev_link_dest_finalize (GObject *object)
+{
+ EvLinkDestPrivate *priv;
+
+ priv = EV_LINK_DEST (object)->priv;
+
+ if (priv->named) {
+ g_free (priv->named);
+ priv->named = NULL;
+ }
+ if (priv->page_label) {
+ g_free (priv->page_label);
+ priv->page_label = NULL;
+ }
+
+ G_OBJECT_CLASS (ev_link_dest_parent_class)->finalize (object);
+}
+
+static void
+ev_link_dest_init (EvLinkDest *ev_link_dest)
+{
+ ev_link_dest->priv = EV_LINK_DEST_GET_PRIVATE (ev_link_dest);
+
+ ev_link_dest->priv->named = NULL;
+}
+
+static void
+ev_link_dest_class_init (EvLinkDestClass *ev_link_dest_class)
+{
+ GObjectClass *g_object_class;
+
+ g_object_class = G_OBJECT_CLASS (ev_link_dest_class);
+
+ g_object_class->set_property = ev_link_dest_set_property;
+ g_object_class->get_property = ev_link_dest_get_property;
+
+ g_object_class->finalize = ev_link_dest_finalize;
+
+ g_type_class_add_private (g_object_class, sizeof (EvLinkDestPrivate));
+
+ g_object_class_install_property (g_object_class,
+ PROP_TYPE,
+ g_param_spec_enum ("type",
+ "Dest Type",
+ "The destination type",
+ EV_TYPE_LINK_DEST_TYPE,
+ EV_LINK_DEST_TYPE_UNKNOWN,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_PAGE,
+ g_param_spec_int ("page",
+ "Dest Page",
+ "The destination page",
+ -1,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_LEFT,
+ g_param_spec_double ("left",
+ "Left coordinate",
+ "The left coordinate",
+ -G_MAXDOUBLE,
+ G_MAXDOUBLE,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_TOP,
+ g_param_spec_double ("top",
+ "Top coordinate",
+ "The top coordinate",
+ -G_MAXDOUBLE,
+ G_MAXDOUBLE,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_BOTTOM,
+ g_param_spec_double ("bottom",
+ "Bottom coordinate",
+ "The bottom coordinate",
+ -G_MAXDOUBLE,
+ G_MAXDOUBLE,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_RIGHT,
+ g_param_spec_double ("right",
+ "Right coordinate",
+ "The right coordinate",
+ -G_MAXDOUBLE,
+ G_MAXDOUBLE,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (g_object_class,
+ PROP_ZOOM,
+ g_param_spec_double ("zoom",
+ "Zoom",
+ "Zoom",
+ 0,
+ G_MAXDOUBLE,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_NAMED,
+ g_param_spec_string ("named",
+ "Named destination",
+ "The named destination",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_PAGE_LABEL,
+ g_param_spec_string ("page_label",
+ "Label of the page",
+ "The label of the destination page",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+}
+
+EvLinkDest *
+ev_link_dest_new_page (gint page)
+{
+ return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
+ "page", page,
+ "type", EV_LINK_DEST_TYPE_PAGE,
+ NULL));
+}
+
+EvLinkDest *
+ev_link_dest_new_xyz (gint page,
+ gdouble left,
+ gdouble top,
+ gdouble zoom)
+{
+ return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
+ "page", page,
+ "type", EV_LINK_DEST_TYPE_XYZ,
+ "left", left,
+ "top", top,
+ "zoom", zoom,
+ NULL));
+}
+
+EvLinkDest *
+ev_link_dest_new_fit (gint page)
+{
+ return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
+ "page", page,
+ "type", EV_LINK_DEST_TYPE_FIT,
+ NULL));
+}
+
+EvLinkDest *
+ev_link_dest_new_fith (gint page,
+ gdouble top)
+{
+ return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
+ "page", page,
+ "type", EV_LINK_DEST_TYPE_FITH,
+ "top", top,
+ NULL));
+}
+
+EvLinkDest *
+ev_link_dest_new_fitv (gint page,
+ gdouble left)
+{
+ return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
+ "page", page,
+ "type", EV_LINK_DEST_TYPE_FITV,
+ "left", left,
+ NULL));
+}
+
+EvLinkDest *
+ev_link_dest_new_fitr (gint page,
+ gdouble left,
+ gdouble bottom,
+ gdouble right,
+ gdouble top)
+{
+ return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
+ "page", page,
+ "type", EV_LINK_DEST_TYPE_FITR,
+ "left", left,
+ "bottom", bottom,
+ "right", right,
+ "top", top,
+ NULL));
+}
+
+EvLinkDest *
+ev_link_dest_new_named (const gchar *named_dest)
+{
+ return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
+ "named", named_dest,
+ "type", EV_LINK_DEST_TYPE_NAMED,
+ NULL));
+}
+
+EvLinkDest *
+ev_link_dest_new_page_label (const gchar *page_label)
+{
+ return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
+ "page_label", page_label,
+ "type", EV_LINK_DEST_TYPE_PAGE_LABEL,
+ NULL));
+}
diff --git a/libdocument/ev-link-dest.h b/libdocument/ev-link-dest.h
new file mode 100644
index 0000000..a0c96f5
--- /dev/null
+++ b/libdocument/ev-link-dest.h
@@ -0,0 +1,86 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2006 Carlos Garcia Campos <carlosgc@gnome.org>
+ * Copyright (C) 2005 Red Hat, Inc.
+ *
+ * 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_LINK_DEST_H
+#define EV_LINK_DEST_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef struct _EvLinkDest EvLinkDest;
+typedef struct _EvLinkDestClass EvLinkDestClass;
+typedef struct _EvLinkDestPrivate EvLinkDestPrivate;
+
+#define EV_TYPE_LINK_DEST (ev_link_dest_get_type())
+#define EV_LINK_DEST(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_LINK_DEST, EvLinkDest))
+#define EV_LINK_DEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_LINK_DEST, EvLinkDestClass))
+#define EV_IS_LINK_DEST(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_LINK_DEST))
+#define EV_IS_LINK_DEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_LINK_DEST))
+#define EV_LINK_DEST_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_LINK_DEST, EvLinkDestClass))
+
+#define EV_TYPE_LINK_DEST_TYPE (ev_link_dest_type_get_type ())
+
+typedef enum {
+ EV_LINK_DEST_TYPE_PAGE,
+ EV_LINK_DEST_TYPE_XYZ,
+ EV_LINK_DEST_TYPE_FIT,
+ EV_LINK_DEST_TYPE_FITH,
+ EV_LINK_DEST_TYPE_FITV,
+ EV_LINK_DEST_TYPE_FITR,
+ EV_LINK_DEST_TYPE_NAMED,
+ EV_LINK_DEST_TYPE_PAGE_LABEL,
+ EV_LINK_DEST_TYPE_UNKNOWN
+} EvLinkDestType;
+
+GType ev_link_dest_type_get_type (void) G_GNUC_CONST;
+GType ev_link_dest_get_type (void) G_GNUC_CONST;
+
+EvLinkDestType ev_link_dest_get_dest_type (EvLinkDest *self);
+gint ev_link_dest_get_page (EvLinkDest *self);
+gdouble ev_link_dest_get_top (EvLinkDest *self);
+gdouble ev_link_dest_get_left (EvLinkDest *self);
+gdouble ev_link_dest_get_bottom (EvLinkDest *self);
+gdouble ev_link_dest_get_right (EvLinkDest *self);
+gdouble ev_link_dest_get_zoom (EvLinkDest *self);
+const gchar *ev_link_dest_get_named_dest (EvLinkDest *self);
+const gchar *ev_link_dest_get_page_label (EvLinkDest *self);
+
+EvLinkDest *ev_link_dest_new_page (gint page);
+EvLinkDest *ev_link_dest_new_xyz (gint page,
+ gdouble left,
+ gdouble top,
+ gdouble zoom);
+EvLinkDest *ev_link_dest_new_fit (gint page);
+EvLinkDest *ev_link_dest_new_fith (gint page,
+ gdouble top);
+EvLinkDest *ev_link_dest_new_fitv (gint page,
+ gdouble left);
+EvLinkDest *ev_link_dest_new_fitr (gint page,
+ gdouble left,
+ gdouble bottom,
+ gdouble right,
+ gdouble top);
+EvLinkDest *ev_link_dest_new_named (const gchar *named_dest);
+EvLinkDest *ev_link_dest_new_page_label (const gchar *page_label);
+
+G_END_DECLS
+
+#endif /* EV_LINK_DEST_H */
diff --git a/libdocument/ev-link.c b/libdocument/ev-link.c
new file mode 100644
index 0000000..8561914
--- /dev/null
+++ b/libdocument/ev-link.c
@@ -0,0 +1,226 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2005 Red Hat, Inc.
+ *
+ * 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 "ev-link.h"
+
+enum {
+ PROP_0,
+ PROP_TITLE,
+ PROP_ACTION
+};
+
+struct _EvLink {
+ GObject base_instance;
+ EvLinkPrivate *priv;
+};
+
+struct _EvLinkClass {
+ GObjectClass base_class;
+};
+
+struct _EvLinkPrivate {
+ gchar *title;
+ EvLinkAction *action;
+};
+
+G_DEFINE_TYPE (EvLink, ev_link, G_TYPE_OBJECT)
+
+#define EV_LINK_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_LINK, EvLinkPrivate))
+
+const gchar *
+ev_link_get_title (EvLink *self)
+{
+ g_return_val_if_fail (EV_IS_LINK (self), NULL);
+
+ return self->priv->title;
+}
+
+EvLinkAction *
+ev_link_get_action (EvLink *self)
+{
+ g_return_val_if_fail (EV_IS_LINK (self), NULL);
+
+ return self->priv->action;
+}
+
+static void
+ev_link_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *param_spec)
+{
+ EvLink *self;
+
+ self = EV_LINK (object);
+
+ switch (prop_id) {
+ case PROP_TITLE:
+ g_value_set_string (value, self->priv->title);
+ break;
+ case PROP_ACTION:
+ g_value_set_pointer (value, self->priv->action);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+ prop_id,
+ param_spec);
+ break;
+ }
+}
+
+static void
+ev_link_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *param_spec)
+{
+ EvLink *self = EV_LINK (object);
+
+ switch (prop_id) {
+ case PROP_TITLE:
+ self->priv->title = g_value_dup_string (value);
+ break;
+ case PROP_ACTION:
+ self->priv->action = g_value_get_pointer (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+ prop_id,
+ param_spec);
+ break;
+ }
+}
+
+static void
+ev_link_finalize (GObject *object)
+{
+ EvLinkPrivate *priv;
+
+ priv = EV_LINK (object)->priv;
+
+ if (priv->title) {
+ g_free (priv->title);
+ priv->title = NULL;
+ }
+
+ if (priv->action) {
+ g_object_unref (priv->action);
+ priv->action = NULL;
+ }
+
+ G_OBJECT_CLASS (ev_link_parent_class)->finalize (object);
+}
+
+static void
+ev_link_init (EvLink *ev_link)
+{
+ ev_link->priv = EV_LINK_GET_PRIVATE (ev_link);
+
+ ev_link->priv->title = NULL;
+ ev_link->priv->action = NULL;
+}
+
+static void
+ev_link_class_init (EvLinkClass *ev_window_class)
+{
+ GObjectClass *g_object_class;
+
+ g_object_class = G_OBJECT_CLASS (ev_window_class);
+
+ g_object_class->set_property = ev_link_set_property;
+ g_object_class->get_property = ev_link_get_property;
+
+ g_object_class->finalize = ev_link_finalize;
+
+ g_type_class_add_private (g_object_class, sizeof (EvLinkPrivate));
+
+ g_object_class_install_property (g_object_class,
+ PROP_TITLE,
+ g_param_spec_string ("title",
+ "Link Title",
+ "The link title",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_ACTION,
+ g_param_spec_pointer ("action",
+ "Link Action",
+ "The link action",
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+}
+
+EvLink *
+ev_link_new (const char *title,
+ EvLinkAction *action)
+{
+ return EV_LINK (g_object_new (EV_TYPE_LINK,
+ "title", title,
+ "action", action,
+ NULL));
+}
+
+/* Link Mapping stuff */
+static void
+ev_link_mapping_free_foreach (EvLinkMapping *mapping)
+{
+ g_object_unref (G_OBJECT (mapping->link));
+ g_free (mapping);
+}
+
+void
+ev_link_mapping_free (GList *link_mapping)
+{
+ if (link_mapping == NULL)
+ return;
+
+ g_list_foreach (link_mapping, (GFunc) (ev_link_mapping_free_foreach), NULL);
+ g_list_free (link_mapping);
+}
+
+EvLink *
+ev_link_mapping_find (GList *link_mapping,
+ gdouble x,
+ gdouble y)
+{
+ GList *list;
+ EvLink *link = NULL;
+ int i;
+
+ i = 0;
+
+ for (list = link_mapping; list; list = list->next) {
+ EvLinkMapping *mapping = list->data;
+
+ i++;
+ if ((x >= mapping->x1) &&
+ (y >= mapping->y1) &&
+ (x <= mapping->x2) &&
+ (y <= mapping->y2)) {
+ link = mapping->link;
+ break;
+ }
+ }
+
+ return link;
+}
+
diff --git a/libdocument/ev-link.h b/libdocument/ev-link.h
new file mode 100644
index 0000000..b7304de
--- /dev/null
+++ b/libdocument/ev-link.h
@@ -0,0 +1,64 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2005 Red Hat, Inc.
+ *
+ * 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_LINK_H
+#define EV_LINK_H
+
+#include <glib-object.h>
+#include "ev-link-action.h"
+
+G_BEGIN_DECLS
+
+typedef struct _EvLink EvLink;
+typedef struct _EvLinkClass EvLinkClass;
+typedef struct _EvLinkPrivate EvLinkPrivate;
+
+#define EV_TYPE_LINK (ev_link_get_type())
+#define EV_LINK(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_LINK, EvLink))
+#define EV_LINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_LINK, EvLinkClass))
+#define EV_IS_LINK(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_LINK))
+#define EV_IS_LINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_LINK))
+#define EV_LINK_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_LINK, EvLinkClass))
+
+GType ev_link_get_type (void) G_GNUC_CONST;
+
+EvLink *ev_link_new (const gchar *title,
+ EvLinkAction *action);
+
+const gchar *ev_link_get_title (EvLink *self);
+EvLinkAction *ev_link_get_action (EvLink *self);
+
+/* Link Mapping stuff */
+typedef struct _EvLinkMapping EvLinkMapping;
+struct _EvLinkMapping
+{
+ EvLink *link;
+ gdouble x1;
+ gdouble y1;
+ gdouble x2;
+ gdouble y2;
+};
+
+void ev_link_mapping_free (GList *link_mapping);
+EvLink *ev_link_mapping_find (GList *link_mapping,
+ gdouble x,
+ gdouble y);
+G_END_DECLS
+
+#endif /* !EV_LINK_H */
diff --git a/libdocument/ev-render-context.c b/libdocument/ev-render-context.c
new file mode 100644
index 0000000..a3969ad
--- /dev/null
+++ b/libdocument/ev-render-context.c
@@ -0,0 +1,79 @@
+#include "ev-render-context.h"
+
+static void ev_render_context_init (EvRenderContext *rc);
+static void ev_render_context_class_init (EvRenderContextClass *class);
+
+
+G_DEFINE_TYPE (EvRenderContext, ev_render_context, G_TYPE_OBJECT);
+
+static void ev_render_context_init (EvRenderContext *rc) { /* Do Nothing */ }
+
+static void
+ev_render_context_dispose (GObject *object)
+{
+ EvRenderContext *rc;
+
+ rc = (EvRenderContext *) object;
+
+ if (rc->destroy) {
+ (*rc->destroy) (rc->data);
+ rc->destroy = NULL;
+ }
+
+ (* G_OBJECT_CLASS (ev_render_context_parent_class)->dispose) (object);
+}
+
+static void
+ev_render_context_class_init (EvRenderContextClass *class)
+{
+ GObjectClass *oclass;
+
+ oclass = G_OBJECT_CLASS (class);
+
+ oclass->dispose = ev_render_context_dispose;
+}
+
+
+EvRenderContext *
+ev_render_context_new (int rotation,
+ gint page,
+ gdouble scale)
+{
+ EvRenderContext *rc;
+
+ rc = (EvRenderContext *) g_object_new (EV_TYPE_RENDER_CONTEXT, NULL);
+
+ rc->rotation = rotation;
+ rc->page = page;
+ rc->scale = scale;
+
+ return rc;
+}
+
+void
+ev_render_context_set_page (EvRenderContext *rc,
+ gint page)
+{
+ g_return_if_fail (rc != NULL);
+
+ rc->page = page;
+}
+
+void
+ev_render_context_set_rotation (EvRenderContext *rc,
+ int rotation)
+{
+ g_return_if_fail (rc != NULL);
+
+ rc->rotation = rotation;
+}
+
+void
+ev_render_context_set_scale (EvRenderContext *rc,
+ gdouble scale)
+{
+ g_return_if_fail (rc != NULL);
+
+ rc->scale = scale;
+}
+
diff --git a/libdocument/ev-render-context.h b/libdocument/ev-render-context.h
new file mode 100644
index 0000000..636f02f
--- /dev/null
+++ b/libdocument/ev-render-context.h
@@ -0,0 +1,66 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2005 Jonathan Blandford <jrb@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_RENDER_CONTEXT_H
+#define EV_RENDER_CONTEXT_H
+
+#include <glib-object.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_IS_RENDER_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_RENDER_CONTEXT))
+
+struct _EvRenderContextClass
+{
+ GObjectClass klass;
+};
+
+struct _EvRenderContext
+{
+ GObject parent;
+ int rotation;
+ gint page;
+ 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,
+ gdouble scale);
+void ev_render_context_set_page (EvRenderContext *rc,
+ gint page);
+void ev_render_context_set_rotation (EvRenderContext *rc,
+ int rotation);
+void ev_render_context_set_scale (EvRenderContext *rc,
+ gdouble scale);
+
+
+G_END_DECLS
+
+#endif /* !EV_RENDER_CONTEXT */
diff --git a/libdocument/ev-selection.c b/libdocument/ev-selection.c
new file mode 100644
index 0000000..2aa45a7
--- /dev/null
+++ b/libdocument/ev-selection.c
@@ -0,0 +1,93 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * Copyright (C) 2005 Red Hat, Inc.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include "ev-selection.h"
+
+static void ev_selection_base_init (gpointer g_class);
+
+GType
+ev_selection_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ {
+ const GTypeInfo our_info =
+ {
+ sizeof (EvSelectionIface),
+ ev_selection_base_init,
+ NULL,
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EvSelection",
+ &our_info, (GTypeFlags)0);
+ }
+
+ return type;
+}
+
+static void
+ev_selection_base_init (gpointer g_class)
+{
+ static gboolean initialized = FALSE;
+
+ if (!initialized) {
+ }
+}
+
+
+void
+ev_selection_render_selection (EvSelection *selection,
+ EvRenderContext *rc,
+ GdkPixbuf **pixbuf,
+ EvRectangle *points,
+ EvRectangle *old_points,
+ GdkColor *text,
+ GdkColor *base)
+{
+ EvSelectionIface *iface = EV_SELECTION_GET_IFACE (selection);
+
+ iface->render_selection (selection, rc,
+ pixbuf,
+ points, old_points,
+ text, base);
+}
+
+GdkRegion *
+ev_selection_get_selection_region (EvSelection *selection,
+ EvRenderContext *rc,
+ EvRectangle *points)
+{
+ EvSelectionIface *iface = EV_SELECTION_GET_IFACE (selection);
+
+ return iface->get_selection_region (selection, rc, points);
+}
+
+GdkRegion *
+ev_selection_get_selection_map (EvSelection *selection,
+ EvRenderContext *rc)
+{
+ EvSelectionIface *iface = EV_SELECTION_GET_IFACE (selection);
+
+ return iface->get_selection_map (selection, rc);
+}
diff --git a/libdocument/ev-selection.h b/libdocument/ev-selection.h
new file mode 100644
index 0000000..d081604
--- /dev/null
+++ b/libdocument/ev-selection.h
@@ -0,0 +1,76 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * Copyright (C) 2000-2003 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef EV_SELECTION_H
+#define EV_SELECTION_H
+
+#include <glib-object.h>
+#include <glib.h>
+#include <gdk/gdkpixbuf.h>
+#include <gdk/gdk.h>
+#include "ev-document.h"
+
+G_BEGIN_DECLS
+
+#define EV_TYPE_SELECTION (ev_selection_get_type ())
+#define EV_SELECTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_SELECTION, EvSelection))
+#define EV_SELECTION_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_SELECTION, EvSelectionIface))
+#define EV_IS_SELECTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_SELECTION))
+#define EV_IS_SELECTION_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_SELECTION))
+#define EV_SELECTION_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_SELECTION, EvSelectionIface))
+
+typedef struct _EvSelection EvSelection;
+typedef struct _EvSelectionIface EvSelectionIface;
+
+struct _EvSelectionIface
+{
+ GTypeInterface base_iface;
+
+ void (* render_selection) (EvSelection *selection,
+ EvRenderContext *rc,
+ GdkPixbuf **pixbuf,
+ EvRectangle *points,
+ EvRectangle *old_points,
+ GdkColor *text,
+ GdkColor *base);
+ GdkRegion * (* get_selection_map) (EvSelection *selection,
+ EvRenderContext *rc);
+ GdkRegion * (* get_selection_region) (EvSelection *selection,
+ EvRenderContext *rc,
+ EvRectangle *points);
+};
+
+GType ev_selection_get_type (void);
+void ev_selection_render_selection (EvSelection *selection,
+ EvRenderContext *rc,
+ GdkPixbuf **pixbuf,
+ EvRectangle *points,
+ EvRectangle *old_points,
+ GdkColor *text,
+ GdkColor *base);
+GdkRegion *ev_selection_get_selection_map (EvSelection *selection,
+ EvRenderContext *rc);
+GdkRegion *ev_selection_get_selection_region (EvSelection *selection,
+ EvRenderContext *rc,
+ EvRectangle *points);
+
+G_END_DECLS
+
+#endif