2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
7 * Copyright 2010, 2011 Novell, Inc.
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.
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.
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.
25 #include <stdlib.h> /* for malloc */
26 #include "atspi-private.h"
29 * atspi_table_get_caption:
30 * @obj: a pointer to the #AtspiTable implementor on which to operate.
32 * Get an accessible representation of the caption for an #AtspiTable.
34 * Returns: (transfer full): an #Accessible object that serves as the table's
38 atspi_table_get_caption (AtspiTable *obj, GError **error)
40 AtspiAccessible *retval = NULL;
42 g_return_val_if_fail (obj != NULL, NULL);
44 _atspi_dbus_get_property (obj, atspi_interface_table, "Caption", error, "(so)", &retval);
49 * atspi_table_get_summary:
50 * @obj: a pointer to the #AtspiTable implementor on which to operate.
52 * Get an accessible object which summarizes the contents of an #AtspiTable.
54 * Returns: (transfer full): an #AtspiAccessible object that serves as the
55 * table's summary (often a reduced #AtspiTable).
58 atspi_table_get_summary (AtspiTable *obj, GError **error)
60 AtspiAccessible *retval;
62 g_return_val_if_fail (obj != NULL, NULL);
64 _atspi_dbus_get_property (obj, atspi_interface_table, "Summary", error, "(so)", &retval);
70 * atspi_table_get_n_rows:
71 * @obj: a pointer to the #AtspiTable implementor on which to operate.
73 * Get the number of rows in an #AtspiTable,
74 * exclusive of any rows that are programmatically hidden, but inclusive
75 * of rows that may be outside of the current scrolling window or viewport.
77 * Returns: an integer indicating the number of rows in the table.
80 atspi_table_get_n_rows (AtspiTable *obj, GError **error)
82 dbus_int32_t retval = -1;
84 g_return_val_if_fail (obj != NULL, -1);
86 _atspi_dbus_get_property (obj, atspi_interface_table, "NRows", error, "i", &retval);
92 * atspi_table_get_n_columns:
93 * @obj: a pointer to the #AtspiTable implementor on which to operate.
95 * Get the number of columns in an #AtspiTable,
96 * exclusive of any columns that are programmatically hidden, but inclusive
97 * of columns that may be outside of the current scrolling window or viewport.
99 * Returns: an integer indicating the number of columns in the table.
102 atspi_table_get_n_columns (AtspiTable *obj, GError **error)
104 dbus_int32_t retval = -1;
106 g_return_val_if_fail (obj != NULL, -1);
108 _atspi_dbus_get_property (obj, atspi_interface_table, "NColumns", error, "i", &retval);
114 * atspi_table_get_accessible_at:
115 * @obj: a pointer to the #AtspiTable implementor on which to operate.
116 * @row: the specified table row, zero-indexed.
117 * @column: the specified table column, zero-indexed.
119 * Get the table cell at the specified row and column indices.
120 * To get the accessible object at a particular (x, y) screen coordinate,
121 * use #atspi_component_get_accessible_at_point ().
123 * Returns: (transfer full): an #AtspiAccessible object representing the
124 * specified table cell.
127 atspi_table_get_accessible_at (AtspiTable *obj,
132 dbus_int32_t d_row = row, d_column = column;
135 g_return_val_if_fail (obj != NULL, NULL);
137 reply = _atspi_dbus_call_partial (obj, atspi_interface_table, "GetAccessibleAt", error, "ii", d_row, d_column);
139 return _atspi_dbus_return_accessible_from_message (reply);
143 * atspi_table_get_index_at:
144 * @obj: a pointer to the #AtspiTable implementor on which to operate.
145 * @row: the specified table row, zero-indexed.
146 * @column: the specified table column, zero-indexed.
148 * Get the 1-D child index corresponding to the specified 2-D row and column indices.
149 * To get the accessible object at a particular (x, y) screen coordinate,
150 * use #Accessible_getAccessibleAtPoint ().
151 * @see #atspi_table_getRowAtIndex(), #atspi_table_getColumnAtIndex()
153 * Returns: a long integer which serves as the index of a specified cell in the
154 * table, in a form usable by #Accessible_getChildAtIndex().
157 atspi_table_get_index_at (AtspiTable *obj,
162 dbus_int32_t d_row = row, d_column = column;
163 dbus_int32_t retval = -1;
165 g_return_val_if_fail (obj != NULL, -1);
167 _atspi_dbus_call (obj, atspi_interface_table, "GetIndexAt", error, "ii=>i", d_row, d_column, &retval);
173 * atspi_table_get_row_at_index:
174 * @obj: a pointer to the #AtspiTable implementor on which to operate.
175 * @index: the specified child index, zero-indexed.
177 * Get the table row index occupied by the child at a particular 1-D child index.
179 * @see #atspi_table_get_indexAt(), #atspi_table_get_columnAtIndex()
181 * Returns: a long integer indicating the first row spanned by the child of a
182 * table, at the specified 1-D (zero-offset) @index.
185 atspi_table_get_row_at_index (AtspiTable *obj,
189 dbus_int32_t d_index = index;
190 dbus_int32_t retval = -1;
192 g_return_val_if_fail (obj != NULL, -1);
194 _atspi_dbus_call (obj, atspi_interface_table, "GetRowAtIndex", error, "i=>i", d_index, &retval);
200 * atspi_table_get_column_at_index:
201 * @obj: a pointer to the #AtspiTable implementor on which to operate.
202 * @index: the specified child index, zero-indexed.
204 * Get the table column index occupied by the child at a particular 1-D child index.
206 * @see #atspi_table_getIndexAt(), #atspi_table_getRowAtIndex()
208 * Returns: a long integer indicating the first column spanned by the child of a
209 * table, at the specified 1-D (zero-offset) @index.
212 atspi_table_get_column_at_index (AtspiTable *obj,
216 dbus_int32_t d_index = index;
217 dbus_int32_t retval = -1;
219 g_return_val_if_fail (obj != NULL, -1);
221 _atspi_dbus_call (obj, atspi_interface_table, "GetColumnAtIndex", error, "i=>i", d_index, &retval);
227 * atspi_table_get_row_description:
228 * @obj: a pointer to the #AtspiTable implementor on which to operate.
229 * @row: the specified table row, zero-indexed.
231 * Get a text description of a particular table row. This differs from
232 * atspi_table_get_row_header, which returns an #AtspiAccessible.
234 * Returns: a UTF-8 string describing the specified table row, if available.
237 atspi_table_get_row_description (AtspiTable *obj,
241 dbus_int32_t d_row = row;
244 g_return_val_if_fail (obj != NULL, NULL);
246 _atspi_dbus_call (obj, atspi_interface_table, "GetRowDescription", error, "i=>s", d_row, &retval);
252 * atspi_table_get_column_description:
253 * @obj: a pointer to the #AtspiTable implementor on which to operate.
254 * @column: the specified table column, zero-indexed.
256 * Get a text description of a particular table column. This differs from
257 * atspi_table_get_column_header, which returns an #Accessible.
259 * Returns: a UTF-8 string describing the specified table column, if available.
262 atspi_table_get_column_description (AtspiTable *obj,
263 gint column, GError **error)
265 dbus_int32_t d_column = column;
268 g_return_val_if_fail (obj != NULL, NULL);
270 _atspi_dbus_call (obj, atspi_interface_table, "GetColumnDescription", error, "i=>s", d_column, &retval);
276 * atspi_table_get_row_extent_at:
277 * @obj: a pointer to the #AtspiTable implementor on which to operate.
278 * @row: the specified table row, zero-indexed.
279 * @column: the specified table column, zero-indexed.
281 * Get the number of rows spanned by the table cell at the specific row and column.
282 * (some tables can have cells which span multiple rows and/or columns).
284 * Returns: a long integer indicating the number of rows spanned by the specified cell.
287 atspi_table_get_row_extent_at (AtspiTable *obj,
292 dbus_int32_t d_row = row, d_column = column;
293 dbus_int32_t retval = -1;
295 g_return_val_if_fail (obj != NULL, -1);
297 _atspi_dbus_call (obj, atspi_interface_table, "GetRowExtentAt", error, "ii=>i", d_row, d_column, &retval);
303 * atspi_table_get_column_extent_at:
304 * @obj: a pointer to the #AtspiTable implementor on which to operate.
305 * @row: the specified table row, zero-indexed.
306 * @column: the specified table column, zero-indexed.
308 * Get the number of columns spanned by the table cell at the specific row and column.
309 * (some tables can have cells which span multiple rows and/or columns).
311 * Returns: a long integer indicating the number of columns spanned by the specified cell.
314 atspi_table_get_column_extent_at (AtspiTable *obj,
319 dbus_int32_t d_row = row, d_column = column;
320 dbus_int32_t retval = -1;
322 g_return_val_if_fail (obj != NULL, -1);
324 _atspi_dbus_call (obj, atspi_interface_table, "GetColumnExtentAt", error, "ii=>i", d_row, d_column, &retval);
330 * atspi_table_get_row_header:
331 * @obj: a pointer to the #AtspiTable implementor on which to operate.
332 * @row: the specified table row, zero-indexed.
334 * Get the header associated with a table row, if available. This differs from
335 * atspi_table_get_row_description, which returns a string.
337 * Returns: (transfer full): a #Accessible representatin of the specified
338 * table row, if available.
341 atspi_table_get_row_header (AtspiTable *obj,
345 dbus_int32_t d_row = row;
348 g_return_val_if_fail (obj != NULL, NULL);
350 reply = _atspi_dbus_call_partial (obj, atspi_interface_table, "GetRowHeader", error, "i", d_row);
352 return _atspi_dbus_return_accessible_from_message (reply);
356 * atspi_table_get_column_header:
357 * @obj: a pointer to the #AtspiTable implementor on which to operate.
358 * @column: the specified table column, zero-indexed.
360 * Get the header associated with a table column, if available. This differs from
361 * atspi_table_get_column_description, which returns a string.
363 * Returns: (transfer full): a #AtspiAccessible representation of the
364 * specified table column, if available.
367 atspi_table_get_column_header (AtspiTable *obj,
371 dbus_int32_t d_column = column;
374 g_return_val_if_fail (obj != NULL, NULL);
376 reply = _atspi_dbus_call_partial (obj, atspi_interface_table, "GetColumnHeader", error, "i", d_column);
378 return _atspi_dbus_return_accessible_from_message (reply);
382 * atspi_table_get_n_selected_rows:
383 * @obj: a pointer to the #AtspiTable implementor on which to operate.
385 * Query a table to find out how many rows are currently selected. Not all tables
386 * support row selection.
388 * Returns: a long integer indicating the number of rows currently selected.
391 atspi_table_get_n_selected_rows (AtspiTable *obj, GError **error)
393 dbus_int32_t retval = -1;
395 g_return_val_if_fail (obj != NULL, -1);
397 _atspi_dbus_get_property (obj, atspi_interface_table, "NSelectedRows", error, "i", &retval);
403 * atspi_table_get_selected_rows:
404 * @obj: a pointer to the #AtspiTable implementor on which to operate.
406 * Query a table for a list of indices of rows which are currently selected.
408 * Returns: (element-type gint) (transfer full): an array of integers,
409 * specifying which rows are currently selected.
412 atspi_table_get_selected_rows (AtspiTable *obj,
417 g_return_val_if_fail (obj != NULL, 0);
419 _atspi_dbus_call (obj, atspi_interface_table, "GetSelectedRows", error, "=>ai", &rows);
425 * atspi_table_get_selected_columns:
426 * @obj: a pointer to the #AtspiTable implementor on which to operate.
428 * Query a table for a list of indices of columns which are currently selected.
430 * Returns: (element-type gint) (transfer full): an array of integers,
431 * specifying which columns are currently selected.
434 atspi_table_get_selected_columns (AtspiTable *obj,
437 GArray *columns = NULL;
439 g_return_val_if_fail (obj != NULL, 0);
441 _atspi_dbus_call (obj, atspi_interface_table, "GetSelectedColumns", error, "=>ai", &columns);
447 * atspi_table_get_n_selected_columns:
448 * @obj: a pointer to the #AtspiTable implementor on which to operate.
450 * Query a table to find out how many columns are currently selected. Not all tables
451 * support column selection.
453 * Returns: a long integer indicating the number of columns currently selected.
456 atspi_table_get_n_selected_columns (AtspiTable *obj, GError **error)
458 dbus_int32_t retval = -1;
460 g_return_val_if_fail (obj != NULL, -1);
462 _atspi_dbus_get_property (obj, atspi_interface_table, "NSelectedColumns", error, "i", &retval);
468 * atspi_table_is_row_selected:
469 * @obj: a pointer to the #AtspiTable implementor on which to operate.
470 * @row: the zero-indexed row number of the row being queried.
472 * Determine whether a table row is selected. Not all tables support row selection.
474 * Returns: #TRUE if the specified row is currently selected, #FALSE if not.
477 atspi_table_is_row_selected (AtspiTable *obj,
481 dbus_int32_t d_row = row;
482 dbus_bool_t retval = FALSE;
484 g_return_val_if_fail (obj != NULL, FALSE);
486 _atspi_dbus_call (obj, atspi_interface_table, "IsRowSelected", error, "i=>b", d_row, &retval);
492 * atspi_table_is_column_selected:
493 * @obj: a pointer to the #AtspiTable implementor on which to operate.
494 * @column: the zero-indexed column number of the column being queried.
496 * Determine whether specified table column is selected.
497 * Not all tables support column selection.
499 * Returns: #TRUE if the specified column is currently selected, #FALSE if not.
502 atspi_table_is_column_selected (AtspiTable *obj,
506 dbus_int32_t d_column = column;
507 dbus_bool_t retval = FALSE;
509 g_return_val_if_fail (obj != NULL, FALSE);
511 _atspi_dbus_call (obj, atspi_interface_table, "IsColumnSelected", error, "i=>b", d_column, &retval);
517 * atspi_table_add_row_selection:
518 * @obj: a pointer to the #AtspiTable implementor on which to operate.
519 * @row: the zero-indexed row number of the row being selected.
521 * Select the specified row, adding it to the current row selection.
522 * Not all tables support row selection.
524 * Returns: #TRUE if the specified row was successfully selected, #FALSE if not.
527 atspi_table_add_row_selection (AtspiTable *obj,
531 dbus_int32_t d_row = row;
532 dbus_bool_t retval = FALSE;
534 g_return_val_if_fail (obj != NULL, FALSE);
536 _atspi_dbus_call (obj, atspi_interface_table, "AddRowSelection", error, "i=>b", d_row, &retval);
542 * atspi_table_add_column_selection:
543 * @obj: a pointer to the #AtspiTable implementor on which to operate.
544 * @column: the zero-indexed column number of the column being selected.
546 * Select the specified column, adding it to the current column selection.
547 * Not all tables support column selection.
549 * Returns: #TRUE if the specified column was successfully selected, #FALSE if not.
552 atspi_table_add_column_selection (AtspiTable *obj,
556 dbus_int32_t d_column = column;
557 dbus_bool_t retval = FALSE;
559 g_return_val_if_fail (obj != NULL, FALSE);
561 _atspi_dbus_call (obj, atspi_interface_table, "AddColumnSelection", error, "i=>b", d_column, &retval);
567 * atspi_table_remove_row_selection:
568 * @obj: a pointer to the #AtspiTable implementor on which to operate.
569 * @row: the zero-indexed number of the row being deselected.
571 * De-select the specified row, removing it to the current row selection.
572 * Not all tables support row selection.
574 * Returns: #TRUE if the specified row was successfully de-selected, #FALSE if not.
577 atspi_table_remove_row_selection (AtspiTable *obj,
581 dbus_int32_t d_row = row;
582 dbus_bool_t retval = FALSE;
584 g_return_val_if_fail (obj != NULL, FALSE);
586 _atspi_dbus_call (obj, atspi_interface_table, "RemoveRowSelection", error, "i=>b", d_row, &retval);
592 * atspi_table_remove_column_selection:
593 * @obj: a pointer to the #AtspiTable implementor on which to operate.
594 * @column: the zero-indexed column number of the column being de-selected.
596 * De-select the specified column, removing it to the current column selection.
597 * Not all tables support column selection.
599 * Returns: #TRUE if the specified column was successfully de-selected, #FALSE if not.
602 atspi_table_remove_column_selection (AtspiTable *obj,
606 dbus_int32_t d_column = column;
607 dbus_bool_t retval = FALSE;
609 g_return_val_if_fail (obj != NULL, FALSE);
611 _atspi_dbus_call (obj, atspi_interface_table, "RemoveColumnSelection", error, "i=>b", d_column, &retval);
617 * atspi_table_get_row_column_extents_at_index:
618 * @obj: a pointer to the #AtspiTable implementor on which to operate.
619 * @index: the index of the Table child whose row/column
620 * extents are requested.
621 * @row: (out): back-filled with the first table row associated with
622 * the cell with child index \c index.
623 * @col: (out): back-filled with the first table column associated
624 * with the cell with child index \c index.
625 * @row_extents: (out): back-filled with the number of table rows
626 * across which child \c i extends.
627 * @col_extents: (out): back-filled with the number of table columns
628 * across which child \c i extends.
629 * @is_selected: (out): a boolean which is back-filled with \c True
630 * if the child at index \c i corresponds to a selected table cell,
631 * \c False otherwise.
633 * Given a child index, determine the row and column indices and
634 * extents, and whether the cell is currently selected. If
635 * the child at \c index is not a cell (for instance, if it is
636 * a summary, caption, etc.), \c False is returned.
639 * If the Table child at index '6' extends across columns 5 and 6 of
640 * row 2 of a Table instance, and is currently selected, then
642 * retval = table::getRowColumnExtentsAtIndex (6, row, col,
647 * will return True, and after the call
648 * row, col, row_extents, col_extents,
649 * and \c is_selected will contain 2, 5, 1, 2, and
650 * True, respectively.
652 * Returns: \c True if the index is associated with a valid table
653 * cell, \c False if the index does not correspond to a cell. If
654 * \c False is returned, the values of the out parameters are
658 atspi_table_get_row_column_extents_at_index (AtspiTable *obj,
659 gint index, gint *row, gint *col,
660 gint *row_extents, gint *col_extents,
661 gboolean *is_selected, GError **error)
663 dbus_int32_t d_index = index;
664 dbus_bool_t retval = FALSE;
665 dbus_int32_t d_row = 0, d_col = 0, d_row_extents = 0, d_col_extents = 0;
666 dbus_bool_t d_is_selected = FALSE;
668 g_return_val_if_fail (obj != NULL, FALSE);
670 _atspi_dbus_call (obj, atspi_interface_table, "GetRowColumnExtentsAtIndex", error, "i=>iiiibb", d_index, &d_row, &d_col, &d_row_extents, &d_col_extents, &d_is_selected, &retval);
673 *row_extents = d_row_extents;;
674 *col_extents = d_col_extents;
675 *is_selected = d_is_selected;;
682 * atspi_table_is_selected:
683 * @obj: a pointer to the #AtspiTable implementor on which to operate.
684 * @row: the zero-indexed row of the cell being queried.
685 * @column: the zero-indexed column of the cell being queried.
687 * Determine whether the cell at a specific row and column is selected.
689 * Returns: #TRUE if the specified cell is currently selected, #FALSE if not.
692 atspi_table_is_selected (AtspiTable *obj,
697 dbus_int32_t d_row = row, d_column = column;
698 dbus_bool_t retval = FALSE;
700 g_return_val_if_fail (obj != NULL, FALSE);
702 _atspi_dbus_call (obj, atspi_interface_table, "IsSelected", error, "ii=>b", d_row, d_column, &retval);
708 atspi_table_base_init (AtspiTable *klass)
713 atspi_table_get_type (void)
715 static GType type = 0;
718 static const GTypeInfo tinfo =
721 (GBaseInitFunc) atspi_table_base_init,
722 (GBaseFinalizeFunc) NULL,
725 type = g_type_register_static (G_TYPE_INTERFACE, "AtspiTable", &tinfo, 0);