]> www.fi.muni.cz Git - evince.git/blob - libdocument/ev-render-context.c
[dualscreen] fix crash on ctrl+w and fix control window closing
[evince.git] / libdocument / ev-render-context.c
1 /* this file is part of evince, a gnome document viewer
2  *
3  *  Copyright (C) 2005 Jonathan Blandford <jrb@gnome.org>
4  *
5  * Evince is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * Evince is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #include <config.h>
21 #include "ev-render-context.h"
22
23 static void ev_render_context_init       (EvRenderContext      *rc);
24 static void ev_render_context_class_init (EvRenderContextClass *class);
25
26
27 G_DEFINE_TYPE (EvRenderContext, ev_render_context, G_TYPE_OBJECT);
28
29 static void ev_render_context_init (EvRenderContext *rc) { /* Do Nothing */ }
30
31 static void
32 ev_render_context_dispose (GObject *object)
33 {
34         EvRenderContext *rc;
35
36         rc = (EvRenderContext *) object;
37
38         if (rc->page) {
39                 g_object_unref (rc->page);
40                 rc->page = NULL;
41         }
42
43         (* G_OBJECT_CLASS (ev_render_context_parent_class)->dispose) (object);
44 }
45
46 static void
47 ev_render_context_class_init (EvRenderContextClass *class)
48 {
49         GObjectClass *oclass;
50
51         oclass = G_OBJECT_CLASS (class);
52
53         oclass->dispose = ev_render_context_dispose;
54 }
55
56 EvRenderContext *
57 ev_render_context_new (EvPage *page,
58                        gint    rotation,
59                        gdouble scale)
60 {
61         EvRenderContext *rc;
62
63         rc = (EvRenderContext *) g_object_new (EV_TYPE_RENDER_CONTEXT, NULL);
64
65         rc->page = page ? g_object_ref (page) : NULL;
66         rc->rotation = rotation;
67         rc->scale = scale;
68
69         return rc;
70 }
71
72 void
73 ev_render_context_set_page (EvRenderContext *rc,
74                             EvPage          *page)
75 {
76         g_return_if_fail (rc != NULL);
77         g_return_if_fail (EV_IS_PAGE (page));
78
79         if (rc->page)
80                 g_object_unref (rc->page);
81         rc->page = g_object_ref (page);
82 }
83
84 void
85 ev_render_context_set_rotation (EvRenderContext *rc,
86                                 int              rotation)
87 {
88         g_return_if_fail (rc != NULL);
89
90         rc->rotation = rotation;
91 }
92
93 void
94 ev_render_context_set_scale (EvRenderContext *rc,
95                              gdouble          scale)
96 {
97         g_return_if_fail (rc != NULL);
98
99         rc->scale = scale;
100 }
101