1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
2 /* this file is part of evince, a gnome document viewer
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31 GObject base_instance;
36 GObjectClass base_class;
39 struct _EvLinkPrivate {
44 G_DEFINE_TYPE (EvLink, ev_link, G_TYPE_OBJECT)
46 #define EV_LINK_GET_PRIVATE(object) \
47 (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_LINK, EvLinkPrivate))
50 ev_link_get_title (EvLink *self)
52 g_return_val_if_fail (EV_IS_LINK (self), NULL);
54 return self->priv->title;
58 ev_link_get_action (EvLink *self)
60 g_return_val_if_fail (EV_IS_LINK (self), NULL);
62 return self->priv->action;
66 ev_link_get_property (GObject *object,
69 GParamSpec *param_spec)
73 self = EV_LINK (object);
77 g_value_set_string (value, self->priv->title);
80 g_value_set_pointer (value, self->priv->action);
83 G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
91 ev_link_set_property (GObject *object,
94 GParamSpec *param_spec)
96 EvLink *self = EV_LINK (object);
100 self->priv->title = g_value_dup_string (value);
103 self->priv->action = g_value_get_pointer (value);
106 G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
114 ev_link_finalize (GObject *object)
118 priv = EV_LINK (object)->priv;
121 g_free (priv->title);
126 g_object_unref (priv->action);
130 G_OBJECT_CLASS (ev_link_parent_class)->finalize (object);
134 ev_link_init (EvLink *ev_link)
136 ev_link->priv = EV_LINK_GET_PRIVATE (ev_link);
138 ev_link->priv->title = NULL;
139 ev_link->priv->action = NULL;
143 ev_link_class_init (EvLinkClass *ev_window_class)
145 GObjectClass *g_object_class;
147 g_object_class = G_OBJECT_CLASS (ev_window_class);
149 g_object_class->set_property = ev_link_set_property;
150 g_object_class->get_property = ev_link_get_property;
152 g_object_class->finalize = ev_link_finalize;
154 g_type_class_add_private (g_object_class, sizeof (EvLinkPrivate));
156 g_object_class_install_property (g_object_class,
158 g_param_spec_string ("title",
163 G_PARAM_CONSTRUCT_ONLY));
164 g_object_class_install_property (g_object_class,
166 g_param_spec_pointer ("action",
170 G_PARAM_CONSTRUCT_ONLY));
174 ev_link_new (const char *title,
175 EvLinkAction *action)
177 return EV_LINK (g_object_new (EV_TYPE_LINK,
184 ev_link_get_page (EvLink *link)
186 EvLinkAction *action;
189 action = ev_link_get_action (link);
193 if (ev_link_action_get_action_type (action) !=
194 EV_LINK_ACTION_TYPE_GOTO_DEST)
197 dest = ev_link_action_get_dest (action);
199 return ev_link_dest_get_page (dest);