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
#include <stdlib.h> /* for malloc */
27

            
28
/**
29
 * AtspiTable:
30
 *
31
 * An interface used by containers whose data is arranged in a tabular form.
32
 *
33
 * An interface used by containers whose contained data is arranged
34
 * in a tabular (i.e. row-column) form. Tables may resemble
35
 * a two-dimensional grid, as in a spreadsheet, or may feature objects
36
 * which span multiple rows and/or columns, but whose bounds are
37
 * aligned on a row/column matrix. Objects within tables are children
38
 * of the table object, and they may be referenced either via a child
39
 * index or via a row/column pair. Table 'cells' may implement other
40
 * interfaces, such as Text, Action, Image, and Component, and should do
41
 * so as appropriate to their onscreen presentation and/or behavior.
42
 */
43

            
44
/**
45
 * atspi_table_get_caption:
46
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
47
 *
48
 * Gets an accessible representation of the caption for an #AtspiTable.
49
 *
50
 * Returns: (transfer full): an #AtspiAccessible object that serves as
51
 * the table's caption.
52
 *
53
 **/
54
AtspiAccessible *
55
1
atspi_table_get_caption (AtspiTable *obj, GError **error)
56
{
57
1
  AtspiAccessible *retval = NULL;
58

            
59
1
  g_return_val_if_fail (obj != NULL, NULL);
60

            
61
1
  _atspi_dbus_get_property (obj, atspi_interface_table, "Caption", error, "(so)", &retval);
62
1
  return retval;
63
}
64

            
65
/**
66
 * atspi_table_get_summary:
67
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
68
 *
69
 * Gets an accessible object which summarizes the contents of an #AtspiTable.
70
 *
71
 * Returns: (transfer full): an #AtspiAccessible object that serves as the
72
 *          table's summary (often a reduced #AtspiTable).
73
 **/
74
AtspiAccessible *
75
1
atspi_table_get_summary (AtspiTable *obj, GError **error)
76
{
77
  AtspiAccessible *retval;
78

            
79
1
  g_return_val_if_fail (obj != NULL, NULL);
80

            
81
1
  _atspi_dbus_get_property (obj, atspi_interface_table, "Summary", error, "(so)", &retval);
82

            
83
1
  return retval;
84
}
85

            
86
/**
87
 * atspi_table_get_n_rows:
88
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
89
 *
90
 * Gets the number of rows in an #AtspiTable,
91
 *        exclusive of any rows that are programmatically hidden, but inclusive
92
 *        of rows that may be outside of the current scrolling window or viewport.
93
 *
94
 * Returns: a #gint indicating the number of rows in the table.
95
 **/
96
gint
97
1
atspi_table_get_n_rows (AtspiTable *obj, GError **error)
98
{
99
1
  dbus_int32_t retval = -1;
100

            
101
1
  g_return_val_if_fail (obj != NULL, -1);
102

            
103
1
  _atspi_dbus_get_property (obj, atspi_interface_table, "NRows", error, "i", &retval);
104

            
105
1
  return retval;
106
}
107

            
108
/**
109
 * atspi_table_get_n_columns:
110
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
111
 *
112
 * Gets the number of columns in an #AtspiTable,
113
 *        exclusive of any columns that are programmatically hidden, but inclusive
114
 *        of columns that may be outside of the current scrolling window or viewport.
115
 *
116
 * Returns: a #gint indicating the number of columns in the table.
117
 **/
118
gint
119
1
atspi_table_get_n_columns (AtspiTable *obj, GError **error)
120
{
121
1
  dbus_int32_t retval = -1;
122

            
123
1
  g_return_val_if_fail (obj != NULL, -1);
124

            
125
1
  _atspi_dbus_get_property (obj, atspi_interface_table, "NColumns", error, "i", &retval);
126

            
127
1
  return retval;
128
}
129

            
130
/**
131
 * atspi_table_get_accessible_at:
132
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
133
 * @row: the specified table row, zero-indexed.
134
 * @column: the specified table column, zero-indexed.
135
 *
136
 * Gets the table cell at the specified row and column indices.
137
 * To get the accessible object at a particular (x, y) screen
138
 * coordinate, use #atspi_component_get_accessible_at_point.
139
 *
140
 * Returns: (transfer full): an #AtspiAccessible object representing the
141
 *          specified table cell.
142
 **/
