2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
7 * Copyright 2010, 2011 Novell, Inc.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
25 #include "atspi-private.h"
27 G_DEFINE_TYPE (AtspiHyperlink, atspi_hyperlink, ATSPI_TYPE_OBJECT)
30 atspi_hyperlink_init (AtspiHyperlink *hyperlink)
35 atspi_hyperlink_class_init (AtspiHyperlinkClass *klass)
40 atspi_hyperlink_new (AtspiApplication *app, const gchar *path)
42 AtspiHyperlink *hyperlink;
44 hyperlink = g_object_new (ATSPI_TYPE_HYPERLINK, NULL);
45 g_return_val_if_fail (hyperlink != NULL, NULL);
47 hyperlink->parent.app = g_object_ref (app);
48 hyperlink->parent.path = g_strdup (path);
54 * atspi_hyperlink_get_n_anchors:
55 * @obj: a pointer to the #AtspiHyperlink object on which to operate.
57 * Get the total number of anchors which an #AtspiHyperlink implementor has.
58 * Though typical hyperlinks have only one anchor, client-side image maps and
59 * other hypertext objects may potentially activate or refer to multiple
60 * URIs. For each anchor there is a corresponding URI and object.
61 * see atspi_hyperlink_get_uri() and atspi_hyperlink_get_object().
63 * Returns: a #gint indicating the number of anchors in this hyperlink.
66 atspi_hyperlink_get_n_anchors (AtspiHyperlink *obj, GError **error)
68 dbus_int32_t retval = -1;
70 g_return_val_if_fail (obj != NULL, -1);
72 _atspi_dbus_get_property (obj, atspi_interface_hyperlink, "NAnchors", error, "i", &retval);
78 * atspi_hyperlink_get_uri:
79 * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
80 * @i: a (zero-index) integer indicating which hyperlink anchor to query.
82 * Get the URI associated with a particular hyperlink anchor.
84 * Returns: a UTF-8 string giving the URI of the @ith hyperlink anchor.
87 atspi_hyperlink_get_uri (AtspiHyperlink *obj, int i, GError **error)
92 g_return_val_if_fail (obj != NULL, NULL);
94 _atspi_dbus_call (obj, atspi_interface_hyperlink, "GetURI", error, "i=>s", d_i, &retval);
97 retval = g_strdup ("");
103 * atspi_hyperlink_get_object:
104 * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
105 * @i: a (zero-index) long integer indicating which hyperlink anchor to query.
107 * Get the object associated with a particular hyperlink anchor, as an #Accessible.
109 * Returns: (transfer full): an #AtspiAccessible that represents the object
110 * associated with the @ith anchor of the specified #AtspiHyperlink.
113 atspi_hyperlink_get_object (AtspiHyperlink *obj, gint i, GError **error)
115 dbus_int32_t d_i = i;
118 g_return_val_if_fail (obj != NULL, NULL);
120 reply = _atspi_dbus_call_partial (obj, atspi_interface_hyperlink, "GetObject", error, "i", d_i);
122 return _atspi_dbus_return_accessible_from_message (reply);
126 * atspi_hyperlink_get_index_range:
127 * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
130 * Get the starting and ending character offsets of the text range associated with
131 * a #AtspiHyperlink, in its originating #AtspiHypertext.
134 atspi_hyperlink_get_index_range (AtspiHyperlink *obj, GError **error)
136 dbus_int32_t d_start_offset, d_end_offset;
137 AtspiRange *ret = g_new (AtspiRange, 1);
140 ret->start_offset = ret->end_offset = -1;
145 _atspi_dbus_call (obj, atspi_interface_hyperlink, "GetIndexRange", error, "=>ii", &d_start_offset, &d_end_offset);
147 ret->start_offset = d_start_offset;
148 ret->end_offset = d_end_offset;
153 * atspi_hyperlink_get_start_index:
154 * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
157 * Get the starting character offset of the text range associated with
158 * a #AtspiHyperlink, in its originating #AtspiHypertext.
161 atspi_hyperlink_get_start_index (AtspiHyperlink *obj, GError **error)
163 dbus_int32_t d_start_offset = -1;
168 _atspi_dbus_get_property (obj, atspi_interface_hyperlink, "StartIndex",
169 error, "i", &d_start_offset);
171 return d_start_offset;
174 * atspi_hyperlink_get_end_index:
175 * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
178 * Get the ending character offset of the text range associated with
179 * a #AtspiHyperlink, in its originating #AtspiHypertext.
182 atspi_hyperlink_get_end_index (AtspiHyperlink *obj, GError **error)
184 dbus_int32_t d_end_offset = -1;
189 _atspi_dbus_get_property (obj, atspi_interface_hyperlink, "EndIndex", error,
197 * atspi_hyperlink_is_valid:
198 * @obj: a pointer to the #AtspiHyperlink on which to operate.
200 * Tell whether an #AtspiHyperlink object is still valid with respect to its
201 * originating hypertext object.
203 * Returns: #TRUE of the specified #AtspiHyperlink is still valid with respect
204 * to its originating #AtspiHypertext object, #FALSE otherwise.
207 atspi_hyperlink_is_valid (AtspiHyperlink *obj, GError **error)
209 dbus_bool_t retval = FALSE;
211 g_return_val_if_fail (obj != NULL, FALSE);
213 _atspi_dbus_call (obj, atspi_interface_hyperlink, "IsValid", error, "=>b", &retval);