Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ev-transition-effect.c
Go to the documentation of this file.
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 
30 
35 
36  gint duration;
37  gint angle;
38  gdouble scale;
39 
40  guint rectangular : 1;
41 };
42 
43 enum {
52 };
53 
54 G_DEFINE_TYPE (EvTransitionEffect, ev_transition_effect, G_TYPE_OBJECT)
55 
56 static void
58  guint prop_id,
59  const GValue *value,
60  GParamSpec *pspec)
61 {
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
96  guint prop_id,
97  GValue *value,
98  GParamSpec *pspec)
99 {
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
134 {
136 
137  priv = EV_TRANSITION_EFFECT_GET_PRIV (effect);
138 
139  priv->scale = 1.;
140 }
141 
142 static void
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,
157  G_PARAM_READWRITE |
158  G_PARAM_STATIC_STRINGS));
159  g_object_class_install_property (object_class,
161  g_param_spec_enum ("alignment",
162  "Effect alignment",
163  "Alignment for the effect",
164  EV_TYPE_TRANSITION_EFFECT_ALIGNMENT,
166  G_PARAM_READWRITE |
167  G_PARAM_STATIC_STRINGS));
168  g_object_class_install_property (object_class,
170  g_param_spec_enum ("direction",
171  "Effect direction",
172  "Direction for the effect",
173  EV_TYPE_TRANSITION_EFFECT_DIRECTION,
175  G_PARAM_READWRITE |
176  G_PARAM_STATIC_STRINGS));
177  g_object_class_install_property (object_class,
179  g_param_spec_int ("duration",
180  "Effect duration",
181  "Effect duration in seconds",
182  0, G_MAXINT, 0,
183  G_PARAM_READWRITE |
184  G_PARAM_STATIC_STRINGS));
185  g_object_class_install_property (object_class,
186  PROP_ANGLE,
187  g_param_spec_int ("angle",
188  "Effect angle",
189  "Effect angle in degrees, counted "
190  "counterclockwise from left to right",
191  0, 360, 0,
192  G_PARAM_READWRITE |
193  G_PARAM_STATIC_STRINGS));
194  g_object_class_install_property (object_class,
195  PROP_SCALE,
196  g_param_spec_double ("scale",
197  "Effect scale",
198  "Scale at which the effect is applied",
199  0., 1., 1.,
200  G_PARAM_READWRITE |
201  G_PARAM_STATIC_STRINGS));
202  g_object_class_install_property (object_class,
204  g_param_spec_boolean ("rectangular",
205  "Rectangular area",
206  "Whether the covered area is rectangular",
207  FALSE,
208  G_PARAM_READWRITE |
209  G_PARAM_STATIC_STRINGS));
210 
211  g_type_class_add_private (klass, sizeof (EvTransitionEffectPrivate));
212 }
213 
216  const gchar *first_property_name,
217  ...)
218 {
219  GObject *object;
220  va_list args;
221 
222  object = g_object_new (EV_TYPE_TRANSITION_EFFECT,
223  "type", type,
224  NULL);
225 
226  va_start (args, first_property_name);
227  g_object_set_valist (object, first_property_name, args);
228  va_end (args);
229 
230  return EV_TRANSITION_EFFECT (object);
231 }