143
AtspiAccessible *
144
2
atspi_table_get_accessible_at (AtspiTable *obj,
145
                               gint row,
146
                               gint column,
147
                               GError **error)
148
{
149
2
  dbus_int32_t d_row = row, d_column = column;
150
  DBusMessage *reply;
151

            
152
2
  g_return_val_if_fail (obj != NULL, NULL);
153

            
154
2
  reply = _atspi_dbus_call_partial (obj, atspi_interface_table, "GetAccessibleAt", error, "ii", d_row, d_column);
155

            
156
2
  return _atspi_dbus_return_accessible_from_message (reply);
157
}
158

            
159
/**
160
 * atspi_table_get_index_at:
161
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
162
 * @row: the specified table row, zero-indexed.
163
 * @column: the specified table column, zero-indexed.
164
 *
165
 * Gets the 1-D child index corresponding to the specified 2-D row and
166
 * column indices. To get the accessible object at a particular (x, y) screen
167
 * coordinate, use #atspi_component_get_accessible_at_point.
168
 *
169
 * @see #atspi_table_get_row_at_index, #atspi_table_get_column_at_index
170
 *
171
 * Returns: a #gint which serves as the index of a specified cell in the
172
 *          table, in a form usable by #atspi_get_child_at_index.
173
 **/
174
gint
175
3
atspi_table_get_index_at (AtspiTable *obj,
176
                          gint row,
177
                          gint column,
178
                          GError **error)
179
{
180
3
  dbus_int32_t d_row = row, d_column = column;
181
3
  dbus_int32_t retval = -1;
182

            
183
3
  g_return_val_if_fail (obj != NULL, -1);
184

            
185
3
  _atspi_dbus_call (obj, atspi_interface_table, "GetIndexAt", error, "ii=>i", d_row, d_column, &retval);
186

            
187
3
  return retval;
188
}
189

            
190
/**
191
 * atspi_table_get_row_at_index:
192
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
193
 * @index: the specified child index, zero-indexed.
194
 *
195
 * Gets the table row index occupied by the child at a particular 1-D
196
 * child index.
197
 *
198
 * @see #atspi_table_get_index_at, #atspi_table_get_column_at_index
199
 *
200
 * Returns: a #gint indicating the first row spanned by the child of a
201
 *          table, at the specified 1-D (zero-offset) @index.
202
 **/
203
gint
204
4
atspi_table_get_row_at_index (AtspiTable *obj,
205
                              gint index,
206
                              GError **error)
207
{
208
4
  dbus_int32_t d_index = index;
209
4
  dbus_int32_t retval = -1;
210

            
211
4
  g_return_val_if_fail (obj != NULL, -1);
212

            
213
4
  _atspi_dbus_call (obj, atspi_interface_table, "GetRowAtIndex", error, "i=>i", d_index, &retval);
214

            
215
4
  return retval;
216
}
217

            
218
/**
219
 * atspi_table_get_column_at_index:
220
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
221
 * @index: the specified child index, zero-indexed.
222
 *
223
 * Gets the table column index occupied by the child at a particular 1-D
224
 * child index.
225
 *
226
 * @see #atspi_table_get_index_at, #atspi_table_get_row_at_index
227
 *
228
 * Returns: a #gint indicating the first column spanned by the child of a
229
 *          table, at the specified 1-D (zero-offset) @index.
230
 **/
231
gint
232
3
atspi_table_get_column_at_index (AtspiTable *obj,
233
                                 gint index,
234
                                 GError **error)
