~elementary-os/elementaryos/os-patch-at-spi2-core-xenial

« back to all changes in this revision

Viewing changes to atspi/atspi-hyperlink.c

  • Committer: RabbitBot
  • Date: 2016-11-16 09:38:52 UTC
  • Revision ID: rabbitbot@elementary.io-20161116093852-xn6hcgpg5y25xooo
Initial import, version 2.18.3-4ubuntu1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * Gets 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
 *
 
60
 * see: #atspi_hyperlink_get_uri and #atspi_hyperlink_get_object.
 
61
 *
 
62
 * Returns: a #gint indicating the number of anchors in this hyperlink.
 
63
 **/
 
64
gint
 
65
atspi_hyperlink_get_n_anchors (AtspiHyperlink *obj, GError **error)
 
66
{
 
67
  dbus_int32_t retval = -1;
 
68
 
 
69
  g_return_val_if_fail (obj != NULL, -1);
 
70
 
 
71
  _atspi_dbus_get_property (obj, atspi_interface_hyperlink, "NAnchors", error, "i", &retval);
 
72
 
 
73
  return retval;
 
74
}
 
75
 
 
76
/**
 
77
 * atspi_hyperlink_get_uri:
 
78
 * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
 
79
 * @i: a (zero-index) integer indicating which hyperlink anchor to query.
 
80
 *
 
81
 * Gets the URI associated with a particular hyperlink anchor.
 
82
 *
 
83
 * Returns: a UTF-8 string giving the URI of the @ith hyperlink anchor.
 
84
 **/
 
85
gchar *
 
86
atspi_hyperlink_get_uri (AtspiHyperlink *obj, int i, GError **error)
 
87
{
 
88
  dbus_int32_t d_i = i;
 
89
  char *retval = NULL;
 
90
 
 
91
  g_return_val_if_fail (obj != NULL, NULL);
 
92
 
 
93
  _atspi_dbus_call (obj, atspi_interface_hyperlink, "GetURI", error, "i=>s", d_i, &retval);
 
94
 
 
95
  if (!retval)
 
96
    retval = g_strdup ("");
 
97
 
 
98
  return retval;
 
99
}
 
100
 
 
101
/**
 
102
 * atspi_hyperlink_get_object:
 
103
 * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
 
104
 * @i: a (zero-index) #gint indicating which hyperlink anchor to query.
 
105
 *
 
106
 * Gets the object associated with a particular hyperlink anchor, as an
 
107
 * #AtspiAccessible.
 
108
 *
 
109
 * Returns: (transfer full): an #AtspiAccessible that represents the object
 
110
 *        associated with the @ith anchor of the specified #AtspiHyperlink.
 
111
 **/
 
112
AtspiAccessible*
 
113
atspi_hyperlink_get_object (AtspiHyperlink *obj, gint i, GError **error)
 
114
{
 
115
  dbus_int32_t d_i = i;
 
116
  DBusMessage *reply;
 
117
 
 
118
  g_return_val_if_fail (obj != NULL, NULL);
 
119
 
 
120
  reply = _atspi_dbus_call_partial (obj, atspi_interface_hyperlink, "GetObject", error, "i", d_i);
 
121
 
 
122
  return _atspi_dbus_return_accessible_from_message (reply);
 
123
}
 
124
 
 
125
/**
 
126
 * atspi_hyperlink_get_index_range:
 
127
 * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
 
128
 *
 
129
 *
 
130
 * Gets the starting and ending character offsets of the text range
 
131
 * associated with an #AtspiHyperlink, in its originating #AtspiHypertext.
 
132
 **/
 
133
AtspiRange *
 
134
atspi_hyperlink_get_index_range (AtspiHyperlink *obj, GError **error)
 
135
{
 
136
  dbus_int32_t d_start_offset = -1;
 
137
  dbus_int32_t d_end_offset = -1;
 
138
  AtspiRange *ret = g_new (AtspiRange, 1);
 
139
 
 
140
  ret->start_offset = ret->end_offset = -1;
 
141
 
 
142
  if (!obj)
 
143
    return ret;
 
144
 
 
145
  _atspi_dbus_call (obj, atspi_interface_hyperlink, "GetIndexRange", error, "=>ii", &d_start_offset, &d_end_offset);
 
146
 
 
147
  ret->start_offset = d_start_offset;
 
148
  ret->end_offset = d_end_offset;
 
149
  return ret;
 
150
}
 
151
 
 
152
/**
 
153
 * atspi_hyperlink_get_start_index:
 
154
 * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
 
155
 *
 
156
 *
 
157
 * Gets the starting character offset of the text range associated with
 
158
 *       an #AtspiHyperlink, in its originating #AtspiHypertext.
 
159
 **/
 
160
gint
 
161
atspi_hyperlink_get_start_index (AtspiHyperlink *obj, GError **error)
 
162
{
 
163
  dbus_int32_t d_start_offset = -1;
 
164
 
 
165
  if (!obj)
 
166
    return -1;
 
167
 
 
168
  _atspi_dbus_get_property (obj, atspi_interface_hyperlink, "StartIndex",
 
169
                            error, "i", &d_start_offset);
 
170
 
 
171
  return d_start_offset;
 
172
}
 
173
/**
 
174
 * atspi_hyperlink_get_end_index:
 
175
 * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
 
176
 *
 
177
 *
 
178
 * Gets the ending character offset of the text range associated with
 
179
 *       an #AtspiHyperlink, in its originating #AtspiHypertext.
 
180
 **/
 
181
gint
 
182
atspi_hyperlink_get_end_index (AtspiHyperlink *obj, GError **error)
 
183
{
 
184
  dbus_int32_t d_end_offset = -1;
 
185
 
 
186
  if (!obj)
 
187
    return -1;
 
188
 
 
189
  _atspi_dbus_get_property (obj, atspi_interface_hyperlink, "EndIndex", error,
 
190
                            "i", &d_end_offset);
 
191
 
 
192
  return d_end_offset;
 
193
}
 
194
 
 
195
 
 
196
/**
 
197
 * atspi_hyperlink_is_valid:
 
198
 * @obj: a pointer to the #AtspiHyperlink on which to operate.
 
199
 *
 
200
 * Tells whether an #AtspiHyperlink object is still valid with respect to its
 
201
 *          originating hypertext object.
 
202
 *
 
203
 * Returns: #TRUE if the specified #AtspiHyperlink is still valid with respect
 
204
 *          to its originating #AtspiHypertext object, #FALSE otherwise.
 
205
 **/
 
206
gboolean
 
207
atspi_hyperlink_is_valid (AtspiHyperlink *obj, GError **error)
 
208
{
 
209
  dbus_bool_t retval = FALSE;
 
210
 
 
211
  g_return_val_if_fail (obj != NULL, FALSE);
 
212
 
 
213
  _atspi_dbus_call (obj, atspi_interface_hyperlink, "IsValid", error, "=>b", &retval);
 
214
 
 
215
  return retval;
 
216
}