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

« back to all changes in this revision

Viewing changes to atspi/atspi-table-cell.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 2013 SUSE LLC.
 
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 <stdlib.h> /* for malloc */
 
26
#include "atspi-private.h"
 
27
 
 
28
static GPtrArray *
 
29
get_object_array_and_unref (DBusMessage *reply)
 
30
{
 
31
  DBusMessageIter iter, iter_array;
 
32
  GPtrArray *array;
 
33
 
 
34
  if (!reply)
 
35
    return NULL;
 
36
 
 
37
  if (strcmp (dbus_message_get_signature (reply), "(so)") != 0)
 
38
  {
 
39
    dbus_message_unref (reply);
 
40
    return NULL;
 
41
  }
 
42
 
 
43
  array = g_ptr_array_new ();
 
44
 
 
45
  dbus_message_iter_init (reply, &iter);
 
46
  dbus_message_iter_recurse (&iter, &iter_array);
 
47
  while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
 
48
  {
 
49
    AtspiAccessible *accessible = _atspi_dbus_return_accessible_from_iter (&iter_array);
 
50
    g_ptr_array_add (array, accessible);
 
51
  }
 
52
  dbus_message_unref (reply);
 
53
  return array;
 
54
}
 
55
 
 
56
/**
 
57
 * atspi_table_cell_get_column_span:
 
58
 * @obj: a GObject instance that implements AtspiTableCellIface
 
59
 *
 
60
 * Returns the number of columns occupied by this cell accessible.
 
61
 *
 
62
 * Returns: a gint representing the number of columns occupied by this cell,
 
63
 * or 0 if the cell does not implement this method.
 
64
 */
 
65
gint
 
66
atspi_table_cell_get_column_span (AtspiTableCell *obj, GError **error)
 
67
{
 
68
  dbus_int32_t retval = -1;
 
69
 
 
70
  g_return_val_if_fail (obj != NULL, -1);
 
71
 
 
72
  _atspi_dbus_get_property (obj, atspi_interface_table_cell, "ColumnSpan",
 
73
                            error, "i", &retval);
 
74
          
 
75
  return retval;
 
76
}
 
77
 
 
78
/**
 
79
 * atspi_table_cell_get_column_header_cells:
 
80
 * @obj: a GObject instance that implements AtspiTableCellIface
 
81
 *
 
82
 * Returns the column headers as an array of cell accessibles.
 
83
 *
 
84
 * Returns: (element-type AtspiAccessible) (transfer full): a GPtrArray of
 
85
 * AtspiAccessibles representing the column header cells.
 
86
  */
 
87
GPtrArray *
 
88
atspi_table_cell_get_column_header_cells (AtspiTableCell *obj, GError **error)
 
89
{
 
90
  DBusMessage *reply;
 
91
 
 
92
  g_return_val_if_fail (obj != NULL, NULL);
 
93
 
 
94
  reply = _atspi_dbus_call_partial (obj, atspi_interface_table_cell, "GetColumnHeaderCells", error, "");
 
95
          
 
96
  return get_object_array_and_unref (reply);
 
97
}
 
98
 
 
99
/**
 
100
 * atspi_table_cell_get_column_index:
 
101
 * @obj: a GObject instance that implements AtspiTableCellIface
 
102
 *
 
103
 * Translates this cell accessible into the corresponding column index.
 
104
 *
 
105
 * Returns: the column index for this cell, or -1 if unimplemented.
 
106
 */
 
107
gint
 
108
atspi_table_cell_get_column_index (AtspiTableCell *obj, GError **error)
 
109
{
 
110
  dbus_int32_t retval = -1;
 
111
 
 
112
  g_return_val_if_fail (obj != NULL, -1);
 
113
 
 
114
  _atspi_dbus_get_property (obj, atspi_interface_table_cell, "ColumnIndex",
 
115
                            error, "i", &retval);
 
116
          
 
117
  return retval;
 
118
}
 
119
 
 
120
/**
 
121
 * atspi_table_cell_get_row_span:
 
122
 * @obj: a GObject instance that implements AtspiTableCellIface
 
123
 *
 
124
 * Returns the number of rows occupied by this cell accessible.
 
125
 *
 
126
 * Returns: a gint representing the number of rows occupied by this cell,
 
127
 * or 0 if the cell does not implement this method.
 
128
 */
 
129
gint
 
130
atspi_table_cell_get_row_span (AtspiTableCell *obj, GError **error)
 
131
{
 
132
  dbus_int32_t retval = -1;
 
133
 
 
134
  g_return_val_if_fail (obj != NULL, -1);
 
135
 
 
136
  _atspi_dbus_get_property (obj, atspi_interface_table_cell, "RowSpan",
 
137
                            error, "i", &retval);
 
138
          
 
139
  return retval;
 
140
}
 
141
 
 
142
/**
 
143
 * atspi_table_cell_get_row_header_cells:
 
144
 * @obj: a GObject instance that implements AtspiTableCellIface
 
145
 *
 
146
 * Returns the row headers as an array of cell accessibles.
 
147
 *
 
148
 * Returns: (element-type AtspiAccessible) (transfer full): a GPtrArray of
 
149
 * AtspiAccessibles representing the row header cells.
 
150
 */
 
151
GPtrArray *
 
152
atspi_table_cell_get_row_header_cells (AtspiTableCell *obj, GError **error)
 
153
{
 
154
  DBusMessage *reply;
 
155
 
 
156
  g_return_val_if_fail (obj != NULL, NULL);
 
157
 
 
158
  reply = _atspi_dbus_call_partial (obj, atspi_interface_table_cell, "GetRowHeaderCells", error, "");
 
159
          
 
160
  return get_object_array_and_unref (reply);
 
161
}
 