235
{
236
3
  dbus_int32_t d_index = index;
237
3
  dbus_int32_t retval = -1;
238

            
239
3
  g_return_val_if_fail (obj != NULL, -1);
240

            
241
3
  _atspi_dbus_call (obj, atspi_interface_table, "GetColumnAtIndex", error, "i=>i", d_index, &retval);
242

            
243
3
  return retval;
244
}
245

            
246
/**
247
 * atspi_table_get_row_description:
248
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
249
 * @row: the specified table row, zero-indexed.
250
 *
251
 * Gets a text description of a particular table row.  This differs from
252
 * #atspi_table_get_row_header, which returns an #AtspiAccessible.
253
 *
254
 * Returns: a UTF-8 string describing the specified table row, if available.
255
 **/
256
gchar *
257
2
atspi_table_get_row_description (AtspiTable *obj,
258
                                 gint row,
259
                                 GError **error)
260
{
261
2
  dbus_int32_t d_row = row;
262
2
  char *retval = NULL;
263

            
264
2
  g_return_val_if_fail (obj != NULL, NULL);
265

            
266
2
  _atspi_dbus_call (obj, atspi_interface_table, "GetRowDescription", error, "i=>s", d_row, &retval);
267

            
268
2
  return retval;
269
}
270

            
271
/**
272
 * atspi_table_get_column_description:
273
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
274
 * @column: the specified table column, zero-indexed.
275
 *
276
 * Gets a text description of a particular table column.  This differs from
277
 * #atspi_table_get_column_header, which returns an #Accessible.
278
 *
279
 * Returns: a UTF-8 string describing the specified table column, if available.
280
 **/
281
gchar *
282
2
atspi_table_get_column_description (AtspiTable *obj,
283
                                    gint column,
284
                                    GError **error)
285
{
286
2
  dbus_int32_t d_column = column;
287
2
  char *retval = NULL;
288

            
289
2
  g_return_val_if_fail (obj != NULL, NULL);
290

            
291
2
  _atspi_dbus_call (obj, atspi_interface_table, "GetColumnDescription", error, "i=>s", d_column, &retval);
292

            
293
2
  return retval;
294
}
295

            
296
/**
297
 * atspi_table_get_row_extent_at:
298
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
299
 * @row: the specified table row, zero-indexed.
300
 * @column: the specified table column, zero-indexed.
301
 *
302
 * Gets the number of rows spanned by the table cell at the specific row
303
 * and column. (some tables can have cells which span multiple rows
304
 * and/or columns).
305
 * The returned values are meaningful only if the Table has both
306
 * STATE_VISIBLE and STATE_SHOWING.
307
 *
308
 * Returns: a #gint indicating the number of rows spanned by the specified cell.
309
 **/
310
gint
311
1
atspi_table_get_row_extent_at (AtspiTable *obj,
312
                               gint row,
313
                               gint column,
314
                               GError **error)
315
{
316
1
  dbus_int32_t d_row = row, d_column = column;
317
1
  dbus_int32_t retval = -1;
318

            
319
1
  g_return_val_if_fail (obj != NULL, -1);
320

            
321
1
  _atspi_dbus_call (obj, atspi_interface_table, "GetRowExtentAt", error, "ii=>i", d_row, d_column, &retval);
322

            
323
1
  return retval;
324
}
325

            
326
/**
327
 * atspi_table_get_column_extent_at:
328
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
329
 * @row: the specified table row, zero-indexed.
330
 * @column: the specified table column, zero-indexed.
331
 *
332
 * Gets the number of columns spanned by the table cell at the specific
333
 * row and column (some tables can have cells which span multiple
334
 * rows and/or columns).
335
 * The returned values are meaningful only if the Table has both
336
 * STATE_VISIBLE and STATE_SHOWING.
337
 *
338
 * Returns: a #gint indicating the number of columns spanned by the specified cell.
339
 **/
