Imported version 2.7.91
[platform/core/uifw/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  * 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 /**
28  * atspi_hypertext_get_n_links:
29  * @obj: a pointer to the #AtspiHypertext implementor on which to operate.
30  *
31  * Gets the total number of #AtspiHyperlink objects that an
32  * #AtspiHypertext implementor has.
33  *
34  * Returns: a #gint indicating the number of #AtspiHyperlink objects
35  *        of the #AtspiHypertext implementor, or -1 if
36  *        the number cannot be determined (for example, if the
37  *        #AtspiHypertext object is so large that it is not
38  *        all currently in the memory cache).
39  **/
40 gint
41 atspi_hypertext_get_n_links (AtspiHypertext *obj, GError **error)
42 {
43   dbus_int32_t retval = 0;
44
45   g_return_val_if_fail (obj != NULL, FALSE);
46
47   _atspi_dbus_call (obj, atspi_interface_hypertext, "GetNLinks", error, "=>i", &retval);
48
49   return retval;
50 }
51
52 /**
53  * atspi_hypertext_get_link:
54  * @obj: a pointer to the #AtspiHypertext implementor on which to operate.
55  * @link_index: a (zero-index) #gint indicating which hyperlink to query.
56  *
57  * Gets the #AtspiHyperlink object at a specified index.
58  *
59  * Returns: (transfer full): the #AtspiHyperlink object specified by
60  *          @link_index.
61  **/
62 AtspiHyperlink *
63 atspi_hypertext_get_link (AtspiHypertext *obj, gint link_index, GError **error)
64 {
65   dbus_int32_t d_link_index = link_index;
66   DBusMessage *reply;
67         
68   g_return_val_if_fail (obj != NULL, NULL);
69
70   reply = _atspi_dbus_call_partial (obj, atspi_interface_hypertext, "GetLink", error, "i", d_link_index);
71
72   return _atspi_dbus_return_hyperlink_from_message (reply);
73 }
74
75 /**
76  * atspi_hypertext_get_link_index:
77  * @obj: a pointer to the #AtspiHypertext implementor on which to operate.
78  * @character_offset: a #gint specifying the character offset to query.
79  *
80  * Gets the index of the #AtspiHyperlink object at a specified
81  *        character offset.
82  *
83  * Returns: the linkIndex of the #AtspiHyperlink active at
84  *        character offset @character_offset, or -1 if there is
85  *        no hyperlink at the specified character offset.
86  **/
87 int
88 atspi_hypertext_get_link_index (AtspiHypertext *obj,
89                                 gint             character_offset,
90                                 GError **error)
91 {
92   dbus_int32_t d_character_offset = character_offset;
93   dbus_int32_t retval = -1;
94
95   g_return_val_if_fail (obj != NULL, -1);
96
97   _atspi_dbus_call (obj, atspi_interface_hypertext, "GetLinkIndex", error, "i=>i", d_character_offset, &retval);
98
99   return retval;
100 }
101
102 static void
103 atspi_hypertext_base_init (AtspiHypertext *klass)
104 {
105 }
106
107 GType
108 atspi_hypertext_get_type (void)
109 {
110   static GType type = 0;
111
112   if (!type) {
113     static const GTypeInfo tinfo =
114     {
115       sizeof (AtspiHypertext),
116       (GBaseInitFunc) atspi_hypertext_base_init,
117       (GBaseFinalizeFunc) NULL,
118     };
119
120     type = g_type_register_static (G_TYPE_INTERFACE, "AtspiHypertext", &tinfo, 0);
121
122   }
123   return type;
124 }