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 /* Static function declarations */
33 spi_table_class_init (SpiTableClass *klass);
35 spi_table_init (SpiTable *table);
37 spi_table_finalize (GObject *obj);
38 static Accessibility_Accessible
39 impl__get_caption (PortableServer_Servant _servant,
40 CORBA_Environment * ev);
41 static Accessibility_Accessible
42 impl__get_summary (PortableServer_Servant _servant,
43 CORBA_Environment * ev);
45 impl__get_nRows (PortableServer_Servant _servant,
46 CORBA_Environment * ev);
48 impl__get_nRows (PortableServer_Servant _servant,
49 CORBA_Environment * ev);
51 impl__get_nColumns (PortableServer_Servant _servant,
52 CORBA_Environment * ev);
53 static Accessibility_Accessible
54 impl_getAccessibleAt (PortableServer_Servant _servant,
56 const CORBA_long column,
57 CORBA_Environment * ev);
59 impl_getIndexAt (PortableServer_Servant _servant,
60 const CORBA_long row, const CORBA_long column,
61 CORBA_Environment * ev);
63 impl_getRowAtIndex (PortableServer_Servant _servant,
64 const CORBA_long index,
65 CORBA_Environment * ev);
67 impl_getColumnAtIndex (PortableServer_Servant _servant,
68 const CORBA_long index,
69 CORBA_Environment * ev);
71 impl_getRowDescription (PortableServer_Servant _servant,
73 CORBA_Environment * ev);
75 impl_getColumnDescription (PortableServer_Servant _servant,
76 const CORBA_long column,
77 CORBA_Environment * ev);
79 impl_getRowExtentAt (PortableServer_Servant _servant,
81 const CORBA_long column,
82 CORBA_Environment * ev);
84 impl_getColumnExtentAt (PortableServer_Servant _servant,
86 const CORBA_long column,
87 CORBA_Environment * ev);
88 static Accessibility_Table
89 impl_getRowHeader (PortableServer_Servant _servant,
91 CORBA_Environment * ev);
92 static Accessibility_Table
93 impl_getColumnHeader (PortableServer_Servant _servant,
94 const CORBA_long column,
95 CORBA_Environment * ev);
96 static Accessibility_LongSeq *
97 impl_getSelectedRows (PortableServer_Servant _servant,
98 CORBA_Environment * ev);
99 static Accessibility_LongSeq *
100 impl_getSelectedColumns (PortableServer_Servant _servant,
101 CORBA_Environment * ev);
103 impl_isRowSelected (PortableServer_Servant _servant,
104 const CORBA_long row,
105 CORBA_Environment * ev);
107 impl_isColumnSelected (PortableServer_Servant _servant,
108 const CORBA_long column,
109 CORBA_Environment * ev);
111 impl_isSelected (PortableServer_Servant _servant,
112 const CORBA_long row,
113 const CORBA_long column,
114 CORBA_Environment * ev);
117 static GObjectClass *parent_class;
120 spi_table_get_type (void)
122 static GType type = 0;
125 static const GTypeInfo tinfo = {
126 sizeof (SpiTableClass),
127 (GBaseInitFunc) NULL,
128 (GBaseFinalizeFunc) NULL,
129 (GClassInitFunc) spi_table_class_init,
130 (GClassFinalizeFunc) NULL,
131 NULL, /* class data */
134 (GInstanceInitFunc) spi_table_init,
135 NULL /* value table */
139 * Bonobo_type_unique auto-generates a load of
140 * CORBA structures for us. All derived types must
141 * use bonobo_type_unique.
143 type = bonobo_type_unique (
145 POA_Accessibility_Table__init,
147 G_STRUCT_OFFSET (SpiTableClass, epv),
149 "SpiAccessibleTable");
156 spi_table_class_init (SpiTableClass *klass)
158 GObjectClass * object_class = (GObjectClass *) klass;
159 POA_Accessibility_Table__epv *epv = &klass->epv;
160 parent_class = g_type_class_peek_parent (klass);
162 object_class->finalize = spi_table_finalize;
165 /* Initialize epv table */
167 epv->_get_caption = impl__get_caption;
168 epv->_get_summary = impl__get_summary;
169 epv->_get_nRows = impl__get_nRows;
170 epv->_get_nColumns = impl__get_nColumns;
171 epv->getAccessibleAt = impl_getAccessibleAt;
172 epv->getIndexAt = impl_getIndexAt;
173 epv->getRowAtIndex = impl_getRowAtIndex;
174 epv->getColumnAtIndex = impl_getColumnAtIndex;
175 epv->getRowDescription = impl_getRowDescription;
176 epv->getColumnDescription = impl_getColumnDescription;
177 epv->getRowExtentAt = impl_getRowExtentAt;
178 epv->getColumnExtentAt = impl_getColumnExtentAt;
179 epv->getRowHeader = impl_getRowHeader;
180 epv->getColumnHeader = impl_getColumnHeader;
181 epv->getSelectedRows = impl_getSelectedRows;
182 epv->getSelectedColumns = impl_getSelectedColumns;
183 epv->isRowSelected = impl_isRowSelected;
184 epv->isColumnSelected = impl_isColumnSelected;
185 epv->isSelected = impl_isSelected;
189 spi_table_init (SpiTable *table)
194 spi_table_finalize (GObject *obj)
196 SpiTable *table = SPI_TABLE (obj);
197 g_object_unref (table->atko);
199 parent_class->finalize (obj);
203 spi_table_interface_new (AtkObject *obj)
205 SpiTable *new_table =
206 SPI_TABLE(g_object_new (SPI_TABLE_TYPE, NULL));
207 new_table->atko = obj;
214 static Accessibility_Accessible
215 impl__get_caption (PortableServer_Servant _servant,
216 CORBA_Environment * ev)
218 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
219 AtkObject *atk_object;
220 Accessibility_Accessible rv;
222 atk_object = atk_table_get_caption (ATK_TABLE(table-> atko));
223 rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(atk_object)));
224 return CORBA_Object_duplicate (rv, ev);
229 static Accessibility_Accessible
230 impl__get_summary (PortableServer_Servant _servant,
231 CORBA_Environment * ev)
233 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
234 AtkObject *atk_object;
235 Accessibility_Accessible rv;
237 atk_object = atk_table_get_summary (ATK_TABLE(table->atko));
238 rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(atk_object)));
239 return CORBA_Object_duplicate (rv, ev);
245 impl__get_nRows (PortableServer_Servant _servant,
246 CORBA_Environment * ev)
248 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
250 atk_table_get_n_rows (ATK_TABLE(table->atko) );
256 impl__get_nColumns (PortableServer_Servant _servant,
257 CORBA_Environment * ev)
259 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
261 atk_table_get_n_columns (ATK_TABLE(table->atko));
266 static Accessibility_Accessible
267 impl_getAccessibleAt (PortableServer_Servant _servant,
268 const CORBA_long row,
269 const CORBA_long column,
270 CORBA_Environment * ev)
272 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
273 AtkObject *atk_object;
274 Accessibility_Accessible rv;
276 atk_object = atk_table_ref_at (ATK_TABLE(table->atko),
277 (gint) row, (gint) column);
278 rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(atk_object)));
279 return CORBA_Object_duplicate (rv, ev);
285 impl_getIndexAt (PortableServer_Servant _servant,
286 const CORBA_long row, const CORBA_long column,
287 CORBA_Environment * ev)
289 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
291 atk_table_get_index_at (ATK_TABLE(table->atko),
292 (gint) row, (gint) column);
298 impl_getRowAtIndex (PortableServer_Servant _servant,
299 const CORBA_long index,
300 CORBA_Environment * ev)
302 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
304 atk_table_get_row_at_index (ATK_TABLE(table->atko), (gint) index);
310 impl_getColumnAtIndex (PortableServer_Servant _servant,
311 const CORBA_long index,
312 CORBA_Environment * ev)
314 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
316 atk_table_get_column_at_index (ATK_TABLE(table->atko), (gint) index);
322 impl_getRowDescription (PortableServer_Servant servant,
323 const CORBA_long row,
324 CORBA_Environment *ev)
329 table = SPI_TABLE (bonobo_object_from_servant (servant));
331 rv = atk_table_get_row_description (ATK_TABLE (table->atko), row);
334 return CORBA_string_dup (rv);
336 return CORBA_string_dup ("");
342 impl_getColumnDescription (PortableServer_Servant servant,
343 const CORBA_long column,
344 CORBA_Environment *ev)
349 table = SPI_TABLE (bonobo_object_from_servant (servant));
351 rv = atk_table_get_row_description (ATK_TABLE (table->atko), column);
354 return CORBA_string_dup (rv);
356 return CORBA_string_dup ("");
362 impl_getRowExtentAt (PortableServer_Servant _servant,
363 const CORBA_long row,
364 const CORBA_long column,
365 CORBA_Environment * ev)
367 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
369 atk_table_get_row_extent_at (ATK_TABLE(table->atko),
370 (gint) row, (gint) column);
376 impl_getColumnExtentAt (PortableServer_Servant _servant,
377 const CORBA_long row,
378 const CORBA_long column,
379 CORBA_Environment * ev)
381 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
383 atk_table_get_column_extent_at (ATK_TABLE(table->atko),
384 (gint) row, (gint) column);
389 static Accessibility_Table
390 impl_getRowHeader (PortableServer_Servant _servant,
391 const CORBA_long row,
392 CORBA_Environment * ev)
394 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
396 Accessibility_Table rv;
398 header = atk_table_get_row_header (ATK_TABLE(table->atko), (gint) row);
399 rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(header)));
400 return CORBA_Object_duplicate (rv, ev);
405 static Accessibility_Table
406 impl_getColumnHeader (PortableServer_Servant _servant,
407 const CORBA_long column,
408 CORBA_Environment * ev)
410 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
412 Accessibility_Table rv;
414 header = atk_table_get_column_header (ATK_TABLE(table->atko), (gint) column);
415 rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(header)));
416 return CORBA_Object_duplicate (rv, ev);
421 static Accessibility_LongSeq *
422 impl_getSelectedRows (PortableServer_Servant _servant,
423 CORBA_Environment * ev)
425 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
428 Accessibility_LongSeq *retval;
430 length = atk_table_get_selected_rows (ATK_TABLE(table->atko), &selectedRows);
432 g_return_val_if_fail (length, NULL);
433 retval = Accessibility_LongSeq__alloc ();
434 retval->_maximum = retval->_length = (CORBA_long) length;
435 retval->_buffer = Accessibility_LongSeq_allocbuf (length);
438 retval->_buffer[length] = (CORBA_long) selectedRows[length];
439 g_free ((gpointer) selectedRows);
445 static Accessibility_LongSeq *
446 impl_getSelectedColumns (PortableServer_Servant _servant,
447 CORBA_Environment * ev)
449 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
450 gint *selectedColumns;
452 Accessibility_LongSeq *retval;
454 length = atk_table_get_selected_columns (ATK_TABLE(table->atko), &selectedColumns);
456 g_return_val_if_fail (length, NULL);
458 retval = Accessibility_LongSeq__alloc ();
459 retval->_maximum = retval->_length = (CORBA_long) length;
460 retval->_buffer = Accessibility_LongSeq_allocbuf (length);
463 retval->_buffer[length] = (CORBA_long) selectedColumns[length];
464 g_free ((gpointer) selectedColumns);
471 impl_isRowSelected (PortableServer_Servant _servant,
472 const CORBA_long row,
473 CORBA_Environment * ev)
475 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
476 return (CORBA_boolean)
477 atk_table_is_row_selected (ATK_TABLE(table->atko), (gint) row);
483 impl_isColumnSelected (PortableServer_Servant _servant,
484 const CORBA_long column,
485 CORBA_Environment * ev)
487 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
488 return (CORBA_boolean)
489 atk_table_is_column_selected (ATK_TABLE(table->atko), (gint) column);
495 impl_isSelected (PortableServer_Servant _servant,
496 const CORBA_long row,
497 const CORBA_long column,
498 CORBA_Environment * ev)
500 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
501 return (CORBA_boolean)
502 atk_table_is_selected (ATK_TABLE(table->atko),
503 (gint) row, (gint) column);