340
gint
341
1
atspi_table_get_column_extent_at (AtspiTable *obj,
342
                                  gint row,
343
                                  gint column,
344
                                  GError **error)
345
{
346
1
  dbus_int32_t d_row = row, d_column = column;
347
1
  dbus_int32_t retval = -1;
348

            
349
1
  g_return_val_if_fail (obj != NULL, -1);
350

            
351
1
  _atspi_dbus_call (obj, atspi_interface_table, "GetColumnExtentAt", error, "ii=>i", d_row, d_column, &retval);
352

            
353
1
  return retval;
354
}
355

            
356
/**
357
 * atspi_table_get_row_header:
358
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
359
 * @row: the specified table row, zero-indexed.
360
 *
361
 * Gets the header associated with a table row, if available. This differs from
362
 * #atspi_table_get_row_description, which returns a string.
363
 *
364
 * Returns: (transfer full): an #AtspiAccessible representation of the specified
365
 *          table row, if available.
366
 **/
367
AtspiAccessible *
368
2
atspi_table_get_row_header (AtspiTable *obj,
369
                            gint row,
370
                            GError **error)
371
{
372
2
  dbus_int32_t d_row = row;
373
  DBusMessage *reply;
374

            
375
2
  g_return_val_if_fail (obj != NULL, NULL);
376

            
377
2
  reply = _atspi_dbus_call_partial (obj, atspi_interface_table, "GetRowHeader", error, "i", d_row);
378

            
379
2
  return _atspi_dbus_return_accessible_from_message (reply);
380
}
381

            
382
/**
383
 * atspi_table_get_column_header:
384
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
385
 * @column: the specified table column, zero-indexed.
386
 *
387
 * Gets the header associated with a table column, if available.
388
 * This differs from #atspi_table_get_column_description, which
389
 * returns a string.
390
 *
391
 * Returns: (transfer full): an #AtspiAccessible representation of the
392
 *          specified table column, if available.
393
 **/
394
AtspiAccessible *
395
3
atspi_table_get_column_header (AtspiTable *obj,
396
                               gint column,
397
                               GError **error)
398
{
399
3
  dbus_int32_t d_column = column;
400
  DBusMessage *reply;
401

            
402
3
  g_return_val_if_fail (obj != NULL, NULL);
403

            
404
3
  reply = _atspi_dbus_call_partial (obj, atspi_interface_table, "GetColumnHeader", error, "i", d_column);
405

            
406
3
  return _atspi_dbus_return_accessible_from_message (reply);
407
}
408

            
409
/**
410
 * atspi_table_get_n_selected_rows:
411
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
412
 *
413
 * Query a table to find out how many rows are currently selected.
414
 * Not all tables support row selection.
415
 *
416
 * Returns: a #gint indicating the number of rows currently selected.
417
 **/
418
gint
419
1
atspi_table_get_n_selected_rows (AtspiTable *obj, GError **error)
420
{
421
1
  dbus_int32_t retval = -1;
422

            
423
1
  g_return_val_if_fail (obj != NULL, -1);
424

            
425
1
  _atspi_dbus_get_property (obj, atspi_interface_table, "NSelectedRows", error, "i", &retval);
426

            
427
1
  return retval;
428
}
429

            
430
/**
431
 * atspi_table_get_selected_rows:
432
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
433
 *
434
 * Queries a table for a list of indices of rows which are currently selected.
435
 *
436
 * Returns: (element-type gint) (transfer full): an array of #gint values,
437
 *          specifying which rows are currently selected.
438
 **/
439
GArray *
440
1
atspi_table_get_selected_rows (AtspiTable *obj,
441
                               GError **error)
442
{
443
1
  GArray *rows = NULL;
444

            
445
1
  g_return_val_if_fail (obj != NULL, 0);
446

            
447
1
  _atspi_dbus_call (obj, atspi_interface_table, "GetSelectedRows", error, "=>ai", &rows);
448

            
449
1
  return rows;
450
}
451

            
452
/**
453
 * atspi_table_get_selected_columns:
454
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
455
 *
456
 * Queries a table for a list of indices of columns which are currently
457
 * selected.
458
 *
459
 * Returns: (element-type gint) (transfer full): an array of #gint values,
460
 *          specifying which columns are currently selected.
461
 **/
