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 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.
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.
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.
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 * Gets an accessible representation of the caption for an #AtspiTable.
34 * Returns: (transfer full): an #AtspiAccessible object that serves as
35 * the table's caption.
39 atspi_table_get_caption (AtspiTable *obj, GError **error)
41 AtspiAccessible *retval = NULL;
43 g_return_val_if_fail (obj != NULL, NULL);
45 _atspi_dbus_get_property (obj, atspi_interface_table, "Caption", error, "(so)", &retval);
50 * atspi_table_get_summary:
51 * @obj: a pointer to the #AtspiTable implementor on which to operate.
53 * Gets an accessible object which summarizes the contents of an #AtspiTable.
55 * Returns: (transfer full): an #AtspiAccessible object that serves as the
56 * table's summary (often a reduced #AtspiTable).
59 atspi_table_get_summary (AtspiTable *obj, GError **error)
61 AtspiAccessible *retval;
63 g_return_val_if_fail (obj != NULL, NULL);
65 _atspi_dbus_get_property (obj, atspi_interface_table, "Summary", error, "(so)", &retval);
71 * atspi_table_get_n_rows:
72 * @obj: a pointer to the #AtspiTable implementor on which to operate.
74 * Gets the number of rows in an #AtspiTable,
75 * exclusive of any rows that are programmatically hidden, but inclusive
76 * of rows that may be outside of the current scrolling window or viewport.
78 * Returns: a #gint indicating the number of rows in the table.
81 atspi_table_get_n_rows (AtspiTable *obj, GError **error)
83 dbus_int32_t retval = -1;
85 g_return_val_if_fail (obj != NULL, -1);
87 _atspi_dbus_get_property (obj, atspi_interface_table, "NRows", error, "i", &retval);
93 * atspi_table_get_n_columns:
94 * @obj: a pointer to the #AtspiTable implementor on which to operate.
96 * Gets the number of columns in an #AtspiTable,
97 * exclusive of any columns that are programmatically hidden, but inclusive
98 * of columns that may be outside of the current scrolling window or viewport.
100 * Returns: a #gint indicating the number of columns in the table.
103 atspi_table_get_n_columns (AtspiTable *obj, GError **error)
105 dbus_int32_t retval = -1;
107 g_return_val_if_fail (obj != NULL, -1);
109 _atspi_dbus_get_property (obj, atspi_interface_table, "NColumns", error, "i", &retval);
115 * atspi_table_get_accessible_at:
116 * @obj: a pointer to the #AtspiTable implementor on which to operate.
117 * @row: the specified table row, zero-indexed.
118 * @column: the specified table column, zero-indexed.
120 * Gets the table cell at the specified row and column indices.
121 * To get the accessible object at a particular (x, y) screen
122 * coordinate, use #atspi_component_get_accessible_at_point.
124 * Returns: (transfer full): an #AtspiAccessible object representing the
125 * specified table cell.
128 atspi_table_get_accessible_at (AtspiTable *obj,
133 dbus_int32_t d_row = row, d_column = column;
136 g_return_val_if_fail (obj != NULL, NULL);
138 reply = _atspi_dbus_call_partial (obj, atspi_interface_table, "GetAccessibleAt", error, "ii", d_row, d_column);
140 return _atspi_dbus_return_accessible_from_message (reply);
144 * atspi_table_get_index_at:
145 * @obj: a pointer to the #AtspiTable implementor on which to operate.
146 * @row: the specified table row, zero-indexed.
147 * @column: the specified table column, zero-indexed.
149 * Gets the 1-D child index corresponding to the specified 2-D row and
150 * column indices. To get the accessible object at a particular (x, y) screen
151 * coordinate, use #atspi_component_get_accessible_at_point.
153 * @see #atspi_table_get_row_at_index, #atspi_table_get_column_at_index
155 * Returns: a #gint which serves as the index of a specified cell in the
156 * table, in a form usable by #atspi_get_child_at_index.
159 atspi_table_get_index_at (AtspiTable *obj,
164 dbus_int32_t d_row = row, d_column = column;
165 dbus_int32_t retval = -1;
167 g_return_val_if_fail (obj != NULL, -1);
169 _atspi_dbus_call (obj, atspi_interface_table, "GetIndexAt", error, "ii=>i", d_row, d_column, &retval);
175 * atspi_table_get_row_at_index:
176 * @obj: a pointer to the #AtspiTable implementor on which to operate.
177 * @index: the specified child index, zero-indexed.
179 * Gets the table row index occupied by the child at a particular 1-D
182 * @see #atspi_table_get_index_at, #atspi_table_get_column_at_index
184 * Returns: a #gint indicating the first row spanned by the child of a
185 * table, at the specified 1-D (zero-offset) @index.
188 atspi_table_get_row_at_index (AtspiTable *obj,
192 dbus_int32_t d_index = index;
193 dbus_int32_t retval = -1;
195 g_return_val_if_fail (obj != NULL, -1);
197 _atspi_dbus_call (obj, atspi_interface_table, "GetRowAtIndex", error, "i=>i", d_index, &retval);
203 * atspi_table_get_column_at_index:
204 * @obj: a pointer to the #AtspiTable implementor on which to operate.
205 * @index: the specified child index, zero-indexed.
207 * Gets the table column index occupied by the child at a particular 1-D
210 * @see #atspi_table_get_index_at, #atspi_table_get_row_at_index
212 * Returns: a #gint indicating the first column spanned by the child of a
213 * table, at the specified 1-D (zero-offset) @index.
216 atspi_table_get_column_at_index (AtspiTable *obj,
220 dbus_int32_t d_index = index;
221 dbus_int32_t retval = -1;
223 g_return_val_if_fail (obj != NULL, -1);
225 _atspi_dbus_call (obj, atspi_interface_table, "GetColumnAtIndex", error, "i=>i", d_index, &retval);
231 * atspi_table_get_row_description:
232 * @obj: a pointer to the #AtspiTable implementor on which to operate.
233 * @row: the specified table row, zero-indexed.
235 * Gets a text description of a particular table row. This differs from
236 * #atspi_table_get_row_header, which returns an #AtspiAccessible.
238 * Returns: a UTF-8 string describing the specified table row, if available.
241 atspi_table_get_row_description (AtspiTable *obj,
245 dbus_int32_t d_row = row;
248 g_return_val_if_fail (obj != NULL, NULL);
250 _atspi_dbus_call (obj, atspi_interface_table, "GetRowDescription", error, "i=>s", d_row, &retval);
256 * atspi_table_get_column_description:
257 * @obj: a pointer to the #AtspiTable implementor on which to operate.
258 * @column: the specified table column, zero-indexed.
260 * Gets a text description of a particular table column. This differs from
261 * #atspi_table_get_column_header, which returns an #Accessible.
263 * Returns: a UTF-8 string describing the specified table column, if available.
266 atspi_table_get_column_description (AtspiTable *obj,
267 gint column, GError **error)
269 dbus_int32_t d_column = column;
272 g_return_val_if_fail (obj != NULL, NULL);
274 _atspi_dbus_call (obj, atspi_interface_table, "GetColumnDescription", error, "i=>s", d_column, &retval);
280 * atspi_table_get_row_extent_at:
281 * @obj: a pointer to the #AtspiTable implementor on which to operate.
282 * @row: the specified table row, zero-indexed.
283 * @column: the specified table column, zero-indexed.
285 * Gets the number of rows spanned by the table cell at the specific row
286 * and column. (some tables can have cells which span multiple rows
288 * The returned values are meaningful only if the Table has both
289 * STATE_VISIBLE and STATE_SHOWING.
291 * Returns: a #gint indicating the number of rows spanned by the specified cell.
294 atspi_table_get_row_extent_at (AtspiTable *obj,
299 dbus_int32_t d_row = row, d_column = column;
300 dbus_int32_t retval = -1;
302 g_return_val_if_fail (obj != NULL, -1);
304 _atspi_dbus_call (obj, atspi_interface_table, "GetRowExtentAt", error, "ii=>i", d_row, d_column, &retval);
310 * atspi_table_get_column_extent_at:
311 * @obj: a pointer to the #AtspiTable implementor on which to operate.
312 * @row: the specified table row, zero-indexed.
313 * @column: the specified table column, zero-indexed.
315 * Gets the number of columns spanned by the table cell at the specific
316 * row and column (some tables can have cells which span multiple
317 * rows and/or columns).
318 * The returned values are meaningful only if the Table has both
319 * STATE_VISIBLE and STATE_SHOWING.
321 * Returns: a #gint indicating the number of columns spanned by the specified cell.
324 atspi_table_get_column_extent_at (AtspiTable *obj,
329 dbus_int32_t d_row = row, d_column = column;
330 dbus_int32_t retval = -1;
332 g_return_val_if_fail (obj != NULL, -1);
334 _atspi_dbus_call (obj, atspi_interface_table, "GetColumnExtentAt", error, "ii=>i", d_row, d_column, &retval);
340 * atspi_table_get_row_header:
341 * @obj: a pointer to the #AtspiTable implementor on which to operate.
342 * @row: the specified table row, zero-indexed.
344 * Gets the header associated with a table row, if available. This differs from
345 * #atspi_table_get_row_description, which returns a string.
347 * Returns: (transfer full): an #AtspiAccessible representation of the specified
348 * table row, if available.
351 atspi_table_get_row_header (AtspiTable *obj,
355 dbus_int32_t d_row = row;
358 g_return_val_if_fail (obj != NULL, NULL);
360 reply = _atspi_dbus_call_partial (obj, atspi_interface_table, "GetRowHeader", error, "i", d_row);
362 return _atspi_dbus_return_accessible_from_message (reply);
366 * atspi_table_get_column_header:
367 * @obj: a pointer to the #AtspiTable implementor on which to operate.
368 * @column: the specified table column, zero-indexed.
370 * Gets the header associated with a table column, if available.
371 * This differs from #atspi_table_get_column_description, which
374 * Returns: (transfer full): an #AtspiAccessible representation of the
375 * specified table column, if available.
378 atspi_table_get_column_header (AtspiTable *obj,
382 dbus_int32_t d_column = column;
385 g_return_val_if_fail (obj != NULL, NULL);
387 reply = _atspi_dbus_call_partial (obj, atspi_interface_table, "GetColumnHeader", error, "i", d_column);
389 return _atspi_dbus_return_accessible_from_message (reply);
393 * atspi_table_get_n_selected_rows:
394 * @obj: a pointer to the #AtspiTable implementor on which to operate.
396 * Query a table to find out how many rows are currently selected.
397 * Not all tables support row selection.
399 * Returns: a #gint indicating the number of rows currently selected.
402 atspi_table_get_n_selected_rows (AtspiTable *obj, GError **error)
404 dbus_int32_t retval = -1;
406 g_return_val_if_fail (obj != NULL, -1);
408 _atspi_dbus_get_property (obj, atspi_interface_table, "NSelectedRows", error, "i", &retval);
414 * atspi_table_get_selected_rows:
415 * @obj: a pointer to the #AtspiTable implementor on which to operate.
417 * Queries a table for a list of indices of rows which are currently selected.
419 * Returns: (element-type gint) (transfer full): an array of #gint values,
420 * specifying which rows are currently selected.
423 atspi_table_get_selected_rows (AtspiTable *obj,
428 g_return_val_if_fail (obj != NULL, 0);
430 _atspi_dbus_call (obj, atspi_interface_table, "GetSelectedRows", error, "=>ai", &rows);
436 * atspi_table_get_selected_columns:
437 * @obj: a pointer to the #AtspiTable implementor on which to operate.
439 * Queries a table for a list of indices of columns which are currently
442 * Returns: (element-type gint) (transfer full): an array of #gint values,
443 * specifying which columns are currently selected.
446 atspi_table_get_selected_columns (AtspiTable *obj,
449 GArray *columns = NULL;
451 g_return_val_if_fail (obj != NULL, 0);
453 _atspi_dbus_call (obj, atspi_interface_table, "GetSelectedColumns", error, "=>ai", &columns);
459 * atspi_table_get_n_selected_columns:
460 * @obj: a pointer to the #AtspiTable implementor on which to operate.
462 * Queries a table to find out how many columns are currently selected.
463 * Not all tables support column selection.
465 * Returns: a #gint indicating the number of columns currently selected.
468 atspi_table_get_n_selected_columns (AtspiTable *obj, GError **error)
470 dbus_int32_t retval = -1;
472 g_return_val_if_fail (obj != NULL, -1);
474 _atspi_dbus_get_property (obj, atspi_interface_table, "NSelectedColumns", error, "i", &retval);
480 * atspi_table_is_row_selected:
481 * @obj: a pointer to the #AtspiTable implementor on which to operate.
482 * @row: the zero-indexed row number of the row being queried.
484 * Determines whether a table row is selected. Not all tables support
487 * Returns: #TRUE if the specified row is currently selected, #FALSE if not.
490 atspi_table_is_row_selected (AtspiTable *obj,
494 dbus_int32_t d_row = row;
495 dbus_bool_t retval = FALSE;
497 g_return_val_if_fail (obj != NULL, FALSE);
499 _atspi_dbus_call (obj, atspi_interface_table, "IsRowSelected", error, "i=>b", d_row, &retval);
505 * atspi_table_is_column_selected:
506 * @obj: a pointer to the #AtspiTable implementor on which to operate.
507 * @column: the zero-indexed column number of the column being queried.
509 * Determines whether specified table column is selected.
510 * Not all tables support column selection.
512 * Returns: #TRUE if the specified column is currently selected, #FALSE if not.
515 atspi_table_is_column_selected (AtspiTable *obj,
519 dbus_int32_t d_column = column;
520 dbus_bool_t retval = FALSE;
522 g_return_val_if_fail (obj != NULL, FALSE);
524 _atspi_dbus_call (obj, atspi_interface_table, "IsColumnSelected", error, "i=>b", d_column, &retval);
530 * atspi_table_add_row_selection:
531 * @obj: a pointer to the #AtspiTable implementor on which to operate.
532 * @row: the zero-indexed row number of the row being selected.
534 * Selects the specified row, adding it to the current row selection.
535 * Not all tables support row selection.
537 * Returns: #TRUE if the specified row was successfully selected, #FALSE if not.
540 atspi_table_add_row_selection (AtspiTable *obj,
544 dbus_int32_t d_row = row;
545 dbus_bool_t retval = FALSE;
547 g_return_val_if_fail (obj != NULL, FALSE);
549 _atspi_dbus_call (obj, atspi_interface_table, "AddRowSelection", error, "i=>b", d_row, &retval);
555 * atspi_table_add_column_selection:
556 * @obj: a pointer to the #AtspiTable implementor on which to operate.
557 * @column: the zero-indexed column number of the column being selected.
559 * Selects the specified column, adding it to the current column selection.
560 * Not all tables support column selection.
562 * Returns: #TRUE if the specified column was successfully selected, #FALSE if not.
565 atspi_table_add_column_selection (AtspiTable *obj,
569 dbus_int32_t d_column = column;
570 dbus_bool_t retval = FALSE;
572 g_return_val_if_fail (obj != NULL, FALSE);
574 _atspi_dbus_call (obj, atspi_interface_table, "AddColumnSelection", error, "i=>b", d_column, &retval);
580 * atspi_table_remove_row_selection:
581 * @obj: a pointer to the #AtspiTable implementor on which to operate.
582 * @row: the zero-indexed number of the row being de-selected.
584 * De-selects the specified row, removing it from the current row selection.
585 * Not all tables support row selection.
587 * Returns: #TRUE if the specified row was successfully de-selected,
591 atspi_table_remove_row_selection (AtspiTable *obj,
595 dbus_int32_t d_row = row;
596 dbus_bool_t retval = FALSE;
598 g_return_val_if_fail (obj != NULL, FALSE);
600 _atspi_dbus_call (obj, atspi_interface_table, "RemoveRowSelection", error, "i=>b", d_row, &retval);
606 * atspi_table_remove_column_selection:
607 * @obj: a pointer to the #AtspiTable implementor on which to operate.
608 * @column: the zero-indexed column number of the column being de-selected.
610 * De-selects the specified column, removing it from the current column
612 * Not all tables support column selection.
614 * Returns: #TRUE if the specified column was successfully de-selected,
618 atspi_table_remove_column_selection (AtspiTable *obj,
622 dbus_int32_t d_column = column;
623 dbus_bool_t retval = FALSE;
625 g_return_val_if_fail (obj != NULL, FALSE);
627 _atspi_dbus_call (obj, atspi_interface_table, "RemoveColumnSelection", error, "i=>b", d_column, &retval);
633 * atspi_table_get_row_column_extents_at_index:
634 * @obj: a pointer to the #AtspiTable implementor on which to operate.
635 * @index: the index of the #AtspiTable child whose row/column
636 * extents are requested.
637 * @row: (out): back-filled with the first table row associated with
638 * the cell with child index.
639 * @col: (out): back-filled with the first table column associated
640 * with the cell with child index.
641 * @row_extents: (out): back-filled with the number of table rows
642 * across which child i extends.
643 * @col_extents: (out): back-filled with the number of table columns
644 * across which child i extends.
645 * @is_selected: (out): a boolean which is back-filled with #TRUE
646 * if the child at index i corresponds to a selected table cell,
649 * Given a child index, determines the row and column indices and
650 * extents, and whether the cell is currently selected. If
651 * the child at index is not a cell (for instance, if it is
652 * a summary, caption, etc.), #FALSE is returned.
653 * The returned values are meaningful only if the Table has both
654 * STATE_VISIBLE and STATE_SHOWING.
657 * If the #AtspiTable child at index '6' extends across columns 5 and 6 of
658 * row 2 of an #AtspiTable instance, and is currently selected, then
660 * retval = atspi_table_get_row_column_extents_at_index (table, 6,
666 * will return #TRUE, and after the call
667 * row, col, row_extents, col_extents,
668 * and is_selected will contain 2, 5, 1, 2, and
669 * #TRUE, respectively.
671 * Returns: #TRUE if the index is associated with a valid table
672 * cell, #FALSE if the index does not correspond to a cell. If
673 * #FALSE is returned, the values of the out parameters are
677 atspi_table_get_row_column_extents_at_index (AtspiTable *obj,
678 gint index, gint *row, gint *col,
679 gint *row_extents, gint *col_extents,
680 gboolean *is_selected, GError **error)
682 dbus_int32_t d_index = index;
683 dbus_bool_t retval = FALSE;
684 dbus_int32_t d_row = 0, d_col = 0, d_row_extents = 0, d_col_extents = 0;
685 dbus_bool_t d_is_selected = FALSE;
687 g_return_val_if_fail (obj != NULL, FALSE);
689 _atspi_dbus_call (obj, atspi_interface_table, "GetRowColumnExtentsAtIndex",
690 error, "i=>biiiib", d_index, &retval, &d_row, &d_col,
691 &d_row_extents, &d_col_extents, &d_is_selected);
695 *row_extents = d_row_extents;;
696 *col_extents = d_col_extents;
697 *is_selected = d_is_selected;;
704 * atspi_table_is_selected:
705 * @obj: a pointer to the #AtspiTable implementor on which to operate.
706 * @row: the zero-indexed row of the cell being queried.
707 * @column: the zero-indexed column of the cell being queried.
709 * Determines whether the cell at a specific row and column is selected.
711 * Returns: #TRUE if the specified cell is currently selected, #FALSE if not.
714 atspi_table_is_selected (AtspiTable *obj,
719 dbus_int32_t d_row = row, d_column = column;
720 dbus_bool_t retval = FALSE;
722 g_return_val_if_fail (obj != NULL, FALSE);
724 _atspi_dbus_call (obj, atspi_interface_table, "IsSelected", error, "ii=>b", d_row, d_column, &retval);
730 atspi_table_base_init (AtspiTable *klass)
735 atspi_table_get_type (void)
737 static GType type = 0;
740 static const GTypeInfo tinfo =
743 (GBaseInitFunc) atspi_table_base_init,
744 (GBaseFinalizeFunc) NULL,
747 type = g_type_register_static (G_TYPE_INTERFACE, "AtspiTable", &tinfo, 0);