162
 
 
163
/**
 
164
 * atspi_table_cell_get_position:
 
165
 * @obj: a GObject instance that implements AtspiTableCellIface
 
166
 * @row: (out): the row of the given cell.
 
167
 * @column: (out): the column of the given cell.
 
168
 *
 
169
 * Retrieves the tabular position of this cell.
 
170
 *
 
171
 * Returns: TRUE if successful, FALSE otherwise.
 
172
 */
 
173
gint
 
174
atspi_table_cell_get_position (AtspiTableCell *obj,
 
175
                               gint *row,
 
176
                               gint *column,
 
177
                               GError *error)
 
178
{
 
179
  DBusMessage *reply;
 
180
  DBusMessageIter iter, iter_struct, iter_variant;
 
181
  dbus_int32_t d_row = -1, d_column = -1;
 
182
  char *iter_sig;
 
183
 
 
184
  g_return_val_if_fail (obj != NULL, -1);
 
185
 
 
186
  reply = _atspi_dbus_call_partial (obj, "org.freedesktop.DBus.Properties",
 
187
                                    "Get", NULL, "ss",
 
188
                                    atspi_interface_table_cell, "Position");
 
189
          
 
190
  dbus_message_iter_init (reply, &iter);
 
191
 
 
192
  /* TODO: Return error here */
 
193
  if (dbus_message_iter_get_arg_type (&iter) != 'v')
 
194
    return FALSE;
 
195
 
 
196
  dbus_message_iter_recurse (&iter, &iter_variant);
 
197
  iter_sig = dbus_message_iter_get_signature (&iter_variant);
 
198
  /* TODO: Also report error here */
 
199
  if (strcmp (iter_sig, "(ii)") != 0)
 
200
  {
 
201
    dbus_free (iter_sig);
 
202
    return FALSE;
 
203
  }
 
204
  dbus_free (iter_sig);
 
205
 
 
206
  dbus_message_iter_recurse (&iter_variant, &iter_struct);
 
207
  dbus_message_iter_get_basic (&iter_struct, &d_row);
 
208
  if (row)
 
209
    *row = d_row;
 
210
  dbus_message_iter_next (&iter_struct);
 
211
  dbus_message_iter_get_basic (&iter_struct, &d_column);
 
212
  if (column)
 
213
    *column = d_column;
 
214
  dbus_message_unref (reply);
 
215
  return TRUE;
 
216
}
 
217
 
 
218
/**
 
219
 * atspi_table_cell_get_row_column_span:
 
220
 * @obj: a GObject instance that implements AtspiTableCellIface
 
221
 * @row: (out): the row index of the given cell.
 
222
 * @column: (out): the column index of the given cell.
 
223
 * @row_span: (out): the number of rows occupied by this cell.
 
224
 * @column_span: (out): the number of columns occupied by this cell.
 
225
 *
 
226
 * Gets the row and column indexes and extents of this cell accessible.
 
227
 */
 
228
void
 
229
atspi_table_cell_get_row_column_span (AtspiTableCell *obj,
 
230
                                       gint *row,
 
231
                                       gint *column,
 
232
                                       gint *row_span,
 
233
                                       gint *column_span,
 
234
                                       GError **error)
 
235
{
 
236
  dbus_int32_t d_row = 0,  d_column = 0, d_row_span = 0, d_column_span = 0;
 
237
 
 
238
  if (row)
 
239
    *row = -1;
 
240
  if (column)
 
241
    *column = -1;
 
242
  if (row_span)
 
243
    *row_span = -1;
 
244
  if (column_span)
 
245
    *column_span = -1;
 
246
 
 
247
  g_return_if_fail (obj != NULL);
 
248
 
 
249
  _atspi_dbus_call (obj, atspi_interface_table_cell, "GetRowColumnSpan",
 
250
                    error, "=>iiii", &d_row, &d_column,
 
251
                    &d_row_span, &d_column_span);
 
252
 
 
253
  if (row)
 
254
    *row = d_row;
 
255
  if (column)
 
256
    *column = d_column;
 
257
  if (row_span)
 
258
    *row_span = d_row_span;
 
259
  if (column_span)
 
260
    *column_span = d_column_span;
 
261
}
 
262
 
 
263
/**
 
264
 * atspi_table_cell_get_table:
 
265
 * @obj: a GObject instance that implements AtspiTableCellIface
 
266
 *
 
267
 * Returns a reference to the accessible of the containing table.
 
268
 *
 
269
 * Returns: (transfer full): the AtspiAccessible for the containing table.
 
270
 */
 
271
AtspiAccessible *
 
272
atspi_table_cell_get_table (AtspiTableCell *obj, GError **error)
 
273
{
 
274
  AtspiAccessible *retval = NULL;
 
275
 
 
276
  g_return_val_if_fail (obj != NULL, NULL);
 
277
 
 
278
  _atspi_dbus_get_property (obj, atspi_interface_table_cell, "Table",
 
279
                            error, "(so)", &retval);
 
280
          
 
281
  return retval;
 
282
}
 
283
 
 
284
static void
 
285
atspi_table_cell_base_init (AtspiTableCell *klass)
 
286
{
 
287
}
 
288
 
 
289
GType
 
290
atspi_table_cell_get_type (void)
 
291
{
 
292
  static GType type = 0;
 
293
 
 
294
  if (!type) {
 
295
    static const GTypeInfo tinfo =
 
296
    {
 
297
      sizeof (AtspiTableCell),
 
298
      (GBaseInitFunc) atspi_table_cell_base_init,
 
299
      (GBaseFinalizeFunc) NULL,
 
300
    };
 
301
 
 
302
    type = g_type_register_static (G_TYPE_INTERFACE, "AtspiTableCell", &tinfo, 0);
 
303
 
 
304
  }
 
305
  return type;
 
306
}