Fix atspi_accessible_get_description
[platform/upstream/at-spi2-core.git] / atspi / atspi-hypertext.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  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 #include "atspi-private.h"
25
26 /**
27  * atspi_hypertext_get_n_links:
28  * @obj: a pointer to the #AtspiHypertext implementor on which to operate.
29  *
30  * Get the total number of #AtspiHyperlinks which an
31  *        #AtspiHypertext implementor has.
32  *
33  * Returns: a #gint indicating the number of #AtspiHyperlinks
34  *        of the #AtspiHypertext implementor, or -1 if
35  *        the number cannot be determined (for example, if the
36  *        #AtspiHypertext object is so large that it is not
37  *        all currently in the memory cache).
38  **/
39 gint
40 atspi_hypertext_get_n_links (AtspiHypertext *obj, GError **error)
41 {
42   dbus_int32_t retval = 0;
43
44   g_return_val_if_fail (obj != NULL, FALSE);
45
46   _atspi_dbus_call (obj, atspi_interface_hypertext, "GetNLinks", error, "=>i", &retval);
47
48   return retval;
49 }
50
51 /**
52  * atspi_hypertext_get_link:
53  * @obj: a pointer to the #AtspiHypertext implementor on which to operate.
54  * @link_index: a (zero-index) integer indicating which hyperlink to query.
55  *
56  * Get the #AtspiHyperlink object at a specified index.
57  *
58  * Returns: (transfer full): the #AtspiHyperlink object specified by
59  *          #link_index.
60  **/
61 AtspiHyperlink *
62 atspi_hypertext_get_link (AtspiHypertext *obj, gint link_index, GError **error)
63 {
64   dbus_int32_t d_link_index = link_index;
65   DBusMessage *reply;
66         
67   g_return_val_if_fail (obj != NULL, NULL);
68
69   reply = _atspi_dbus_call_partial (obj, atspi_interface_hypertext, "GetLink", error, "i", d_link_index);
70
71   return _atspi_dbus_return_hyperlink_from_message (reply);
72 }
73
74 /**
75  * atspi_hypertext_get_link_index:
76  * @obj: a pointer to the #AtspiHypertext implementor on which to operate.
77  * @character_offset: an integer specifying the character offset to query.
78  *
79  * Get the index of the #AtspiHyperlink object at a specified
80  *        character offset.
81  *
82  * Returns: the linkIndex of the #AtspiHyperlink active at
83  *        character offset @character_offset, or -1 if there is
84  *        no hyperlink at the specified character offset.
85  **/
86 int
87 atspi_hypertext_get_link_index (AtspiHypertext *obj,
88                                 gint             character_offset,
89                                 GError **error)
90 {
91   dbus_int32_t d_character_offset = character_offset;
92   dbus_int32_t retval = -1;
93
94   g_return_val_if_fail (obj != NULL, -1);
95
96   _atspi_dbus_call (obj, atspi_interface_hypertext, "GetLinkIndex", error, "i=>i", d_character_offset, &retval);
97
98   return retval;
99 }
100
101 static void
102 atspi_hypertext_base_init (AtspiHypertext *klass)
103 {
104 }
105
106 GType
107 atspi_hypertext_get_type (void)
108 {
109   static GType type = 0;
110
111   if (!type) {
112     static const GTypeInfo tinfo =
113     {
114       sizeof (AtspiHypertext),
115       (GBaseInitFunc) atspi_hypertext_base_init,
116       (GBaseFinalizeFunc) NULL,
117     };
118
119     type = g_type_register_static (G_TYPE_INTERFACE, "AtspiHypertext", &tinfo, 0);
120
121   }
122   return type;
123 }