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 Lesser General Public
11
 * License as published by the Free Software Foundation; either
12
 * version 2.1 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
 * Lesser General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public
20
 * License along with this library; if not, write to the
21
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22
 * Boston, MA 02110-1301, USA.
23
 */
24

            
25
#include "atspi-private.h"
26

            
27
/**
28
 * AtspiHypertext:
29
 *
30
 * An interface used for objects which implement linking between
31
 * multiple resource locations.
32
 *
33
 * An interface used for objects which implement linking between
34
 * multiple resource or content locations, or multiple 'markers'
35
 * within a single document. A hypertext instance is associated
36
 * with one or more hyperlinks which are associated with particular
37
 * offsets within the hypertext's content.
38
 */
39

            
40
/**
41
 * atspi_hypertext_get_n_links:
42
 * @obj: a pointer to the #AtspiHypertext implementor on which to operate.
43
 *
44
 * Gets the total number of #AtspiHyperlink objects that an
45
 * #AtspiHypertext implementor has.
46
 *
47
 * Returns: a #gint indicating the number of #AtspiHyperlink objects
48
 *        of the #AtspiHypertext implementor, or -1 if
49
 *        the number cannot be determined (for example, if the
50
 *        #AtspiHypertext object is so large that it is not
51
 *        all currently in the memory cache).
52
 **/
53
gint
54
1
atspi_hypertext_get_n_links (AtspiHypertext *obj, GError **error)
55
{
56
1
  dbus_int32_t retval = 0;
57

            
58
1
  g_return_val_if_fail (obj != NULL, FALSE);
59

            
60
1
  _atspi_dbus_call (obj, atspi_interface_hypertext, "GetNLinks", error, "=>i", &retval);
61

            
62
1
  return retval;
63
}
64

            
65
/**
66
 * atspi_hypertext_get_link:
67
 * @obj: a pointer to the #AtspiHypertext implementor on which to operate.
68
 * @link_index: a (zero-index) #gint indicating which hyperlink to query.
69
 *
70
 * Gets the #AtspiHyperlink object at a specified index.
71
 *
72
 * Returns: (nullable) (transfer full): the #AtspiHyperlink object
73
 *          specified by @link_index.
74
 **/
75
AtspiHyperlink *
76
9
atspi_hypertext_get_link (AtspiHypertext *obj, gint link_index, GError **error)
77
{
78
9
  dbus_int32_t d_link_index = link_index;
79
  DBusMessage *reply;
80

            
81
9
  g_return_val_if_fail (obj != NULL, NULL);
82

            
83
9
  reply = _atspi_dbus_call_partial (obj, atspi_interface_hypertext, "GetLink", error, "i", d_link_index);
84

            
85
9
  return _atspi_dbus_return_hyperlink_from_message (reply);
86
}
87

            
88
/**
89
 * atspi_hypertext_get_link_index:
90
 * @obj: a pointer to the #AtspiHypertext implementor on which to operate.
91
 * @character_offset: a #gint specifying the character offset to query.
92
 *
93
 * Gets the index of the #AtspiHyperlink object at a specified
94
 *        character offset.
95
 *
96
 * Returns: the linkIndex of the #AtspiHyperlink active at
97
 *        character offset @character_offset, or -1 if there is
98
 *        no hyperlink at the specified character offset.
99
 **/
100
int
101
3
atspi_hypertext_get_link_index (AtspiHypertext *obj,
102
                                gint character_offset,
103
                                GError **error)
104
{
105
3
  dbus_int32_t d_character_offset = character_offset;
106
3
  dbus_int32_t retval = -1;
107

            
108
3
  g_return_val_if_fail (obj != NULL, -1);
109

            
110
3
  _atspi_dbus_call (obj, atspi_interface_hypertext, "GetLinkIndex", error, "i=>i", d_character_offset, &retval);
111

            
112
3
  return retval;
113
}
114

            
115
static void
116
4
atspi_hypertext_base_init (AtspiHypertext *klass)
117
{
118
4
}
119

            
120
GType
121
12
atspi_hypertext_get_type (void)
122
{
123
  static GType type = 0;
124

            
125
12
  if (!type)
126
    {
127
      static const GTypeInfo tinfo = {
128
        sizeof (AtspiHypertext),
129
        (GBaseInitFunc) atspi_hypertext_base_init,
130
        (GBaseFinalizeFunc) NULL,
131
      };
132

            
133
2
      type = g_type_register_static (G_TYPE_INTERFACE, "AtspiHypertext", &tinfo, 0);
134
    }
135
12
  return type;
136
}