]> www.fi.muni.cz Git - evince.git/blob - pdf/xpdf/pdf-document.c
Start of content-area widget.
[evince.git] / pdf / xpdf / pdf-document.c
1 /* pdfdocument.h: Implementation of EvDocument for PDF
2  * Copyright (C) 2004, Red Hat, Inc.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2, or (at your option)
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18
19 #include "pdf-document.h"
20
21 typedef struct _PdfDocumentClass PdfDocumentClass;
22
23 #define PDF_DOCUMENT_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), PDF_TYPE_DOCUMENT, PdfDocumentClass))
24 #define PDF_IS_DOCUMENT_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), PDF_TYPE_DOCUMENT))
25 #define PDF_DOCUMENT_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), PDF_TYPE_DOCUMENT, PdfDocumentClass))
26
27 struct _PdfDocumentClass
28 {
29         GObjectClass parent_class;
30 };
31
32 struct _PdfDocument
33 {
34         GObject parent_instance;
35
36         GdkRectangle page_rect;
37         GdkDrawable *target;
38         
39 };
40
41 static void pdf_document_document_iface_init (EvDocumentIface *iface);
42
43 G_DEFINE_TYPE_WITH_CODE (PdfDocument, pdf_document, G_TYPE_OBJECT,
44                          { G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT,
45                                                   pdf_document_document_iface_init) });
46
47
48 static gboolean
49 pdf_document_load (EvDocument  *document,
50                    const char  *uri,
51                    GError     **error)
52 {
53         return TRUE;
54 }
55
56 static int
57 pdf_document_get_n_pages (EvDocument  *document)
58 {
59         return 1;
60 }
61
62 static void
63 pdf_document_set_page (EvDocument  *document,
64                        int          page)
65 {
66 }
67
68 static void
69 pdf_document_set_target (EvDocument  *document,
70                          GdkDrawable *target)
71 {
72         PdfDocument *pdf_document = PDF_DOCUMENT (document);
73         
74         if (pdf_document->target != target) {
75                 if (pdf_document->target)
76                         g_object_unref (pdf_document->target);
77                 
78                 pdf_document->target = target;
79
80                 if (pdf_document->target)
81                         g_object_ref (pdf_document->target);
82         }
83 }
84
85 static void
86 pdf_document_set_page_rect (EvDocument  *document,
87                             int          x,
88                             int          y,
89                             int          width,
90                             int          height)
91 {
92         PdfDocument *pdf_document = PDF_DOCUMENT (document);
93         
94         pdf_document->page_rect.x = x;
95         pdf_document->page_rect.y = y;
96         pdf_document->page_rect.width = width;
97         pdf_document->page_rect.height = height;
98 }
99
100 static void
101 pdf_document_render (EvDocument  *document,
102                      int          clip_x,
103                      int          clip_y,
104                      int          clip_width,
105                      int          clip_height)
106 {
107 }
108
109 static void
110 pdf_document_finalize (GObject *object)
111 {
112         PdfDocument *pdf_document = PDF_DOCUMENT (object);
113
114         if (pdf_document->target)
115                 g_object_unref (pdf_document->target);
116
117 }
118
119 static void
120 pdf_document_class_init (PdfDocumentClass *class)
121 {
122         GObjectClass *gobject_class = G_OBJECT_CLASS (class);
123   
124         gobject_class->finalize = pdf_document_finalize;
125 }
126
127 static void
128 pdf_document_document_iface_init (EvDocumentIface *iface)
129 {
130         iface->load = pdf_document_load;
131         iface->get_n_pages = pdf_document_get_n_pages;
132         iface->set_page = pdf_document_set_page;
133         iface->set_target = pdf_document_set_target;
134         iface->set_page_rect = pdf_document_set_page_rect;
135         iface->render = pdf_document_render;
136 }
137
138 static void
139 pdf_document_init (PdfDocument *document)
140 {
141 }
142