]> www.fi.muni.cz Git - evince.git/blob - backend/ev-document.c
6f6a687eef0686f4345e88b9661b079f9e70423c
[evince.git] / backend / ev-document.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
2 /*
3  *  Copyright (C) 2004 Marco Pesenti Gritti
4  *
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)
8  *  any later version.
9  *
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.
14  *
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.
18  *
19  */
20
21 #include "config.h"
22
23 #include "ev-document.h"
24 #include "ev-backend-marshalers.h"
25
26 static void ev_document_class_init (gpointer g_class);
27
28 enum
29 {
30         CHANGED,
31         LAST_SIGNAL
32 };
33
34 static guint signals[LAST_SIGNAL] = { 0 };
35
36 GType
37 ev_document_get_type (void)
38 {
39         static GType type = 0;
40
41         if (G_UNLIKELY (type == 0))
42         {
43                 static const GTypeInfo our_info =
44                 {
45                         sizeof (EvDocumentIface),
46                         NULL,
47                         NULL,
48                         (GClassInitFunc)ev_document_class_init
49                 };
50
51                 type = g_type_register_static (G_TYPE_INTERFACE,
52                                                "EvDocument",
53                                                &our_info, (GTypeFlags)0);
54         }
55
56         return type;
57 }
58
59 GQuark
60 ev_document_error_quark (void)
61 {
62   static GQuark q = 0;
63   if (q == 0)
64     q = g_quark_from_static_string ("ev-document-error-quark");
65
66   return q;
67 }
68
69 static void
70 ev_document_class_init (gpointer g_class)
71 {
72         signals[CHANGED] =
73                 g_signal_new ("changed",
74                               EV_TYPE_DOCUMENT,
75                               G_SIGNAL_RUN_LAST,
76                               G_STRUCT_OFFSET (EvDocumentIface, changed),
77                               NULL, NULL,
78                               g_cclosure_marshal_VOID__VOID,
79                               G_TYPE_NONE,
80                               0);
81
82         g_object_interface_install_property (g_class,
83                                 g_param_spec_string ("title",
84                                                      "Document Title",
85                                                      "The title of the document",
86                                                      NULL,
87                                                      G_PARAM_READABLE));
88 }
89
90 gboolean
91 ev_document_load (EvDocument  *document,
92                   const char  *uri,
93                   GError     **error)
94 {
95         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
96         return iface->load (document, uri, error);
97 }
98
99 gboolean
100 ev_document_save (EvDocument  *document,
101                   const char  *uri,
102                   GError     **error)
103 {
104         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
105         return iface->save (document, uri, error);
106 }
107
108 char *
109 ev_document_get_title (EvDocument  *document)
110 {
111         char *title;
112
113         g_object_get (document, "title", &title, NULL);
114
115         return title;
116 }
117
118 int
119 ev_document_get_n_pages (EvDocument  *document)
120 {
121         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
122         return iface->get_n_pages (document);
123 }
124
125 void
126 ev_document_set_page (EvDocument  *document,
127                       int          page)
128 {
129         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
130         iface->set_page (document, page);
131 }
132
133 int
134 ev_document_get_page (EvDocument *document)
135 {
136         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
137         return iface->get_page (document);
138 }
139
140 void
141 ev_document_set_target (EvDocument  *document,
142                         GdkDrawable *target)
143 {
144         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
145         iface->set_target (document, target);
146 }
147
148 void
149 ev_document_set_scale (EvDocument   *document,
150                        double        scale)
151 {
152         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
153         iface->set_scale (document, scale);
154 }
155
156 void
157 ev_document_set_page_offset (EvDocument  *document,
158                              int          x,
159                              int          y)
160 {
161         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
162         iface->set_page_offset (document, x, y);
163 }
164
165 void
166 ev_document_get_page_size   (EvDocument   *document,
167                              int          *width,
168                              int          *height)
169 {
170         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
171         iface->get_page_size (document, width, height);
172 }
173
174 char *
175 ev_document_get_text (EvDocument   *document,
176                       GdkRectangle *rect)
177 {
178         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
179         return iface->get_text (document, rect);
180 }
181
182 EvLink *
183 ev_document_get_link (EvDocument   *document,
184                       int           x,
185                       int           y)
186 {
187         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
188         return iface->get_link (document, x, y);
189 }
190
191 void
192 ev_document_render (EvDocument  *document,
193                     int          clip_x,
194                     int          clip_y,
195                     int          clip_width,
196                     int          clip_height)
197 {
198         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
199         iface->render (document, clip_x, clip_y, clip_width, clip_height);
200 }
201
202 void
203 ev_document_changed (EvDocument *document)
204 {
205         g_signal_emit (G_OBJECT (document), signals[CHANGED], 0);
206 }