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 * SECTION:atkhyperlink
25 * @Short_description: An ATK object which encapsulates a link or set
26 * of links in a hypertext document.
29 * An ATK object which encapsulates a link or set of links (for
30 * instance in the case of client-side image maps) in a hypertext
31 * document. It may implement the AtkAction interface. AtkHyperlink
32 * may also be used to refer to inline embedded content, since it
33 * allows specification of a start and end offset within the host
34 * AtkHypertext object.
46 PROP_0, /* gobject convention */
55 static void atk_hyperlink_class_init (AtkHyperlinkClass *klass);
56 static void atk_hyperlink_init (AtkHyperlink *link,
57 AtkHyperlinkClass *klass);
59 static void atk_hyperlink_real_get_property (GObject *object,
64 static void atk_hyperlink_action_iface_init (AtkActionIface *iface);
66 static guint atk_hyperlink_signals[LAST_SIGNAL] = { 0, };
68 static gpointer parent_class = NULL;
71 atk_hyperlink_get_type (void)
73 static GType type = 0;
77 static const GTypeInfo typeInfo =
79 sizeof (AtkHyperlinkClass),
81 (GBaseFinalizeFunc) NULL,
82 (GClassInitFunc) atk_hyperlink_class_init,
83 (GClassFinalizeFunc) NULL,
85 sizeof (AtkHyperlink),
87 (GInstanceInitFunc) atk_hyperlink_init,
90 static const GInterfaceInfo action_info =
92 (GInterfaceInitFunc) atk_hyperlink_action_iface_init,
93 (GInterfaceFinalizeFunc) NULL,
97 type = g_type_register_static (G_TYPE_OBJECT, "AtkHyperlink", &typeInfo, 0) ;
98 g_type_add_interface_static (type, ATK_TYPE_ACTION, &action_info);
104 atk_hyperlink_class_init (AtkHyperlinkClass *klass)
106 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
108 parent_class = g_type_class_peek_parent (klass);
110 gobject_class->get_property = atk_hyperlink_real_get_property;
112 klass->link_activated = NULL;
115 * AtkHyperlink:selected-link:
119 * Deprecated: Since 1.8. This property is deprecated since ATK
120 * version 1.8. Please use ATK_STATE_FOCUSABLE for all links, and
121 * ATK_STATE_FOCUSED for focused links.
124 g_object_class_install_property (gobject_class,
126 g_param_spec_boolean ("selected-link",
128 _("Specifies whether the AtkHyperlink object is selected"),
131 g_object_class_install_property (gobject_class,
133 g_param_spec_int ("number-of-anchors",
134 _("Number of Anchors"),
135 _("The number of anchors associated with the AtkHyperlink object"),
140 g_object_class_install_property (gobject_class,
142 g_param_spec_int ("end-index",
144 _("The end index of the AtkHyperlink object"),
149 g_object_class_install_property (gobject_class,
151 g_param_spec_int ("start-index",
153 _("The start index of the AtkHyperlink object"),
160 * AtkHyperlink::link-activated:
161 * @atkhyperlink: the object which received the signal.
163 * The signal link-activated is emitted when a link is activated.
165 atk_hyperlink_signals[LINK_ACTIVATED] =
166 g_signal_new ("link_activated",
167 G_TYPE_FROM_CLASS (klass),
169 G_STRUCT_OFFSET (AtkHyperlinkClass, link_activated),
171 g_cclosure_marshal_VOID__VOID,
178 atk_hyperlink_init (AtkHyperlink *link,
179 AtkHyperlinkClass *klass)
184 atk_hyperlink_real_get_property (GObject *object,
191 link = ATK_HYPERLINK (object);
195 case PROP_SELECTED_LINK:
196 // This property is deprecated, also the method to get the value
197 g_value_set_boolean (value, FALSE);
199 case PROP_NUMBER_ANCHORS:
200 g_value_set_int (value, atk_hyperlink_get_n_anchors (link));
203 g_value_set_int (value, atk_hyperlink_get_end_index (link));
205 case PROP_START_INDEX:
206 g_value_set_int (value, atk_hyperlink_get_start_index (link));
214 * atk_hyperlink_get_uri:
215 * @link_: an #AtkHyperlink
216 * @i: a (zero-index) integer specifying the desired anchor
218 * Get a the URI associated with the anchor specified
221 * Multiple anchors are primarily used by client-side image maps.
223 * Returns: a string specifying the URI
226 atk_hyperlink_get_uri (AtkHyperlink *link,
229 AtkHyperlinkClass *klass;
231 g_return_val_if_fail (ATK_IS_HYPERLINK (link), NULL);
233 klass = ATK_HYPERLINK_GET_CLASS (link);
235 return (klass->get_uri) (link, i);
241 * atk_hyperlink_get_object:
242 * @link_: an #AtkHyperlink
243 * @i: a (zero-index) integer specifying the desired anchor
245 * Returns the item associated with this hyperlinks nth anchor.
246 * For instance, the returned #AtkObject will implement #AtkText
247 * if @link_ is a text hyperlink, #AtkImage if @link_ is an image
250 * Multiple anchors are primarily used by client-side image maps.
252 * Returns: (transfer none): an #AtkObject associated with this hyperlinks
256 atk_hyperlink_get_object (AtkHyperlink *link,
259 AtkHyperlinkClass *klass;
261 g_return_val_if_fail (ATK_IS_HYPERLINK (link), NULL);
263 klass = ATK_HYPERLINK_GET_CLASS (link);
264 if (klass->get_object)
265 return (klass->get_object) (link, i);
271 * atk_hyperlink_get_end_index:
272 * @link_: an #AtkHyperlink
274 * Gets the index with the hypertext document at which this link ends.
276 * Returns: the index with the hypertext document at which this link ends
279 atk_hyperlink_get_end_index (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_end_index)
287 return (klass->get_end_index) (link);
293 * atk_hyperlink_get_start_index:
294 * @link_: an #AtkHyperlink
296 * Gets the index with the hypertext document at which this link begins.
298 * Returns: the index with the hypertext document at which this link begins
301 atk_hyperlink_get_start_index (AtkHyperlink *link)
303 AtkHyperlinkClass *klass;
305 g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0);
307 klass = ATK_HYPERLINK_GET_CLASS (link);
308 if (klass->get_start_index)
309 return (klass->get_start_index) (link);
315 * atk_hyperlink_is_valid:
316 * @link_: an #AtkHyperlink
318 * Since the document that a link is associated with may have changed
319 * this method returns %TRUE if the link is still valid (with
320 * respect to the document it references) and %FALSE otherwise.
322 * Returns: whether or not this link is still valid
325 atk_hyperlink_is_valid (AtkHyperlink *link)
327 AtkHyperlinkClass *klass;
329 g_return_val_if_fail (ATK_IS_HYPERLINK (link), FALSE);
331 klass = ATK_HYPERLINK_GET_CLASS (link);
333 return (klass->is_valid) (link);
339 * atk_hyperlink_is_inline:
340 * @link_: an #AtkHyperlink
342 * Indicates whether the link currently displays some or all of its
343 * content inline. Ordinary HTML links will usually return
344 * %FALSE, but an inline <src> HTML element will return
347 * Returns: whether or not this link displays its content inline.
351 atk_hyperlink_is_inline (AtkHyperlink *link)
353 AtkHyperlinkClass *klass;
355 g_return_val_if_fail (ATK_IS_HYPERLINK (link), FALSE);
357 klass = ATK_HYPERLINK_GET_CLASS (link);
358 if (klass->link_state)
359 return (klass->link_state (link) & ATK_HYPERLINK_IS_INLINE);
365 * atk_hyperlink_get_n_anchors:
366 * @link_: an #AtkHyperlink
368 * Gets the number of anchors associated with this hyperlink.
370 * Returns: the number of anchors associated with this hyperlink
373 atk_hyperlink_get_n_anchors (AtkHyperlink *link)
375 AtkHyperlinkClass *klass;
377 g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0);
379 klass = ATK_HYPERLINK_GET_CLASS (link);
380 if (klass->get_n_anchors)
381 return (klass->get_n_anchors) (link);
387 * atk_hyperlink_is_selected_link:
388 * @link_: an #AtkHyperlink
390 * Determines whether this AtkHyperlink is selected
394 * Deprecated: This method is deprecated since ATK version 1.8.
395 * Please use ATK_STATE_FOCUSABLE for all links, and ATK_STATE_FOCUSED
398 * Returns: True is the AtkHyperlink is selected, False otherwise
401 atk_hyperlink_is_selected_link (AtkHyperlink *link)
403 AtkHyperlinkClass *klass;
405 g_return_val_if_fail (ATK_IS_HYPERLINK (link), FALSE);
407 klass = ATK_HYPERLINK_GET_CLASS (link);
408 if (klass->is_selected_link)
409 return (klass->is_selected_link) (link);
414 static void atk_hyperlink_action_iface_init (AtkActionIface *iface)
419 * When we come to derive a class from AtkHyperlink we will provide an
420 * implementation of the AtkAction interface.