1 /* ATK - Accessibility Toolkit
2 * Copyright 2001, 2002, 2003 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"
24 PROP_0, /* gobject convention */
30 static void atk_hyperlink_class_init (AtkHyperlinkClass *klass);
31 static void atk_hyperlink_init (AtkHyperlink *link,
32 AtkHyperlinkClass *klass);
34 static void atk_hyperlink_real_get_property (GObject *object,
39 static void atk_hyperlink_action_iface_init (AtkActionIface *iface);
41 static gpointer parent_class = NULL;
44 atk_hyperlink_get_type (void)
46 static GType type = 0;
50 static const GTypeInfo typeInfo =
52 sizeof (AtkHyperlinkClass),
54 (GBaseFinalizeFunc) NULL,
55 (GClassInitFunc) atk_hyperlink_class_init,
56 (GClassFinalizeFunc) NULL,
58 sizeof (AtkHyperlink),
60 (GInstanceInitFunc) atk_hyperlink_init,
63 static const GInterfaceInfo action_info =
65 (GInterfaceInitFunc) atk_hyperlink_action_iface_init,
66 (GInterfaceFinalizeFunc) NULL,
70 type = g_type_register_static (G_TYPE_OBJECT, "AtkHyperlink", &typeInfo, 0) ;
71 g_type_add_interface_static (type, ATK_TYPE_ACTION, &action_info);
77 atk_hyperlink_class_init (AtkHyperlinkClass *klass)
79 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
81 parent_class = g_type_class_peek_parent (klass);
83 gobject_class->get_property = atk_hyperlink_real_get_property;
85 g_object_class_install_property (gobject_class,
87 g_param_spec_boolean ("selected-link",
89 "Specifies whether the AtkHyperlink object is selected",
95 atk_hyperlink_init (AtkHyperlink *link,
96 AtkHyperlinkClass *klass)
101 atk_hyperlink_real_get_property (GObject *object,
108 link = ATK_HYPERLINK (object);
112 case PROP_SELECTED_LINK:
113 g_value_set_boolean (value, atk_hyperlink_is_selected_link (link));
121 * atk_hyperlink_get_uri:
122 * @link_: an #AtkHyperlink
123 * @i: a (zero-index) integer specifying the desired anchor
125 * Get a the URI associated with the anchor specified
128 * Multiple anchors are primarily used by client-side image maps.
130 * Returns: a string specifying the URI
133 atk_hyperlink_get_uri (AtkHyperlink *link,
136 AtkHyperlinkClass *klass;
138 g_return_val_if_fail (ATK_IS_HYPERLINK (link), NULL);
140 klass = ATK_HYPERLINK_GET_CLASS (link);
142 return (klass->get_uri) (link, i);
148 * atk_hyperlink_get_object:
149 * @link_: an #AtkHyperlink
150 * @i: a (zero-index) integer specifying the desired anchor
152 * Returns the item associated with this hyperlinks nth anchor.
153 * For instance, the returned #AtkObject will implement #AtkText
154 * if @link_ is a text hyperlink, #AtkImage if @link_ is an image
157 * Multiple anchors are primarily used by client-side image maps.
159 * Returns: an #AtkObject associated with this hyperlinks i-th anchor
162 atk_hyperlink_get_object (AtkHyperlink *link,
165 AtkHyperlinkClass *klass;
167 g_return_val_if_fail (ATK_IS_HYPERLINK (link), NULL);
169 klass = ATK_HYPERLINK_GET_CLASS (link);
170 if (klass->get_object)
171 return (klass->get_object) (link, i);
177 * atk_hyperlink_get_end_index:
178 * @link_: an #AtkHyperlink
180 * Gets the index with the hypertext document at which this link ends.
182 * Returns: the index with the hypertext document at which this link ends
185 atk_hyperlink_get_end_index (AtkHyperlink *link)
187 AtkHyperlinkClass *klass;
189 g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0);
191 klass = ATK_HYPERLINK_GET_CLASS (link);
192 if (klass->get_end_index)
193 return (klass->get_end_index) (link);
199 * atk_hyperlink_get_start_index:
200 * @link_: an #AtkHyperlink
202 * Gets the index with the hypertext document at which this link begins.
204 * Returns: the index with the hypertext document at which this link begins
207 atk_hyperlink_get_start_index (AtkHyperlink *link)
209 AtkHyperlinkClass *klass;
211 g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0);
213 klass = ATK_HYPERLINK_GET_CLASS (link);
214 if (klass->get_start_index)
215 return (klass->get_start_index) (link);
221 * atk_hyperlink_is_valid:
222 * @link_: an #AtkHyperlink
224 * Since the document that a link is associated with may have changed
225 * this method returns %TRUE if the link is still valid (with
226 * respect to the document it references) and %FALSE otherwise.
228 * Returns: whether or not this link is still valid
231 atk_hyperlink_is_valid (AtkHyperlink *link)
233 AtkHyperlinkClass *klass;
235 g_return_val_if_fail (ATK_IS_HYPERLINK (link), FALSE);
237 klass = ATK_HYPERLINK_GET_CLASS (link);
239 return (klass->is_valid) (link);
245 * atk_hyperlink_is_inline:
246 * @link_: an #AtkHyperlink
248 * Indicates whether the link currently displays some or all of its
249 * content inline. Ordinary HTML links will usually return
250 * %FALSE, but an inline <src> HTML element will return
253 * Returns: whether or not this link displays its content inline.
257 atk_hyperlink_is_inline (AtkHyperlink *link)
259 AtkHyperlinkClass *klass;
261 g_return_val_if_fail (ATK_IS_HYPERLINK (link), FALSE);
263 klass = ATK_HYPERLINK_GET_CLASS (link);
264 if (klass->link_state)
265 return (klass->link_state (link) & ATK_HYPERLINK_IS_INLINE);
271 * atk_hyperlink_get_n_anchors:
272 * @link_: an #AtkHyperlink
274 * Gets the number of anchors associated with this hyperlink.
276 * Returns: the number of anchors associated with this hyperlink
279 atk_hyperlink_get_n_anchors (AtkHyperlink *link)
281 AtkHyperlinkClass *klass;
283 g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0);
285 klass = ATK_HYPERLINK_GET_CLASS (link);
286 if (klass->get_n_anchors)
287 return (klass->get_n_anchors) (link);
293 * atk_hyperlink_is_selected_link:
294 * @link_: an #AtkHyperlink
296 * Determines whether this AtkHyperlink is selected
298 * Returns: True is the AtkHyperlink is selected, False otherwise
301 atk_hyperlink_is_selected_link (AtkHyperlink *link)
303 AtkHyperlinkClass *klass;
305 g_return_val_if_fail (ATK_IS_HYPERLINK (link), FALSE);
307 klass = ATK_HYPERLINK_GET_CLASS (link);
308 if (klass->is_selected_link)
309 return (klass->is_selected_link) (link);
314 static void atk_hyperlink_action_iface_init (AtkActionIface *iface)
319 * When we come to derive a class from AtkHyperlink we will provide an
320 * implementation of the AtkAction interface.