2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001 Sun Microsystems Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 /* table.c : implements the Table interface */
27 #include <libspi/accessible.h>
28 #include <libspi/table.h>
30 /* A pointer to our parent object class */
31 static GObjectClass *parent_class;
34 spi_table_finalize (GObject *obj)
36 SpiTable *table = SPI_TABLE (obj);
37 g_object_unref (table->atko);
39 parent_class->finalize (obj);
43 spi_table_interface_new (AtkObject *obj)
45 SpiTable *new_table = g_object_new (SPI_TABLE_TYPE, NULL);
46 new_table->atko = obj;
53 static Accessibility_Accessible
54 impl__get_caption (PortableServer_Servant _servant,
55 CORBA_Environment * ev)
57 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
58 AtkObject *atk_object;
59 Accessibility_Accessible rv;
61 atk_object = atk_table_get_caption (ATK_TABLE(table-> atko));
62 rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(atk_object)));
63 return CORBA_Object_duplicate (rv, ev);
68 static Accessibility_Accessible
69 impl__get_summary (PortableServer_Servant _servant,
70 CORBA_Environment * ev)
72 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
73 AtkObject *atk_object;
74 Accessibility_Accessible rv;
76 atk_object = atk_table_get_summary (ATK_TABLE(table->atko));
77 rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(atk_object)));
78 return CORBA_Object_duplicate (rv, ev);
84 impl__get_nRows (PortableServer_Servant _servant,
85 CORBA_Environment * ev)
87 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
89 atk_table_get_n_rows (ATK_TABLE(table->atko) );
95 impl__get_nColumns (PortableServer_Servant _servant,
96 CORBA_Environment * ev)
98 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
100 atk_table_get_n_columns (ATK_TABLE(table->atko));
105 static Accessibility_Accessible
106 impl_getAccessibleAt (PortableServer_Servant _servant,
107 const CORBA_long row,
108 const CORBA_long column,
109 CORBA_Environment * ev)
111 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
112 AtkObject *atk_object;
113 Accessibility_Accessible rv;
115 atk_object = atk_table_ref_at (ATK_TABLE(table->atko),
116 (gint) row, (gint) column);
117 rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(atk_object)));
118 return CORBA_Object_duplicate (rv, ev);
124 impl_getIndexAt (PortableServer_Servant _servant,
125 const CORBA_long row, const CORBA_long column,
126 CORBA_Environment * ev)
128 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
130 atk_table_get_index_at (ATK_TABLE(table->atko),
131 (gint) row, (gint) column);
137 impl_getRowAtIndex (PortableServer_Servant _servant,
138 const CORBA_long index,
139 CORBA_Environment * ev)
141 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
143 atk_table_get_row_at_index (ATK_TABLE(table->atko), (gint) index);
149 impl_getColumnAtIndex (PortableServer_Servant _servant,
150 const CORBA_long index,
151 CORBA_Environment * ev)
153 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
155 atk_table_get_column_at_index (ATK_TABLE(table->atko), (gint) index);
161 impl_getRowDescription (PortableServer_Servant servant,
162 const CORBA_long row,
163 CORBA_Environment *ev)
168 table = SPI_TABLE (bonobo_object_from_servant (servant));
170 rv = atk_table_get_row_description (ATK_TABLE (table->atko), row);
173 return CORBA_string_dup (rv);
175 return CORBA_string_dup ("");
181 impl_getColumnDescription (PortableServer_Servant servant,
182 const CORBA_long column,
183 CORBA_Environment *ev)
188 table = SPI_TABLE (bonobo_object_from_servant (servant));
190 rv = atk_table_get_row_description (ATK_TABLE (table->atko), column);
193 return CORBA_string_dup (rv);
195 return CORBA_string_dup ("");
201 impl_getRowExtentAt (PortableServer_Servant _servant,
202 const CORBA_long row,
203 const CORBA_long column,
204 CORBA_Environment * ev)
206 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
208 atk_table_get_row_extent_at (ATK_TABLE(table->atko),
209 (gint) row, (gint) column);
215 impl_getColumnExtentAt (PortableServer_Servant _servant,
216 const CORBA_long row,
217 const CORBA_long column,
218 CORBA_Environment * ev)
220 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
222 atk_table_get_column_extent_at (ATK_TABLE(table->atko),
223 (gint) row, (gint) column);
228 static Accessibility_Table
229 impl_getRowHeader (PortableServer_Servant _servant,
230 const CORBA_long row,
231 CORBA_Environment * ev)
233 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
235 Accessibility_Table rv;
237 header = atk_table_get_row_header (ATK_TABLE(table->atko), (gint) row);
238 rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(header)));
239 return CORBA_Object_duplicate (rv, ev);
244 static Accessibility_Table
245 impl_getColumnHeader (PortableServer_Servant _servant,
246 const CORBA_long column,
247 CORBA_Environment * ev)
249 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
251 Accessibility_Table rv;
253 header = atk_table_get_column_header (ATK_TABLE(table->atko), (gint) column);
254 rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(header)));
255 return CORBA_Object_duplicate (rv, ev);
260 static Accessibility_LongSeq *
261 impl_getSelectedRows (PortableServer_Servant _servant,
262 CORBA_Environment * ev)
264 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
267 Accessibility_LongSeq *retval;
269 length = atk_table_get_selected_rows (ATK_TABLE(table->atko), &selectedRows);
271 g_return_val_if_fail (length, NULL);
272 retval = Accessibility_LongSeq__alloc ();
273 retval->_maximum = retval->_length = (CORBA_long) length;
274 retval->_buffer = Accessibility_LongSeq_allocbuf (length);
277 retval->_buffer[length] = (CORBA_long) selectedRows[length];
278 g_free ((gpointer) selectedRows);
284 static Accessibility_LongSeq *
285 impl_getSelectedColumns (PortableServer_Servant _servant,
286 CORBA_Environment * ev)
288 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
289 gint *selectedColumns;
291 Accessibility_LongSeq *retval;
293 length = atk_table_get_selected_columns (ATK_TABLE(table->atko), &selectedColumns);
295 g_return_val_if_fail (length, NULL);
297 retval = Accessibility_LongSeq__alloc ();
298 retval->_maximum = retval->_length = (CORBA_long) length;
299 retval->_buffer = Accessibility_LongSeq_allocbuf (length);
302 retval->_buffer[length] = (CORBA_long) selectedColumns[length];
303 g_free ((gpointer) selectedColumns);
310 impl_isRowSelected (PortableServer_Servant _servant,
311 const CORBA_long row,
312 CORBA_Environment * ev)
314 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
315 return (CORBA_boolean)
316 atk_table_is_row_selected (ATK_TABLE(table->atko), (gint) row);
322 impl_isColumnSelected (PortableServer_Servant _servant,
323 const CORBA_long column,
324 CORBA_Environment * ev)
326 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
327 return (CORBA_boolean)
328 atk_table_is_column_selected (ATK_TABLE(table->atko), (gint) column);
334 impl_isSelected (PortableServer_Servant _servant,
335 const CORBA_long row,
336 const CORBA_long column,
337 CORBA_Environment * ev)
339 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
340 return (CORBA_boolean)
341 atk_table_is_selected (ATK_TABLE(table->atko),
342 (gint) row, (gint) column);
346 spi_table_class_init (SpiTableClass *klass)
348 GObjectClass * object_class = (GObjectClass *) klass;
349 POA_Accessibility_Table__epv *epv = &klass->epv;
350 parent_class = g_type_class_peek_parent (klass);
352 object_class->finalize = spi_table_finalize;
355 /* Initialize epv table */
357 epv->_get_caption = impl__get_caption;
358 epv->_get_summary = impl__get_summary;
359 epv->_get_nRows = impl__get_nRows;
360 epv->_get_nColumns = impl__get_nColumns;
361 epv->getAccessibleAt = impl_getAccessibleAt;
362 epv->getIndexAt = impl_getIndexAt;
363 epv->getRowAtIndex = impl_getRowAtIndex;
364 epv->getColumnAtIndex = impl_getColumnAtIndex;
365 epv->getRowDescription = impl_getRowDescription;
366 epv->getColumnDescription = impl_getColumnDescription;
367 epv->getRowExtentAt = impl_getRowExtentAt;
368 epv->getColumnExtentAt = impl_getColumnExtentAt;
369 epv->getRowHeader = impl_getRowHeader;
370 epv->getColumnHeader = impl_getColumnHeader;
371 epv->getSelectedRows = impl_getSelectedRows;
372 epv->getSelectedColumns = impl_getSelectedColumns;
373 epv->isRowSelected = impl_isRowSelected;
374 epv->isColumnSelected = impl_isColumnSelected;
375 epv->isSelected = impl_isSelected;
379 spi_table_init (SpiTable *table)
383 BONOBO_TYPE_FUNC_FULL (SpiTable,