462
GArray *
463
1
atspi_table_get_selected_columns (AtspiTable *obj,
464
                                  GError **error)
465
{
466
1
  GArray *columns = NULL;
467

            
468
1
  g_return_val_if_fail (obj != NULL, 0);
469

            
470
1
  _atspi_dbus_call (obj, atspi_interface_table, "GetSelectedColumns", error, "=>ai", &columns);
471

            
472
1
  return columns;
473
}
474

            
475
/**
476
 * atspi_table_get_n_selected_columns:
477
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
478
 *
479
 * Queries a table to find out how many columns are currently selected.
480
 * Not all tables support column selection.
481
 *
482
 * Returns: a #gint indicating the number of columns currently selected.
483
 **/
484
gint
485
1
atspi_table_get_n_selected_columns (AtspiTable *obj, GError **error)
486
{
487
1
  dbus_int32_t retval = -1;
488

            
489
1
  g_return_val_if_fail (obj != NULL, -1);
490

            
491
1
  _atspi_dbus_get_property (obj, atspi_interface_table, "NSelectedColumns", error, "i", &retval);
492

            
493
1
  return retval;
494
}
495

            
496
/**
497
 * atspi_table_is_row_selected:
498
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
499
 * @row: the zero-indexed row number of the row being queried.
500
 *
501
 * Determines whether a table row is selected.  Not all tables support
502
 * row selection.
503
 *
504
 * Returns: #TRUE if the specified row is currently selected, #FALSE if not.
505
 **/
506
gboolean
507
6
atspi_table_is_row_selected (AtspiTable *obj,
508
                             gint row,
509
                             GError **error)
510
{
511
6
  dbus_int32_t d_row = row;
512
6
  dbus_bool_t retval = FALSE;
513

            
514
6
  g_return_val_if_fail (obj != NULL, FALSE);
515

            
516
6
  _atspi_dbus_call (obj, atspi_interface_table, "IsRowSelected", error, "i=>b", d_row, &retval);
517

            
518
6
  return retval;
519
}
520

            
521
/**
522
 * atspi_table_is_column_selected:
523
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
524
 * @column: the zero-indexed column number of the column being queried.
525
 *
526
 * Determines whether specified table column is selected.
527
 * Not all tables support column selection.
528
 *
529
 * Returns: #TRUE if the specified column is currently selected, #FALSE if not.
530
 **/
531
gboolean
532
6
atspi_table_is_column_selected (AtspiTable *obj,
533
                                gint column,
534
                                GError **error)
535
{
536
6
  dbus_int32_t d_column = column;
537
6
  dbus_bool_t retval = FALSE;
538

            
539
6
  g_return_val_if_fail (obj != NULL, FALSE);
540

            
541
6
  _atspi_dbus_call (obj, atspi_interface_table, "IsColumnSelected", error, "i=>b", d_column, &retval);
542

            
543
6
  return retval;
544
}
545

            
546
/**
547
 * atspi_table_add_row_selection:
548
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
549
 * @row: the zero-indexed row number of the row being selected.
550
 *
551
 * Selects the specified row, adding it to the current row selection.
552
 * Not all tables support row selection.
553
 *
554
 * Returns: #TRUE if the specified row was successfully selected, #FALSE if not.
555
 **/
556
gboolean
557
1
atspi_table_add_row_selection (AtspiTable *obj,
558
                               gint row,
559
                               GError **error)
