]> www.fi.muni.cz Git - evince.git/blob - backend/ev-document.c
Implement "Save a copy..." menu item
[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 static void
60 ev_document_class_init (gpointer g_class)
61 {
62         signals[CHANGED] =
63                 g_signal_new ("changed",
64                               EV_TYPE_DOCUMENT,
65                               G_SIGNAL_RUN_LAST,
66                               G_STRUCT_OFFSET (EvDocumentIface, changed),
67                               NULL, NULL,
68                               g_cclosure_marshal_VOID__VOID,
69                               G_TYPE_NONE,
70                               0);
71
72         g_object_interface_install_property (g_class,
73                                 g_param_spec_string ("title",
74                                                      "Document Title",
75                                                      "The title of the document",
76                                                      NULL,
77                                                      G_PARAM_READABLE));
78 }
79
80 gboolean
81 ev_document_load (EvDocument  *document,
82                   const char  *uri,
83                   GError     **error)
84 {
85         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
86         return iface->load (document, uri, error);
87 }
88
89 gboolean
90 ev_document_save (EvDocument  *document,
91                   const char  *uri,
92                   GError     **error)
93 {
94         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
95         return iface->save (document, uri, error);
96 }
97
98 char *
99 ev_document_get_title (EvDocument  *document)
100 {
101         char *title;
102
103         g_object_get (document, "title", &title, NULL);
104
105         return title;
106 }
107
108 int
109 ev_document_get_n_pages (EvDocument  *document)
110 {
111         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
112         return iface->get_n_pages (document);
113 }
114
115 void
116 ev_document_set_page (EvDocument  *document,
117                       int          page)
118 {
119         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
120         iface->set_page (document, page);
121 }
122
123 int
124 ev_document_get_page (EvDocument *document)
125 {
126         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
127         return iface->get_page (document);
128 }
129
130 void
131 ev_document_set_target (EvDocument  *document,
132                         GdkDrawable *target)
133 {
134         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
135         iface->set_target (document, target);
136 }
137
138 void
139 ev_document_set_scale (EvDocument   *document,
140                        double        scale)
141 {
142         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
143         iface->set_scale (document, scale);
144 }
145
146 void
147 ev_document_set_page_offset (EvDocument  *document,
148                              int          x,
149                              int          y)
150 {
151         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
152         iface->set_page_offset (document, x, y);
153 }
154
155 void
156 ev_document_get_page_size   (EvDocument   *document,
157                              int          *width,
158                              int          *height)
159 {
160         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
161         iface->get_page_size (document, width, height);
162 }
163
164 void
165 ev_document_render (EvDocument  *document,
166                     int          clip_x,
167                     int          clip_y,
168                     int          clip_width,
169                     int          clip_height)
170 {
171         EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
172         iface->render (document, clip_x, clip_y, clip_width, clip_height);
173 }
174
175 void
176 ev_document_changed (EvDocument *document)
177 {
178         g_signal_emit (G_OBJECT (document), signals[CHANGED], 0);
179 }