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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
30 GObject base_instance;
35 GObjectClass base_class;
38 struct _EvLinkPrivate {
43 G_DEFINE_TYPE (EvLink, ev_link, G_TYPE_OBJECT)
45 #define EV_LINK_GET_PRIVATE(object) \
46 (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_LINK, EvLinkPrivate))
49 ev_link_get_title (EvLink *self)
51 g_return_val_if_fail (EV_IS_LINK (self), NULL);
53 return self->priv->title;
57 ev_link_get_action (EvLink *self)
59 g_return_val_if_fail (EV_IS_LINK (self), NULL);
61 return self->priv->action;
65 ev_link_get_property (GObject *object,
68 GParamSpec *param_spec)
72 self = EV_LINK (object);
76 g_value_set_string (value, self->priv->title);
79 g_value_set_pointer (value, self->priv->action);
82 G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
90 ev_link_set_property (GObject *object,
93 GParamSpec *param_spec)
95 EvLink *self = EV_LINK (object);
99 self->priv->title = g_value_dup_string (value);
102 self->priv->action = g_value_get_pointer (value);
105 G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
113 ev_link_finalize (GObject *object)
117 priv = EV_LINK (object)->priv;
120 g_free (priv->title);
125 g_object_unref (priv->action);
129 G_OBJECT_CLASS (ev_link_parent_class)->finalize (object);
133 ev_link_init (EvLink *ev_link)
135 ev_link->priv = EV_LINK_GET_PRIVATE (ev_link);
137 ev_link->priv->title = NULL;
138 ev_link->priv->action = NULL;
142 ev_link_class_init (EvLinkClass *ev_window_class)
144 GObjectClass *g_object_class;
146 g_object_class = G_OBJECT_CLASS (ev_window_class);
148 g_object_class->set_property = ev_link_set_property;
149 g_object_class->get_property = ev_link_get_property;
151 g_object_class->finalize = ev_link_finalize;
153 g_type_class_add_private (g_object_class, sizeof (EvLinkPrivate));
155 g_object_class_install_property (g_object_class,
157 g_param_spec_string ("title",
162 G_PARAM_CONSTRUCT_ONLY));
163 g_object_class_install_property (g_object_class,
165 g_param_spec_pointer ("action",
169 G_PARAM_CONSTRUCT_ONLY));
173 ev_link_new (const char *title,
174 EvLinkAction *action)
176 return EV_LINK (g_object_new (EV_TYPE_LINK,
182 /* Link Mapping stuff */
184 ev_link_mapping_free_foreach (EvLinkMapping *mapping)
186 g_object_unref (G_OBJECT (mapping->link));
191 ev_link_mapping_free (GList *link_mapping)
193 if (link_mapping == NULL)
196 g_list_foreach (link_mapping, (GFunc) (ev_link_mapping_free_foreach), NULL);
197 g_list_free (link_mapping);
201 ev_link_mapping_find (GList *link_mapping,
211 for (list = link_mapping; list; list = list->next) {
212 EvLinkMapping *mapping = list->data;
215 if ((x >= mapping->x1) &&
216 (y >= mapping->y1) &&
217 (x <= mapping->x2) &&
218 (y <= mapping->y2)) {
219 link = mapping->link;