560
{
561
1
  dbus_int32_t d_row = row;
562
1
  dbus_bool_t retval = FALSE;
563

            
564
1
  g_return_val_if_fail (obj != NULL, FALSE);
565

            
566
1
  _atspi_dbus_call (obj, atspi_interface_table, "AddRowSelection", error, "i=>b", d_row, &retval);
567

            
568
1
  return retval;
569
}
570

            
571
/**
572
 * atspi_table_add_column_selection:
573
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
574
 * @column: the zero-indexed column number of the column being selected.
575
 *
576
 * Selects the specified column, adding it to the current column selection.
577
 * Not all tables support column selection.
578
 *
579
 * Returns: #TRUE if the specified column was successfully selected, #FALSE if not.
580
 **/
581
gboolean
582
1
atspi_table_add_column_selection (AtspiTable *obj,
583
                                  gint column,
584
                                  GError **error)
585
{
586
1
  dbus_int32_t d_column = column;
587
1
  dbus_bool_t retval = FALSE;
588

            
589
1
  g_return_val_if_fail (obj != NULL, FALSE);
590

            
591
1
  _atspi_dbus_call (obj, atspi_interface_table, "AddColumnSelection", error, "i=>b", d_column, &retval);
592

            
593
1
  return retval;
594
}
595

            
596
/**
597
 * atspi_table_remove_row_selection:
598
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
599
 * @row: the zero-indexed number of the row being de-selected.
600
 *
601
 * De-selects the specified row, removing it from the current row selection.
602
 * Not all tables support row selection.
603
 *
604
 * Returns: #TRUE if the specified row was successfully de-selected,
605
 * #FALSE if not.
606
 **/
607
gboolean
608
1
atspi_table_remove_row_selection (AtspiTable *obj,
609
                                  gint row,
610
                                  GError **error)
611
{
612
1
  dbus_int32_t d_row = row;
613
1
  dbus_bool_t retval = FALSE;
614

            
615
1
  g_return_val_if_fail (obj != NULL, FALSE);
616

            
617
1
  _atspi_dbus_call (obj, atspi_interface_table, "RemoveRowSelection", error, "i=>b", d_row, &retval);
618

            
619
1
  return retval;
620
}
621

            
622
/**
623
 * atspi_table_remove_column_selection:
624
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
625
 * @column: the zero-indexed column number of the column being de-selected.
626
 *
627
 * De-selects the specified column, removing it from the current column
628
 * selection.
629
 * Not all tables support column selection.
630
 *
631
 * Returns: #TRUE if the specified column was successfully de-selected,
632
 * #FALSE if not.
633
 **/
634
gboolean
635
1
atspi_table_remove_column_selection (AtspiTable *obj,
636
                                     gint column,
637
                                     GError **error)
638
{
639
1
  dbus_int32_t d_column = column;
640
1
  dbus_bool_t retval = FALSE;
641

            
642
1
  g_return_val_if_fail (obj != NULL, FALSE);
643

            
644
1
  _atspi_dbus_call (obj, atspi_interface_table, "RemoveColumnSelection", error, "i=>b", d_column, &retval);
645

            
646
1
  return retval;
647
}
648

            
649
/**
650
 * atspi_table_get_row_column_extents_at_index:
651
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
652
 * @index: the index of the #AtspiTable child whose row/column
653
 * extents are requested.
654
 * @row: (out): back-filled with the first table row associated with
655
 * the cell with child index.
656
 * @col: (out): back-filled with the first table column associated
657
 * with the cell with child index.
658
 * @row_extents: (out): back-filled with the number of table rows
659
 * across which child i extends.
660
 * @col_extents: (out): back-filled with the number of table columns
661
 * across which child i extends.
662
 * @is_selected: (out): a boolean which is back-filled with #TRUE
663
 * if the child at index i corresponds to a selected table cell,
664
 * #FALSE otherwise.
665
 *
666
 * Given a child index, determines the row and column indices and
667
 * extents, and whether the cell is currently selected.  If
668
 * the child at index is not a cell (for instance, if it is
669
 * a summary, caption, etc.), #FALSE is returned.
670
 * The returned values are meaningful only if the Table has both
671
 * STATE_VISIBLE and STATE_SHOWING.
672
 *
673
 * Example:
674
 * If the #AtspiTable child at index '6' extends across columns 5 and 6 of
675
 * row 2 of an #AtspiTable instance, and is currently selected, then
676
 *
677
 * retval = atspi_table_get_row_column_extents_at_index (table, 6,
678
 *                                             row, col,
679
 *                                             row_extents,
680
 *                                             col_extents,
681
 *                                             is_selected);
682
 *
683
 * will return #TRUE, and after the call
684
 * row, col, row_extents, col_extents,
685
 * and is_selected will contain 2, 5, 1, 2, and
686
 * #TRUE, respectively.
687
 *
688
 * Returns: #TRUE if the index is associated with a valid table
689
 * cell, #FALSE if the index does not correspond to a cell.  If
690
 * #FALSE is returned, the values of the out parameters are
691
 * undefined.
692
 **/
