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 2013 SUSE LLC.
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 get_object_array_and_unref (DBusMessage *reply)
31 DBusMessageIter iter, iter_array;
37 if (strcmp (dbus_message_get_signature (reply), "a(so)") != 0)
39 dbus_message_unref (reply);
43 array = g_ptr_array_new ();
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)
49 AtspiAccessible *accessible = _atspi_dbus_return_accessible_from_iter (&iter_array);
50 g_ptr_array_add (array, accessible);
52 dbus_message_unref (reply);
57 * atspi_table_cell_get_column_span:
58 * @obj: a GObject instance that implements AtspiTableCellIface
60 * Returns the number of columns occupied by this cell accessible.
61 * The returned values are meaningful only if the table cell has both
62 * STATE_VISIBLE and STATE_SHOWING.
64 * Returns: a gint representing the number of columns occupied by this cell,
65 * or 0 if the cell does not implement this method.
68 atspi_table_cell_get_column_span (AtspiTableCell *obj, GError **error)
70 dbus_int32_t retval = -1;
72 g_return_val_if_fail (obj != NULL, -1);
74 _atspi_dbus_get_property (obj, atspi_interface_table_cell, "ColumnSpan",
81 * atspi_table_cell_get_column_header_cells:
82 * @obj: a GObject instance that implements AtspiTableCellIface
84 * Returns the column headers as an array of cell accessibles.
86 * Returns: (element-type AtspiAccessible) (transfer full): a GPtrArray of
87 * AtspiAccessibles representing the column header cells.
90 atspi_table_cell_get_column_header_cells (AtspiTableCell *obj, GError **error)
94 g_return_val_if_fail (obj != NULL, NULL);
96 reply = _atspi_dbus_call_partial (obj, atspi_interface_table_cell, "GetColumnHeaderCells", error, "");
98 return get_object_array_and_unref (reply);
102 * atspi_table_cell_get_row_span:
103 * @obj: a GObject instance that implements AtspiTableCellIface
105 * Returns the number of rows occupied by this cell accessible.
106 * The returned values are meaningful only if the table cell has both
107 * STATE_VISIBLE and STATE_SHOWING.
109 * Returns: a gint representing the number of rows occupied by this cell,
110 * or 0 if the cell does not implement this method.
113 atspi_table_cell_get_row_span (AtspiTableCell *obj, GError **error)
115 dbus_int32_t retval = -1;
117 g_return_val_if_fail (obj != NULL, -1);
119 _atspi_dbus_get_property (obj, atspi_interface_table_cell, "RowSpan",
120 error, "i", &retval);
126 * atspi_table_cell_get_row_header_cells:
127 * @obj: a GObject instance that implements AtspiTableCellIface
129 * Returns the row headers as an array of cell accessibles.
131 * Returns: (element-type AtspiAccessible) (transfer full): a GPtrArray of
132 * AtspiAccessibles representing the row header cells.
135 atspi_table_cell_get_row_header_cells (AtspiTableCell *obj, GError **error)
139 g_return_val_if_fail (obj != NULL, NULL);
141 reply = _atspi_dbus_call_partial (obj, atspi_interface_table_cell, "GetRowHeaderCells", error, "");
143 return get_object_array_and_unref (reply);
147 * atspi_table_cell_get_position:
148 * @obj: a GObject instance that implements AtspiTableCellIface
149 * @row: (out): the row of the given cell.
150 * @column: (out): the column of the given cell.
152 * Retrieves the tabular position of this cell.
154 * Returns: TRUE if successful, FALSE otherwise.
157 atspi_table_cell_get_position (AtspiTableCell *obj,
163 DBusMessageIter iter, iter_struct, iter_variant;
164 dbus_int32_t d_row = -1, d_column = -1;
167 g_return_val_if_fail (obj != NULL, -1);
169 reply = _atspi_dbus_call_partial (obj, "org.freedesktop.DBus.Properties",
171 atspi_interface_table_cell, "Position");
176 dbus_message_iter_init (reply, &iter);
178 /* TODO: Return error here */
179 if (dbus_message_iter_get_arg_type (&iter) != 'v')
182 dbus_message_iter_recurse (&iter, &iter_variant);
183 iter_sig = dbus_message_iter_get_signature (&iter_variant);
184 /* TODO: Also report error here */
185 if (strcmp (iter_sig, "(ii)") != 0)
187 dbus_free (iter_sig);
190 dbus_free (iter_sig);
192 dbus_message_iter_recurse (&iter_variant, &iter_struct);
193 dbus_message_iter_get_basic (&iter_struct, &d_row);
196 dbus_message_iter_next (&iter_struct);
197 dbus_message_iter_get_basic (&iter_struct, &d_column);
200 dbus_message_unref (reply);
205 * atspi_table_cell_get_row_column_span:
206 * @obj: a GObject instance that implements AtspiTableCellIface
207 * @row: (out): the row index of the given cell.
208 * @column: (out): the column index of the given cell.
209 * @row_span: (out): the number of rows occupied by this cell.
210 * @column_span: (out): the number of columns occupied by this cell.
212 * Gets the row and column indexes and extents of this cell accessible.
213 * The returned values are meaningful only if the table cell has both
214 * STATE_VISIBLE and STATE_SHOWING.
217 atspi_table_cell_get_row_column_span (AtspiTableCell *obj,
224 dbus_int32_t d_row = 0, d_column = 0, d_row_span = 0, d_column_span = 0;
235 g_return_if_fail (obj != NULL);
237 _atspi_dbus_call (obj, atspi_interface_table_cell, "GetRowColumnSpan",
238 error, "=>iiii", &d_row, &d_column,
239 &d_row_span, &d_column_span);
246 *row_span = d_row_span;
248 *column_span = d_column_span;
252 * atspi_table_cell_get_table:
253 * @obj: a GObject instance that implements AtspiTableCellIface
255 * Returns a reference to the accessible of the containing table.
257 * Returns: (transfer full): the AtspiAccessible for the containing table.
260 atspi_table_cell_get_table (AtspiTableCell *obj, GError **error)
262 AtspiAccessible *retval = NULL;
264 g_return_val_if_fail (obj != NULL, NULL);
266 _atspi_dbus_get_property (obj, atspi_interface_table_cell, "Table",
267 error, "(so)", &retval);
273 atspi_table_cell_base_init (AtspiTableCell *klass)
278 atspi_table_cell_get_type (void)
280 static GType type = 0;
283 static const GTypeInfo tinfo =
285 sizeof (AtspiTableCell),
286 (GBaseInitFunc) atspi_table_cell_base_init,
287 (GBaseFinalizeFunc) NULL,
290 type = g_type_register_static (G_TYPE_INTERFACE, "AtspiTableCell", &tinfo, 0);