]> www.fi.muni.cz Git - evince.git/blob - backend/ev-document.c
dcc620483dd10729a93884d4fff338395924af19
[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_base_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                         ev_document_base_init,
47                         NULL,
48                 };
49
50                 type = g_type_register_static (G_TYPE_INTERFACE,
51                                                "EvDocument",
52                                                &our_info, (GTypeFlags)0);
53         }
54
55         return type;
56 }
57
58 static void
59 ev_document_base_init (gpointer g_class)
60 {
61         static gboolean initialized = FALSE;
62
63         if (!initialized)
64         {
65                 signals[CHANGED] =
66                         g_signal_new ("changed",
67                                       EV_TYPE_DOCUMENT,
68                                       G_SIGNAL_RUN_LAST,
69                                       G_STRUCT_OFFSET (EvDocumentIface, changed),
70                                       NULL, NULL,
71                                       g_cclosure_marshal_VOID__VOID,
72                                       G_TYPE_NONE,
73                                       0);
74
75                 initialized = TRUE;
76         }
77 }
78
79 gboolean
80 ev_document_load (EvDocument  *document,
81                   const char  *uri,
82                   GError     **error)
83 {
84         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
85         return iface->load (document, uri, error);
86 }
87
88 int
89 ev_document_get_n_pages (EvDocument  *document)
90 {
91         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
92         return iface->get_n_pages (document);
93 }
94
95 void
96 ev_document_set_page (EvDocument  *document,
97                       int          page)
98 {
99         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
100         iface->set_page (document, page);
101 }
102
103 int
104 ev_document_get_page (EvDocument *document)
105 {
106         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
107         return iface->get_page (document);
108 }
109
110 void
111 ev_document_set_target (EvDocument  *document,
112                         GdkDrawable *target)
113 {
114         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
115         iface->set_target (document, target);
116 }
117
118 void
119 ev_document_set_scale (EvDocument   *document,
120                        double        scale)
121 {
122         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
123         iface->set_scale (document, scale);
124 }
125
126 void
127 ev_document_set_page_offset (EvDocument  *document,
128                              int          x,
129                              int          y)
130 {
131         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
132         iface->set_page_offset (document, x, y);
133 }
134
135 void
136 ev_document_get_page_size   (EvDocument   *document,
137                              int          *width,
138                              int          *height)
139 {
140         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
141         iface->get_page_size (document, width, height);
142 }
143
144 void
145 ev_document_render (EvDocument  *document,
146                     int          clip_x,
147                     int          clip_y,
148                     int          clip_width,
149                     int          clip_height)
150 {
151         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
152         iface->render (document, clip_x, clip_y, clip_width, clip_height);
153 }
154
155 void
156 ev_document_changed (EvDocument *document)
157 {
158         g_signal_emit (G_OBJECT (document), signals[CHANGED], 0);
159 }