693
gboolean
694
1
atspi_table_get_row_column_extents_at_index (AtspiTable *obj,
695
                                             gint index,
696
                                             gint *row,
697
                                             gint *col,
698
                                             gint *row_extents,
699
                                             gint *col_extents,
700
                                             gboolean *is_selected,
701
                                             GError **error)
702
{
703
1
  dbus_int32_t d_index = index;
704
1
  dbus_bool_t retval = FALSE;
705
1
  dbus_int32_t d_row = 0, d_col = 0, d_row_extents = 0, d_col_extents = 0;
706
1
  dbus_bool_t d_is_selected = FALSE;
707

            
708
1
  g_return_val_if_fail (obj != NULL, FALSE);
709

            
710
1
  _atspi_dbus_call (obj, atspi_interface_table, "GetRowColumnExtentsAtIndex",
711
                    error, "i=>biiiib", d_index, &retval, &d_row, &d_col,
712
                    &d_row_extents, &d_col_extents, &d_is_selected);
713

            
714
1
  *row = d_row;
715
1
  *col = d_col;
716
1
  *row_extents = d_row_extents;
717
  ;
718
1
  *col_extents = d_col_extents;
719
1
  *is_selected = d_is_selected;
720
  ;
721

            
722
1
  return retval;
723
}
724

            
725
/**
726
 * atspi_table_is_selected:
727
 * @obj: a pointer to the #AtspiTable implementor on which to operate.
728
 * @row: the zero-indexed row of the cell being queried.
729
 * @column: the zero-indexed column of the cell being queried.
730
 *
731
 * Determines whether the cell at a specific row and column is selected.
732
 *
733
 * Returns: #TRUE if the specified cell is currently selected, #FALSE if not.
734
 **/
735
gboolean
736
2
atspi_table_is_selected (AtspiTable *obj,
737
                         gint row,
738
                         gint column,
739
                         GError **error)
740
{
741
2
  dbus_int32_t d_row = row, d_column = column;
742
2
  dbus_bool_t retval = FALSE;
743

            
744
2
  g_return_val_if_fail (obj != NULL, FALSE);
745

            
746
2
  _atspi_dbus_call (obj, atspi_interface_table, "IsSelected", error, "ii=>b", d_row, d_column, &retval);
747

            
748
2
  return retval;
749
}
750

            
751
static void
752
4
atspi_table_base_init (AtspiTable *klass)
753
{
754
4
}
755

            
756
GType
757
28
atspi_table_get_type (void)
758
{
759
  static GType type = 0;
760

            
761
28
  if (!type)
762
    {
763
      static const GTypeInfo tinfo = {
764
        sizeof (AtspiTable),
765
        (GBaseInitFunc) atspi_table_base_init,
766
        (GBaseFinalizeFunc) NULL,
767
      };
768

            
769
2
      type = g_type_register_static (G_TYPE_INTERFACE, "AtspiTable", &tinfo, 0);
770
    }
771
28
  return type;
772
}