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"
32 PROP_0, /* gobject convention */
41 static void atk_hyperlink_class_init (AtkHyperlinkClass *klass);
42 static void atk_hyperlink_init (AtkHyperlink *link,
43 AtkHyperlinkClass *klass);
45 static void atk_hyperlink_real_get_property (GObject *object,
50 static void atk_hyperlink_action_iface_init (AtkActionIface *iface);
52 static guint atk_hyperlink_signals[LAST_SIGNAL] = { 0, };
54 static gpointer parent_class = NULL;
57 atk_hyperlink_get_type (void)
59 static GType type = 0;
63 static const GTypeInfo typeInfo =
65 sizeof (AtkHyperlinkClass),
67 (GBaseFinalizeFunc) NULL,
68 (GClassInitFunc) atk_hyperlink_class_init,
69 (GClassFinalizeFunc) NULL,
71 sizeof (AtkHyperlink),
73 (GInstanceInitFunc) atk_hyperlink_init,
76 static const GInterfaceInfo action_info =
78 (GInterfaceInitFunc) atk_hyperlink_action_iface_init,
79 (GInterfaceFinalizeFunc) NULL,
83 type = g_type_register_static (G_TYPE_OBJECT, "AtkHyperlink", &typeInfo, 0) ;
84 g_type_add_interface_static (type, ATK_TYPE_ACTION, &action_info);
90 atk_hyperlink_class_init (AtkHyperlinkClass *klass)
92 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
94 parent_class = g_type_class_peek_parent (klass);
96 gobject_class->get_property = atk_hyperlink_real_get_property;
98 klass->link_activated = NULL;
100 g_object_class_install_property (gobject_class,
102 g_param_spec_boolean ("selected-link",
104 _("Specifies whether the AtkHyperlink object is selected"),
107 g_object_class_install_property (gobject_class,
109 g_param_spec_int ("number-of-anchors",
110 _("Number of Anchors"),
111 _("The number of anchors associated with the AtkHyperlink object"),
116 g_object_class_install_property (gobject_class,
118 g_param_spec_int ("end-index",
120 _("The end index of the AtkHyperlink object"),
125 g_object_class_install_property (gobject_class,
127 g_param_spec_int ("start-index",
129 _("The start index of the AtkHyperlink object"),
134 atk_hyperlink_signals[LINK_ACTIVATED] =
135 g_signal_new ("link_activated",
136 G_TYPE_FROM_CLASS (klass),
138 G_STRUCT_OFFSET (AtkHyperlinkClass, link_activated),
140 g_cclosure_marshal_VOID__VOID,
147 atk_hyperlink_init (AtkHyperlink *link,
148 AtkHyperlinkClass *klass)
153 atk_hyperlink_real_get_property (GObject *object,
160 link = ATK_HYPERLINK (object);
164 case PROP_SELECTED_LINK:
165 g_value_set_boolean (value, atk_hyperlink_is_selected_link (link));
167 case PROP_NUMBER_ANCHORS:
168 g_value_set_int (value, atk_hyperlink_get_n_anchors (link));
171 g_value_set_int (value, atk_hyperlink_get_end_index (link));
173 case PROP_START_INDEX:
174 g_value_set_int (value, atk_hyperlink_get_start_index (link));
182 * atk_hyperlink_get_uri:
183 * @link_: an #AtkHyperlink
184 * @i: a (zero-index) integer specifying the desired anchor
186 * Get a the URI associated with the anchor specified
189 * Multiple anchors are primarily used by client-side image maps.
191 * Returns: a string specifying the URI
194 atk_hyperlink_get_uri (AtkHyperlink *link,
197 AtkHyperlinkClass *klass;
199 g_return_val_if_fail (ATK_IS_HYPERLINK (link), NULL);
201 klass = ATK_HYPERLINK_GET_CLASS (link);
203 return (klass->get_uri) (link, i);
209 * atk_hyperlink_get_object:
210 * @link_: an #AtkHyperlink
211 * @i: a (zero-index) integer specifying the desired anchor
213 * Returns the item associated with this hyperlinks nth anchor.
214 * For instance, the returned #AtkObject will implement #AtkText
215 * if @link_ is a text hyperlink, #AtkImage if @link_ is an image
218 * Multiple anchors are primarily used by client-side image maps.
220 * Returns: an #AtkObject associated with this hyperlinks i-th anchor
223 atk_hyperlink_get_object (AtkHyperlink *link,
226 AtkHyperlinkClass *klass;
228 g_return_val_if_fail (ATK_IS_HYPERLINK (link), NULL);
230 klass = ATK_HYPERLINK_GET_CLASS (link);
231 if (klass->get_object)
232 return (klass->get_object) (link, i);
238 * atk_hyperlink_get_end_index:
239 * @link_: an #AtkHyperlink
241 * Gets the index with the hypertext document at which this link ends.
243 * Returns: the index with the hypertext document at which this link ends
246 atk_hyperlink_get_end_index (AtkHyperlink *link)
248 AtkHyperlinkClass *klass;
250 g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0);
252 klass = ATK_HYPERLINK_GET_CLASS (link);
253 if (klass->get_end_index)
254 return (klass->get_end_index) (link);
260 * atk_hyperlink_get_start_index:
261 * @link_: an #AtkHyperlink
263 * Gets the index with the hypertext document at which this link begins.
265 * Returns: the index with the hypertext document at which this link begins
268 atk_hyperlink_get_start_index (AtkHyperlink *link)
270 AtkHyperlinkClass *klass;
272 g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0);
274 klass = ATK_HYPERLINK_GET_CLASS (link);
275 if (klass->get_start_index)
276 return (klass->get_start_index) (link);
282 * atk_hyperlink_is_valid:
283 * @link_: an #AtkHyperlink
285 * Since the document that a link is associated with may have changed
286 * this method returns %TRUE if the link is still valid (with
287 * respect to the document it references) and %FALSE otherwise.
289 * Returns: whether or not this link is still valid
292 atk_hyperlink_is_valid (AtkHyperlink *link)
294 AtkHyperlinkClass *klass;
296 g_return_val_if_fail (ATK_IS_HYPERLINK (link), FALSE);
298 klass = ATK_HYPERLINK_GET_CLASS (link);
300 return (klass->is_valid) (link);
306 * atk_hyperlink_is_inline:
307 * @link_: an #AtkHyperlink
309 * Indicates whether the link currently displays some or all of its
310 * content inline. Ordinary HTML links will usually return
311 * %FALSE, but an inline <src> HTML element will return
314 * Returns: whether or not this link displays its content inline.
318 atk_hyperlink_is_inline (AtkHyperlink *link)
320 AtkHyperlinkClass *klass;
322 g_return_val_if_fail (ATK_IS_HYPERLINK (link), FALSE);
324 klass = ATK_HYPERLINK_GET_CLASS (link);
325 if (klass->link_state)
326 return (klass->link_state (link) & ATK_HYPERLINK_IS_INLINE);
332 * atk_hyperlink_get_n_anchors:
333 * @link_: an #AtkHyperlink
335 * Gets the number of anchors associated with this hyperlink.
337 * Returns: the number of anchors associated with this hyperlink
340 atk_hyperlink_get_n_anchors (AtkHyperlink *link)
342 AtkHyperlinkClass *klass;
344 g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0);
346 klass = ATK_HYPERLINK_GET_CLASS (link);
347 if (klass->get_n_anchors)
348 return (klass->get_n_anchors) (link);
354 * atk_hyperlink_is_selected_link:
355 * @link_: an #AtkHyperlink
357 * Determines whether this AtkHyperlink is selected
361 * @Deprecated: This method is deprecated since ATK version 1.8.
362 * Please use ATK_STATE_SELECTED to indicate when a hyperlink within a
363 * Hypertext container is selected.
365 * Returns: True is the AtkHyperlink is selected, False otherwise
368 atk_hyperlink_is_selected_link (AtkHyperlink *link)
370 AtkHyperlinkClass *klass;
372 g_return_val_if_fail (ATK_IS_HYPERLINK (link), FALSE);
374 klass = ATK_HYPERLINK_GET_CLASS (link);
375 if (klass->is_selected_link)
376 return (klass->is_selected_link) (link);
381 static void atk_hyperlink_action_iface_init (AtkActionIface *iface)
386 * When we come to derive a class from AtkHyperlink we will provide an
387 * implementation of the AtkAction interface.