1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
3 * Copyright (C) 2004 Marco Pesenti Gritti
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "ev-document.h"
25 #include "ev-backend-marshalers.h"
26 #include "ev-job-queue.h"
28 static void ev_document_class_init (gpointer g_class);
31 GMutex *ev_doc_mutex = NULL;
35 ev_document_get_type (void)
37 static GType type = 0;
39 if (G_UNLIKELY (type == 0))
41 static const GTypeInfo our_info =
43 sizeof (EvDocumentIface),
46 (GClassInitFunc)ev_document_class_init
49 type = g_type_register_static (G_TYPE_INTERFACE,
51 &our_info, (GTypeFlags)0);
58 ev_document_error_quark (void)
62 q = g_quark_from_static_string ("ev-document-error-quark");
68 ev_document_class_init (gpointer g_class)
70 g_object_interface_install_property (g_class,
71 g_param_spec_string ("title",
73 "The title of the document",
78 #define PAGE_CACHE_STRING "ev-page-cache"
81 ev_document_get_page_cache (EvDocument *document)
83 EvPageCache *page_cache;
85 g_return_val_if_fail (EV_IS_DOCUMENT (document), NULL);
87 page_cache = g_object_get_data (G_OBJECT (document), PAGE_CACHE_STRING);
88 if (page_cache == NULL) {
89 page_cache = _ev_page_cache_new (document);
90 g_object_set_data_full (G_OBJECT (document), PAGE_CACHE_STRING, page_cache, g_object_unref);
97 ev_document_get_doc_mutex (void)
99 if (ev_doc_mutex == NULL) {
100 ev_doc_mutex = g_mutex_new ();
107 ev_document_load (EvDocument *document,
111 EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
113 LOG ("ev_document_load");
114 retval = iface->load (document, uri, error);
116 /* Call this to make the initial cached copy */
118 ev_document_get_page_cache (document);
124 ev_document_save (EvDocument *document,
128 EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
131 LOG ("ev_document_save");
132 retval = iface->save (document, uri, error);
138 ev_document_get_title (EvDocument *document)
142 LOG ("ev_document_get_title");
143 g_object_get (document, "title", &title, NULL);
149 ev_document_get_n_pages (EvDocument *document)
151 EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
154 LOG ("ev_document_get_n_pages");
155 retval = iface->get_n_pages (document);
161 ev_document_get_page_size (EvDocument *document,
166 EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
168 LOG ("ev_document_get_page_size");
169 iface->get_page_size (document, page, width, height);
173 ev_document_get_page_label(EvDocument *document,
176 EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
178 LOG ("ev_document_get_page_label");
179 if (iface->get_page_label == NULL)
182 return iface->get_page_label (document, page);
186 ev_document_can_get_text (EvDocument *document)
188 EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
190 return iface->can_get_text (document);
194 ev_document_get_text (EvDocument *document,
198 EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
201 LOG ("ev_document_get_text");
202 retval = iface->get_text (document, page, rect);
208 ev_document_get_links (EvDocument *document,
211 EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
214 LOG ("ev_document_get_link");
215 if (iface->get_links == NULL)
217 retval = iface->get_links (document, page);
225 ev_document_render_pixbuf (EvDocument *document,
229 EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
232 LOG ("ev_document_render_pixbuf");
233 g_assert (iface->render_pixbuf);
235 retval = iface->render_pixbuf (document, page, scale);