Make use of parent_class consistent; define as gpointer and use
[atk.git] / atk / atkhyperlink.c
blob65dfe13aa4472142fdd29ed58e6af3c692c56b48
1 /* ATK - Accessibility Toolkit
2 * Copyright 2001 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include "atkhyperlink.h"
23 static void atk_hyperlink_class_init (AtkHyperlinkClass *klass);
24 static void atk_hyperlink_init (AtkHyperlink *link,
25 AtkHyperlinkClass *klass);
27 static void atk_hyperlink_action_iface_init (AtkActionIface *iface);
29 static gpointer parent_class = NULL;
31 GType
32 atk_hyperlink_get_type (void)
34 static GType type = 0;
36 if (!type)
38 static const GTypeInfo typeInfo =
40 sizeof (AtkHyperlinkClass),
41 (GBaseInitFunc) NULL,
42 (GBaseFinalizeFunc) NULL,
43 (GClassInitFunc) atk_hyperlink_class_init,
44 (GClassFinalizeFunc) NULL,
45 NULL,
46 sizeof (AtkObject),
48 (GInstanceInitFunc) atk_hyperlink_init,
49 } ;
51 static const GInterfaceInfo action_info =
53 (GInterfaceInitFunc) atk_hyperlink_action_iface_init,
54 (GInterfaceFinalizeFunc) NULL,
55 NULL
58 type = g_type_register_static (G_TYPE_OBJECT, "AtkHyperlink", &typeInfo, 0) ;
59 g_type_add_interface_static (type, ATK_TYPE_ACTION, &action_info);
61 return type;
64 static void
65 atk_hyperlink_class_init (AtkHyperlinkClass *klass)
67 parent_class = g_type_class_peek_parent (klass);
71 static void
72 atk_hyperlink_init (AtkHyperlink *link,
73 AtkHyperlinkClass *klass)
77 /**
78 * atk_hyperlink_get_uri:
79 * @link: an #AtkHyperlink
80 * @i: a (zero-index) integer specifying the desired anchor
82 * Get a the URI associated with the anchor specified
83 * by @i of @link.
85 * Multiple anchors are primarily used by client-side image maps.
87 * Returns: a string specifying the URI
88 **/
89 gchar*
90 atk_hyperlink_get_uri (AtkHyperlink *link,
91 gint i)
93 AtkHyperlinkClass *klass;
95 g_return_val_if_fail (ATK_IS_HYPERLINK (link), NULL);
97 klass = ATK_HYPERLINK_GET_CLASS (link);
98 if (klass->get_uri)
99 return (klass->get_uri) (link, i);
100 else
101 return NULL;
105 * atk_hyperlink_get_object:
106 * @link: an #AtkHyperlink
107 * @i: a (zero-index) integer specifying the desired anchor
109 * Returns the item associated with this hyperlinks nth anchor.
110 * For instance, the returned #AtkObject will implement #AtkText
111 * if @link is a text hyperlink, #AtkImage if @link is an image
112 * hyperlink etc.
114 * Multiple anchors are primarily used by client-side image maps.
116 * Returns: an #AtkObject associated with this hyperlinks i-th anchor
118 AtkObject*
119 atk_hyperlink_get_object (AtkHyperlink *link,
120 gint i)
122 AtkHyperlinkClass *klass;
124 g_return_val_if_fail (ATK_IS_HYPERLINK (link), NULL);
126 klass = ATK_HYPERLINK_GET_CLASS (link);
127 if (klass->get_object)
128 return (klass->get_object) (link, i);
129 else
130 return NULL;
134 * atk_hyperlink_get_end_index:
135 * @link: an #AtkHyperlink
137 * Gets the index with the hypertext document at which this link ends.
139 * Returns: the index with the hypertext document at which this link ends
141 gint
142 atk_hyperlink_get_end_index (AtkHyperlink *link)
144 AtkHyperlinkClass *klass;
146 g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0);
148 klass = ATK_HYPERLINK_GET_CLASS (link);
149 if (klass->get_end_index)
150 return (klass->get_end_index) (link);
151 else
152 return 0;
156 * atk_hyperlink_get_start_index:
157 * @link: an #AtkHyperlink
159 * Gets the index with the hypertext document at which this link begins.
161 * Returns: the index with the hypertext document at which this link begins
163 gint
164 atk_hyperlink_get_start_index (AtkHyperlink *link)
166 AtkHyperlinkClass *klass;
168 g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0);
170 klass = ATK_HYPERLINK_GET_CLASS (link);
171 if (klass->get_start_index)
172 return (klass->get_start_index) (link);
173 else
174 return 0;
178 * atk_hyperlink_is_valid:
179 * @link: an #AtkHyperlink
181 * Since the document that a link is associated with may have changed
182 * this method returns %TRUE if the link is still valid (with
183 * respect to the document it references) and %FALSE otherwise.
185 * Returns: whether or not this link is still valid
187 gboolean
188 atk_hyperlink_is_valid (AtkHyperlink *link)
190 AtkHyperlinkClass *klass;
192 g_return_val_if_fail (ATK_IS_HYPERLINK (link), FALSE);
194 klass = ATK_HYPERLINK_GET_CLASS (link);
195 if (klass->is_valid)
196 return (klass->is_valid) (link);
197 else
198 return FALSE;
202 * atk_hyperlink_get_n_anchors:
203 * @link: an #AtkHyperlink
205 * Gets the number of anchors associated with this hyperlink.
207 * Returns: the number of anchors associated with this hyperlink
209 gint
210 atk_hyperlink_get_n_anchors (AtkHyperlink *link)
212 AtkHyperlinkClass *klass;
214 g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0);
216 klass = ATK_HYPERLINK_GET_CLASS (link);
217 if (klass->get_n_anchors)
218 return (klass->get_n_anchors) (link);
219 else
220 return 0;
223 static void atk_hyperlink_action_iface_init (AtkActionIface *iface)
226 * We do nothing here
228 * When we come to derive a class from AtkHyperlink we will provide an
229 * implementation of the AtkAction interface.
231 * This depends on being able to override an interface in a derived class
232 * which currently (March 2001) is not implemented but will be in GTK+ 2.0.