]> www.fi.muni.cz Git - evince.git/blob - libdocument/ev-transition-effect.c
[dualscreen] fix crash on ctrl+w and fix control window closing
[evince.git] / libdocument / ev-transition-effect.c
1 /* ev-transition-effect.c
2  *  this file is part of evince, a gnome document viewer
3  *
4  * Copyright (C) 2007 Carlos Garnacho <carlos@imendio.com>
5  *
6  * Evince is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * Evince is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20
21 #include <config.h>
22
23 #include "ev-transition-effect.h"
24
25 #include "ev-document-type-builtins.h"
26
27 #define EV_TRANSITION_EFFECT_GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EV_TYPE_TRANSITION_EFFECT, EvTransitionEffectPrivate))
28
29 typedef struct EvTransitionEffectPrivate EvTransitionEffectPrivate;
30
31 struct EvTransitionEffectPrivate {
32         EvTransitionEffectType type;
33         EvTransitionEffectAlignment alignment;
34         EvTransitionEffectDirection direction;
35
36         gint duration;
37         gint angle;
38         gdouble scale;
39
40         guint rectangular : 1;
41 };
42
43 enum {
44         PROP_0,
45         PROP_TYPE,
46         PROP_ALIGNMENT,
47         PROP_DIRECTION,
48         PROP_DURATION,
49         PROP_ANGLE,
50         PROP_SCALE,
51         PROP_RECTANGULAR
52 };
53
54 G_DEFINE_TYPE (EvTransitionEffect, ev_transition_effect, G_TYPE_OBJECT)
55
56 static void
57 ev_transition_effect_set_property (GObject      *object,
58                                    guint         prop_id,
59                                    const GValue *value,
60                                    GParamSpec   *pspec)
61 {
62         EvTransitionEffectPrivate *priv;
63
64         priv = EV_TRANSITION_EFFECT_GET_PRIV (object);
65
66         switch (prop_id) {
67         case PROP_TYPE:
68                 priv->type = g_value_get_enum (value);
69                 break;
70         case PROP_ALIGNMENT:
71                 priv->alignment = g_value_get_enum (value);
72                 break;
73         case PROP_DIRECTION:
74                 priv->direction = g_value_get_enum (value);
75                 break;
76         case PROP_DURATION:
77                 priv->duration = g_value_get_int (value);
78                 break;
79         case PROP_ANGLE:
80                 priv->angle = g_value_get_int (value);
81                 break;
82         case PROP_SCALE:
83                 priv->scale = g_value_get_double (value);
84                 break;
85         case PROP_RECTANGULAR:
86                 priv->rectangular = g_value_get_boolean (value);
87                 break;
88         default:
89                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
90                 break;
91         }
92 }
93
94 static void
95 ev_transition_effect_get_property (GObject    *object,
96                                    guint       prop_id,
97                                    GValue     *value,
98                                    GParamSpec *pspec)
99 {
100         EvTransitionEffectPrivate *priv;
101
102         priv = EV_TRANSITION_EFFECT_GET_PRIV (object);
103
104         switch (prop_id) {
105         case PROP_TYPE:
106                 g_value_set_enum (value, priv->type);
107                 break;
108         case PROP_ALIGNMENT:
109                 g_value_set_enum (value, priv->alignment);
110                 break;
111         case PROP_DIRECTION:
112                 g_value_set_enum (value, priv->direction);
113                 break;
114         case PROP_DURATION:
115                 g_value_set_int (value, priv->duration);
116                 break;
117         case PROP_ANGLE:
118                 g_value_set_int (value, priv->angle);
119                 break;
120         case PROP_SCALE:
121                 g_value_set_double (value, priv->scale);
122                 break;
123         case PROP_RECTANGULAR:
124                 g_value_set_enum (value, priv->rectangular);
125                 break;
126         default:
127                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
128                 break;
129         }
130 }
131
132 static void
133 ev_transition_effect_init (EvTransitionEffect *effect)
134 {
135         EvTransitionEffectPrivate *priv;
136
137         priv = EV_TRANSITION_EFFECT_GET_PRIV (effect);
138
139         priv->scale = 1.;
140 }
141
142 static void
143 ev_transition_effect_class_init (EvTransitionEffectClass *klass)
144 {
145         GObjectClass *object_class = G_OBJECT_CLASS (klass);
146
147         object_class->set_property = ev_transition_effect_set_property;
148         object_class->get_property = ev_transition_effect_get_property;
149
150         g_object_class_install_property (object_class,
151                                          PROP_TYPE,
152                                          g_param_spec_enum ("type",
153                                                             "Effect type",
154                                                             "Page transition effect type",
155                                                             EV_TYPE_TRANSITION_EFFECT_TYPE,
156                                                             EV_TRANSITION_EFFECT_REPLACE,
157                                                             G_PARAM_READWRITE));
158         g_object_class_install_property (object_class,
159                                          PROP_ALIGNMENT,
160                                          g_param_spec_enum ("alignment",
161                                                             "Effect alignment",
162                                                             "Alignment for the effect",
163                                                             EV_TYPE_TRANSITION_EFFECT_ALIGNMENT,
164                                                             EV_TRANSITION_ALIGNMENT_HORIZONTAL,
165                                                             G_PARAM_READWRITE));
166         g_object_class_install_property (object_class,
167                                          PROP_DIRECTION,
168                                          g_param_spec_enum ("direction",
169                                                             "Effect direction",
170                                                             "Direction for the effect",
171                                                             EV_TYPE_TRANSITION_EFFECT_DIRECTION,
172                                                             EV_TRANSITION_DIRECTION_INWARD,
173                                                             G_PARAM_READWRITE));
174         g_object_class_install_property (object_class,
175                                          PROP_DURATION,
176                                          g_param_spec_int ("duration",
177                                                            "Effect duration",
178                                                            "Effect duration in seconds",
179                                                            0, G_MAXINT, 0,
180                                                            G_PARAM_READWRITE));
181         g_object_class_install_property (object_class,
182                                          PROP_ANGLE,
183                                          g_param_spec_int ("angle",
184                                                            "Effect angle",
185                                                            "Effect angle in degrees, counted "
186                                                            "counterclockwise from left to right",
187                                                            0, 360, 0,
188                                                            G_PARAM_READWRITE));
189         g_object_class_install_property (object_class,
190                                          PROP_SCALE,
191                                          g_param_spec_double ("scale",
192                                                               "Effect scale",
193                                                               "Scale at which the effect is applied",
194                                                               0., 1., 1.,
195                                                               G_PARAM_READWRITE));
196         g_object_class_install_property (object_class,
197                                          PROP_RECTANGULAR,
198                                          g_param_spec_boolean ("rectangular",
199                                                                "Rectangular area",
200                                                                "Whether the covered area is rectangular",
201                                                                FALSE,
202                                                                G_PARAM_READWRITE));
203
204         g_type_class_add_private (klass, sizeof (EvTransitionEffectPrivate));
205 }
206
207 EvTransitionEffect *
208 ev_transition_effect_new (EvTransitionEffectType  type,
209                           const gchar            *first_property_name,
210                           ...)
211 {
212         GObject *object;
213         va_list  args;
214
215         object = g_object_new (EV_TYPE_TRANSITION_EFFECT,
216                                "type", type,
217                                NULL);
218
219         va_start (args, first_property_name);
220         g_object_set_valist (object, first_property_name, args);
221         va_end (args);
222
223         return EV_TRANSITION_EFFECT (object);
224 }