1 /* this file is part of evince, a gnome document viewer
3 * Copyright (C) 2006 Carlos Garcia Campos <carlosgc@gnome.org>
4 * Copyright (C) 2005 Red Hat, Inc.
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
21 #include "ev-link-dest.h"
36 GObject base_instance;
38 EvLinkDestPrivate *priv;
41 struct _EvLinkDestClass {
42 GObjectClass base_class;
45 struct _EvLinkDestPrivate {
56 G_DEFINE_TYPE (EvLinkDest, ev_link_dest, G_TYPE_OBJECT)
58 #define EV_LINK_DEST_GET_PRIVATE(object) \
59 (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_LINK_DEST, EvLinkDestPrivate))
62 ev_link_dest_type_get_type (void)
64 static GType type = 0;
66 if (G_UNLIKELY (type == 0)) {
67 static const GEnumValue values[] = {
68 { EV_LINK_DEST_TYPE_PAGE, "EV_LINK_DEST_TYPE_PAGE", "page" },
69 { EV_LINK_DEST_TYPE_XYZ, "EV_LINK_DEST_TYPE_XYZ", "xyz" },
70 { EV_LINK_DEST_TYPE_FIT, "EV_LINK_DEST_TYPE_FIT", "fit" },
71 { EV_LINK_DEST_TYPE_FITH, "EV_LINK_DEST_TYPE_FITH", "fith" },
72 { EV_LINK_DEST_TYPE_FITV, "EV_LINK_DEST_TYPE_FITV", "fitv" },
73 { EV_LINK_DEST_TYPE_FITR, "EV_LINK_DEST_TYPE_FITR", "fitr" },
74 { EV_LINK_DEST_TYPE_NAMED, "EV_LINK_DEST_TYPE_NAMED", "named" },
75 { EV_LINK_DEST_TYPE_UNKNOWN, "EV_LINK_DEST_TYPE_UNKNOWN", "unknown" },
79 type = g_enum_register_static ("EvLinkDestType", values);
86 ev_link_dest_get_dest_type (EvLinkDest *self)
88 g_return_val_if_fail (EV_IS_LINK_DEST (self), 0);
90 return self->priv->type;
94 ev_link_dest_get_page (EvLinkDest *self)
96 g_return_val_if_fail (EV_IS_LINK_DEST (self), -1);
98 return self->priv->page;
102 ev_link_dest_get_top (EvLinkDest *self)
104 g_return_val_if_fail (EV_IS_LINK_DEST (self), 0);
106 return self->priv->top;
110 ev_link_dest_get_left (EvLinkDest *self)
112 g_return_val_if_fail (EV_IS_LINK_DEST (self), 0);
114 return self->priv->left;
118 ev_link_dest_get_bottom (EvLinkDest *self)
120 g_return_val_if_fail (EV_IS_LINK_DEST (self), 0);
122 return self->priv->bottom;
126 ev_link_dest_get_right (EvLinkDest *self)
128 g_return_val_if_fail (EV_IS_LINK_DEST (self), 0);
130 return self->priv->right;
134 ev_link_dest_get_zoom (EvLinkDest *self)
136 g_return_val_if_fail (EV_IS_LINK_DEST (self), 0);
138 return self->priv->zoom;
142 ev_link_dest_get_named_dest (EvLinkDest *self)
144 g_return_val_if_fail (EV_IS_LINK_DEST (self), NULL);
146 return self->priv->named;
150 ev_link_dest_get_property (GObject *object,
153 GParamSpec *param_spec)
157 self = EV_LINK_DEST (object);
161 g_value_set_enum (value, self->priv->type);
164 g_value_set_int (value, self->priv->page);
167 g_value_set_double (value, self->priv->top);
170 g_value_set_double (value, self->priv->left);
173 g_value_set_double (value, self->priv->bottom);
176 g_value_set_double (value, self->priv->left);
179 g_value_set_double (value, self->priv->zoom);
182 g_value_set_string (value, self->priv->named);
185 G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
193 ev_link_dest_set_property (GObject *object,
196 GParamSpec *param_spec)
198 EvLinkDest *self = EV_LINK_DEST (object);
202 self->priv->type = g_value_get_enum (value);
205 self->priv->page = g_value_get_int (value);
208 self->priv->top = g_value_get_double (value);
211 self->priv->left = g_value_get_double (value);
214 self->priv->bottom = g_value_get_double (value);
217 self->priv->right = g_value_get_double (value);
220 self->priv->zoom = g_value_get_double (value);
223 self->priv->named = g_value_dup_string (value);
226 G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
234 ev_link_dest_finalize (GObject *object)
236 EvLinkDestPrivate *priv;
238 priv = EV_LINK_DEST (object)->priv;
241 g_free (priv->named);
245 G_OBJECT_CLASS (ev_link_dest_parent_class)->finalize (object);
249 ev_link_dest_init (EvLinkDest *ev_link_dest)
251 ev_link_dest->priv = EV_LINK_DEST_GET_PRIVATE (ev_link_dest);
253 ev_link_dest->priv->named = NULL;
257 ev_link_dest_class_init (EvLinkDestClass *ev_link_dest_class)
259 GObjectClass *g_object_class;
261 g_object_class = G_OBJECT_CLASS (ev_link_dest_class);
263 g_object_class->set_property = ev_link_dest_set_property;
264 g_object_class->get_property = ev_link_dest_get_property;
266 g_object_class->finalize = ev_link_dest_finalize;
268 g_type_class_add_private (g_object_class, sizeof (EvLinkDestPrivate));
270 g_object_class_install_property (g_object_class,
272 g_param_spec_enum ("type",
274 "The destination type",
275 EV_TYPE_LINK_DEST_TYPE,
276 EV_LINK_DEST_TYPE_UNKNOWN,
278 G_PARAM_CONSTRUCT_ONLY));
279 g_object_class_install_property (g_object_class,
281 g_param_spec_int ("page",
283 "The destination page",
288 G_PARAM_CONSTRUCT_ONLY));
289 g_object_class_install_property (g_object_class,
291 g_param_spec_double ("left",
293 "The left coordinate",
298 G_PARAM_CONSTRUCT_ONLY));
299 g_object_class_install_property (g_object_class,
301 g_param_spec_double ("top",
303 "The top coordinate",
308 G_PARAM_CONSTRUCT_ONLY));
309 g_object_class_install_property (g_object_class,
311 g_param_spec_double ("bottom",
313 "The bottom coordinate",
318 G_PARAM_CONSTRUCT_ONLY));
319 g_object_class_install_property (g_object_class,
321 g_param_spec_double ("right",
323 "The right coordinate",
328 G_PARAM_CONSTRUCT_ONLY));
330 g_object_class_install_property (g_object_class,
332 g_param_spec_double ("zoom",
339 G_PARAM_CONSTRUCT_ONLY));
340 g_object_class_install_property (g_object_class,
342 g_param_spec_string ("named",
344 "The named destination",
347 G_PARAM_CONSTRUCT_ONLY));
351 ev_link_dest_new_page (gint page)
353 return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
355 "type", EV_LINK_DEST_TYPE_PAGE,
360 ev_link_dest_new_xyz (gint page,
365 return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
367 "type", EV_LINK_DEST_TYPE_XYZ,
375 ev_link_dest_new_fit (gint page)
377 return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
379 "type", EV_LINK_DEST_TYPE_FIT,
384 ev_link_dest_new_fith (gint page,
387 return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
389 "type", EV_LINK_DEST_TYPE_FITH,
395 ev_link_dest_new_fitv (gint page,
398 return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
400 "type", EV_LINK_DEST_TYPE_FITV,
406 ev_link_dest_new_fitr (gint page,
412 return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
414 "type", EV_LINK_DEST_TYPE_FITR,
423 ev_link_dest_new_named (const gchar *named_dest)
425 return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
427 "type", EV_LINK_DEST_TYPE_NAMED,