Clean up names of private functions
[platform/upstream/at-spi2-core.git] / atspi / atspi-hyperlink.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001, 2002 Sun Microsystems Inc.,
6  * Copyright 2001, 2002 Ximian, Inc.
7  * Copyright 2010, 2011 Novell, Inc.
8  *
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.
13  *
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.
18  *
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.
23  */
24
25 #include "atspi-private.h"
26
27 G_DEFINE_TYPE (AtspiHyperlink, atspi_hyperlink, ATSPI_TYPE_OBJECT)
28
29 static void
30 atspi_hyperlink_init (AtspiHyperlink *hyperlink)
31 {
32 }
33
34 static void
35 atspi_hyperlink_class_init (AtspiHyperlinkClass *klass)
36 {
37 }
38
39 AtspiHyperlink *
40 _atspi_hyperlink_new (AtspiApplication *app, const gchar *path)
41 {
42   AtspiHyperlink *hyperlink;
43   
44   hyperlink = g_object_new (ATSPI_TYPE_HYPERLINK, NULL);
45   hyperlink->parent.app = g_object_ref (app);
46   hyperlink->parent.path = g_strdup (path);
47
48   return hyperlink;
49 }
50
51 /**
52  * atspi_hyperlink_get_n_anchors:
53  * @obj: a pointer to the #AtspiHyperlink object on which to operate.
54  *
55  * Get the total number of anchors which an #AtspiHyperlink implementor has.
56  *       Though typical hyperlinks have only one anchor, client-side image maps and
57  *       other hypertext objects may potentially activate or refer to multiple
58  *       URIs.  For each anchor there is a corresponding URI and object.
59  * see atspi_hyperlink_get_uri() and atspi_hyperlink_get_object().
60  *
61  * Returns: a #gint indicating the number of anchors in this hyperlink.
62  **/
63 gint
64 atspi_hyperlink_get_n_anchors (AtspiHyperlink *obj, GError **error)
65 {
66   dbus_int32_t retval = -1;
67
68   g_return_val_if_fail (obj != NULL, -1);
69
70   _atspi_dbus_get_property (obj, atspi_interface_hyperlink, "NAnchors", error, "i", &retval);
71
72   return retval;
73 }
74
75 /**
76  * atspi_hyperlink_get_uri:
77  * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
78  * @i: a (zero-index) integer indicating which hyperlink anchor to query.
79  *
80  * Get the URI associated with a particular hyperlink anchor.  
81  *
82  * Returns: a UTF-8 string giving the URI of the @ith hyperlink anchor.
83  **/
84 gchar *
85 atspi_hyperlink_get_uri (AtspiHyperlink *obj, int i, GError **error)
86 {
87   dbus_int32_t d_i = i;
88   char *retval = NULL;
89
90   g_return_val_if_fail (obj != NULL, NULL);
91
92   _atspi_dbus_call (obj, atspi_interface_hyperlink, "GetURI", error, "i=>s", d_i, &retval);
93
94   if (!retval)
95     retval = g_strdup ("");
96
97   return retval;
98 }
99
100 /**
101  * atspi_hyperlink_get_object:
102  * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
103  * @i: a (zero-index) long integer indicating which hyperlink anchor to query.
104  *
105  * Get the object associated with a particular hyperlink anchor, as an #Accessible. 
106  *
107  * Returns: (transfer full): an #AtspiAccessible that represents the object
108  *        associated with the @ith anchor of the specified #AtspiHyperlink.
109  **/
110 AtspiAccessible*
111 atspi_hyperlink_get_object (AtspiHyperlink *obj, gint i, GError **error)
112 {
113   dbus_int32_t d_i = i;
114   DBusMessage *reply;
115
116   g_return_val_if_fail (obj != NULL, NULL);
117
118   reply = _atspi_dbus_call_partial (obj, atspi_interface_hyperlink, "GetObject", error, "i", d_i);
119
120   return _atspi_dbus_return_accessible_from_message (reply);
121 }
122
123 /**
124  * atspi_hyperlink_get_index_range:
125  * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
126  *
127  *
128  * Get the starting and ending character offsets of the text range associated with
129  *       a #AtspiHyperlink, in its originating #AtspiHypertext.
130  **/
131 AtspiRange *
132 atspi_hyperlink_get_index_range (AtspiHyperlink *obj, GError **error)
133 {
134   dbus_int32_t d_start_offset, d_end_offset;
135   AtspiRange *ret = g_new (AtspiRange, 1);
136
137   ret->start_offset = ret->end_offset = -1;
138
139   if (!obj)
140     return ret;
141
142   _atspi_dbus_call (obj, atspi_interface_hyperlink, "GetIndexRange", error, "=>ii", &d_start_offset, &d_end_offset);
143
144   ret->start_offset = d_start_offset;
145   ret->end_offset = d_end_offset;
146   return ret;
147 }
148
149 /**
150  * atspi_hyperlink_get_start_index:
151  * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
152  *
153  *
154  * Get the starting character offset of the text range associated with
155  *       a #AtspiHyperlink, in its originating #AtspiHypertext.
156  **/
157 gint
158 atspi_hyperlink_get_start_index (AtspiHyperlink *obj, GError **error)
159 {
160   dbus_int32_t d_start_offset = -1;
161
162   if (!obj)
163     return -1;
164
165   _atspi_dbus_get_property (obj, atspi_interface_hyperlink, "StartIndex",
166                             error, "i", &d_start_offset);
167
168   return d_start_offset;
169 }
170 /**
171  * atspi_hyperlink_get_end_index:
172  * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
173  *
174  *
175  * Get the ending character offset of the text range associated with
176  *       a #AtspiHyperlink, in its originating #AtspiHypertext.
177  **/
178 gint
179 atspi_hyperlink_get_end_index (AtspiHyperlink *obj, GError **error)
180 {
181   dbus_int32_t d_end_offset = -1;
182
183   if (!obj)
184     return -1;
185
186   _atspi_dbus_get_property (obj, atspi_interface_hyperlink, "EndIndex", error,
187                             "i", &d_end_offset);
188
189   return d_end_offset;
190 }
191
192
193 /**
194  * atspi_hyperlink_is_valid:
195  * @obj: a pointer to the #AtspiHyperlink on which to operate.
196  *
197  * Tell whether an #AtspiHyperlink object is still valid with respect to its
198  *          originating hypertext object.
199  *
200  * Returns: #TRUE of the specified #AtspiHyperlink is still valid with respect
201  *          to its originating #AtspiHypertext object, #FALSE otherwise.
202  **/
203 gboolean
204 atspi_hyperlink_is_valid (AtspiHyperlink *obj, GError **error)
205 {
206   dbus_bool_t retval = FALSE;
207
208   g_return_val_if_fail (obj != NULL, FALSE);
209
210   _atspi_dbus_call (obj, atspi_interface_hyperlink, "IsValid", error, "=>b", &retval);
211
212   return retval;
213 }