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.
24 * component.c : bonobo wrapper for accessible component implementation
28 #include <bonobo/Bonobo.h>
33 * This pulls the CORBA definitions for the "Accessibility::Accessible" server
35 #include <libspi/Accessibility.h>
38 * This pulls the definition of the SpiTable bonobo object
43 * Static function declarations
47 spi_table_class_init (SpiTableClass *klass);
49 spi_table_init (SpiTable *table);
51 spi_table_finalize (GObject *obj);
52 static Accessibility_Accessible
53 impl__get_caption (PortableServer_Servant _servant,
54 CORBA_Environment * ev);
55 static Accessibility_Accessible
56 impl__get_summary (PortableServer_Servant _servant,
57 CORBA_Environment * ev);
59 impl__get_nRows (PortableServer_Servant _servant,
60 CORBA_Environment * ev);
62 impl__get_nRows (PortableServer_Servant _servant,
63 CORBA_Environment * ev);
65 impl__get_nColumns (PortableServer_Servant _servant,
66 CORBA_Environment * ev);
67 static Accessibility_Accessible
68 impl_getAccessibleAt (PortableServer_Servant _servant,
70 const CORBA_long column,
71 CORBA_Environment * ev);
73 impl_getIndexAt (PortableServer_Servant _servant,
74 const CORBA_long row, const CORBA_long column,
75 CORBA_Environment * ev);
77 impl_getRowAtIndex (PortableServer_Servant _servant,
78 const CORBA_long index,
79 CORBA_Environment * ev);
81 impl_getColumnAtIndex (PortableServer_Servant _servant,
82 const CORBA_long index,
83 CORBA_Environment * ev);
85 impl_getRowDescription (PortableServer_Servant _servant,
87 CORBA_Environment * ev);
89 impl_getColumnDescription (PortableServer_Servant _servant,
90 const CORBA_long column,
91 CORBA_Environment * ev);
93 impl_getRowExtentAt (PortableServer_Servant _servant,
95 const CORBA_long column,
96 CORBA_Environment * ev);
98 impl_getColumnExtentAt (PortableServer_Servant _servant,
100 const CORBA_long column,
101 CORBA_Environment * ev);
102 static Accessibility_Table
103 impl_getRowHeader (PortableServer_Servant _servant,
104 const CORBA_long row,
105 CORBA_Environment * ev);
106 static Accessibility_Table
107 impl_getColumnHeader (PortableServer_Servant _servant,
108 const CORBA_long column,
109 CORBA_Environment * ev);
110 static Accessibility_LongSeq *
111 impl_getSelectedRows (PortableServer_Servant _servant,
112 CORBA_Environment * ev);
113 static Accessibility_LongSeq *
114 impl_getSelectedColumns (PortableServer_Servant _servant,
115 CORBA_Environment * ev);
117 impl_isRowSelected (PortableServer_Servant _servant,
118 const CORBA_long row,
119 CORBA_Environment * ev);
121 impl_isColumnSelected (PortableServer_Servant _servant,
122 const CORBA_long column,
123 CORBA_Environment * ev);
125 impl_isSelected (PortableServer_Servant _servant,
126 const CORBA_long row,
127 const CORBA_long column,
128 CORBA_Environment * ev);
131 static GObjectClass *parent_class;
134 spi_table_get_type (void)
136 static GType type = 0;
139 static const GTypeInfo tinfo = {
140 sizeof (SpiTableClass),
141 (GBaseInitFunc) NULL,
142 (GBaseFinalizeFunc) NULL,
143 (GClassInitFunc) spi_table_class_init,
144 (GClassFinalizeFunc) NULL,
145 NULL, /* class data */
148 (GInstanceInitFunc) spi_table_init,
149 NULL /* value table */
153 * Bonobo_type_unique auto-generates a load of
154 * CORBA structures for us. All derived types must
155 * use bonobo_type_unique.
157 type = bonobo_type_unique (
159 POA_Accessibility_Table__init,
161 G_STRUCT_OFFSET (SpiTableClass, epv),
163 "SpiAccessibleTable");
170 spi_table_class_init (SpiTableClass *klass)
172 GObjectClass * object_class = (GObjectClass *) klass;
173 POA_Accessibility_Table__epv *epv = &klass->epv;
174 parent_class = g_type_class_peek_parent (klass);
176 object_class->finalize = spi_table_finalize;
179 /* Initialize epv table */
181 epv->_get_caption = impl__get_caption;
182 epv->_get_summary = impl__get_summary;
183 epv->_get_nRows = impl__get_nRows;
184 epv->_get_nColumns = impl__get_nColumns;
185 epv->getAccessibleAt = impl_getAccessibleAt;
186 epv->getIndexAt = impl_getIndexAt;
187 epv->getRowAtIndex = impl_getRowAtIndex;
188 epv->getColumnAtIndex = impl_getColumnAtIndex;
189 epv->getRowDescription = impl_getRowDescription;
190 epv->getColumnDescription = impl_getColumnDescription;
191 epv->getRowExtentAt = impl_getRowExtentAt;
192 epv->getColumnExtentAt = impl_getColumnExtentAt;
193 epv->getRowHeader = impl_getRowHeader;
194 epv->getColumnHeader = impl_getColumnHeader;
195 epv->getSelectedRows = impl_getSelectedRows;
196 epv->getSelectedColumns = impl_getSelectedColumns;
197 epv->isRowSelected = impl_isRowSelected;
198 epv->isColumnSelected = impl_isColumnSelected;
199 epv->isSelected = impl_isSelected;
203 spi_table_init (SpiTable *table)
208 spi_table_finalize (GObject *obj)
210 SpiTable *table = SPI_TABLE (obj);
211 g_object_unref (table->atko);
213 parent_class->finalize (obj);
217 spi_table_interface_new (AtkObject *obj)
219 SpiTable *new_table =
220 SPI_TABLE(g_object_new (SPI_TABLE_TYPE, NULL));
221 new_table->atko = obj;
228 static Accessibility_Accessible
229 impl__get_caption (PortableServer_Servant _servant,
230 CORBA_Environment * ev)
232 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
233 AtkObject *atk_object;
234 Accessibility_Accessible rv;
236 atk_object = atk_table_get_caption (ATK_TABLE(table-> atko));
237 rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(atk_object)));
238 return CORBA_Object_duplicate (rv, ev);
243 static Accessibility_Accessible
244 impl__get_summary (PortableServer_Servant _servant,
245 CORBA_Environment * ev)
247 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
248 AtkObject *atk_object;
249 Accessibility_Accessible rv;
251 atk_object = atk_table_get_summary (ATK_TABLE(table->atko));
252 rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(atk_object)));
253 return CORBA_Object_duplicate (rv, ev);
259 impl__get_nRows (PortableServer_Servant _servant,
260 CORBA_Environment * ev)
262 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
264 atk_table_get_n_rows (ATK_TABLE(table->atko) );
270 impl__get_nColumns (PortableServer_Servant _servant,
271 CORBA_Environment * ev)
273 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
275 atk_table_get_n_columns (ATK_TABLE(table->atko));
280 static Accessibility_Accessible
281 impl_getAccessibleAt (PortableServer_Servant _servant,
282 const CORBA_long row,
283 const CORBA_long column,
284 CORBA_Environment * ev)
286 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
287 AtkObject *atk_object;
288 Accessibility_Accessible rv;
290 atk_object = atk_table_ref_at (ATK_TABLE(table->atko),
291 (gint) row, (gint) column);
292 rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(atk_object)));
293 return CORBA_Object_duplicate (rv, ev);
299 impl_getIndexAt (PortableServer_Servant _servant,
300 const CORBA_long row, const CORBA_long column,
301 CORBA_Environment * ev)
303 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
305 atk_table_get_index_at (ATK_TABLE(table->atko),
306 (gint) row, (gint) column);
312 impl_getRowAtIndex (PortableServer_Servant _servant,
313 const CORBA_long index,
314 CORBA_Environment * ev)
316 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
318 atk_table_get_row_at_index (ATK_TABLE(table->atko), (gint) index);
324 impl_getColumnAtIndex (PortableServer_Servant _servant,
325 const CORBA_long index,
326 CORBA_Environment * ev)
328 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
330 atk_table_get_column_at_index (ATK_TABLE(table->atko), (gint) index);
336 impl_getRowDescription (PortableServer_Servant _servant,
337 const CORBA_long row,
338 CORBA_Environment * ev)
340 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
343 rv = atk_table_get_row_description (ATK_TABLE(table->atko), (gint) row);
345 return CORBA_string_dup (rv);
347 return CORBA_string_dup ("");
353 impl_getColumnDescription (PortableServer_Servant _servant,
354 const CORBA_long column,
355 CORBA_Environment * ev)
357 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
360 rv = atk_table_get_column_description (ATK_TABLE(table->atko), (gint) column);
362 return CORBA_string_dup (rv);
364 return CORBA_string_dup ("");
370 impl_getRowExtentAt (PortableServer_Servant _servant,
371 const CORBA_long row,
372 const CORBA_long column,
373 CORBA_Environment * ev)
375 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
377 atk_table_get_row_extent_at (ATK_TABLE(table->atko),
378 (gint) row, (gint) column);
384 impl_getColumnExtentAt (PortableServer_Servant _servant,
385 const CORBA_long row,
386 const CORBA_long column,
387 CORBA_Environment * ev)
389 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
391 atk_table_get_column_extent_at (ATK_TABLE(table->atko),
392 (gint) row, (gint) column);
397 static Accessibility_Table
398 impl_getRowHeader (PortableServer_Servant _servant,
399 const CORBA_long row,
400 CORBA_Environment * ev)
402 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
404 Accessibility_Table rv;
406 header = atk_table_get_row_header (ATK_TABLE(table->atko), (gint) row);
407 rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(header)));
408 return CORBA_Object_duplicate (rv, ev);
413 static Accessibility_Table
414 impl_getColumnHeader (PortableServer_Servant _servant,
415 const CORBA_long column,
416 CORBA_Environment * ev)
418 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
420 Accessibility_Table rv;
422 header = atk_table_get_column_header (ATK_TABLE(table->atko), (gint) column);
423 rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(header)));
424 return CORBA_Object_duplicate (rv, ev);
429 static Accessibility_LongSeq *
430 impl_getSelectedRows (PortableServer_Servant _servant,
431 CORBA_Environment * ev)
433 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
436 Accessibility_LongSeq *retval;
438 length = atk_table_get_selected_rows (ATK_TABLE(table->atko), &selectedRows);
440 g_return_val_if_fail (length, NULL);
441 retval = Accessibility_LongSeq__alloc ();
442 retval->_maximum = retval->_length = (CORBA_long) length;
443 retval->_buffer = Accessibility_LongSeq_allocbuf (length);
446 retval->_buffer[length] = (CORBA_long) selectedRows[length];
447 g_free ((gpointer) selectedRows);
453 static Accessibility_LongSeq *
454 impl_getSelectedColumns (PortableServer_Servant _servant,
455 CORBA_Environment * ev)
457 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
458 gint *selectedColumns;
460 Accessibility_LongSeq *retval;
462 length = atk_table_get_selected_columns (ATK_TABLE(table->atko), &selectedColumns);
464 g_return_val_if_fail (length, NULL);
466 retval = Accessibility_LongSeq__alloc ();
467 retval->_maximum = retval->_length = (CORBA_long) length;
468 retval->_buffer = Accessibility_LongSeq_allocbuf (length);
471 retval->_buffer[length] = (CORBA_long) selectedColumns[length];
472 g_free ((gpointer) selectedColumns);
479 impl_isRowSelected (PortableServer_Servant _servant,
480 const CORBA_long row,
481 CORBA_Environment * ev)
483 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
484 return (CORBA_boolean)
485 atk_table_is_row_selected (ATK_TABLE(table->atko), (gint) row);
491 impl_isColumnSelected (PortableServer_Servant _servant,
492 const CORBA_long column,
493 CORBA_Environment * ev)
495 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
496 return (CORBA_boolean)
497 atk_table_is_column_selected (ATK_TABLE(table->atko), (gint) column);
503 impl_isSelected (PortableServer_Servant _servant,
504 const CORBA_long row,
505 const CORBA_long column,
506 CORBA_Environment * ev)
508 SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
509 return (CORBA_boolean)
510 atk_table_is_selected (ATK_TABLE(table->atko),
511 (gint) row, (gint) column);