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 Table bonobo object
43 * Static function declarations
47 table_class_init (TableClass *klass);
49 table_init (Table *table);
51 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 table_get_type (void)
136 static GType type = 0;
139 static const GTypeInfo tinfo = {
141 (GBaseInitFunc) NULL,
142 (GBaseFinalizeFunc) NULL,
143 (GClassInitFunc) table_class_init,
144 (GClassFinalizeFunc) NULL,
145 NULL, /* class data */
148 (GInstanceInitFunc) 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 (TableClass, epv),
170 table_class_init (TableClass *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 = 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 table_init (Table *table)
208 table_finalize (GObject *obj)
210 Table *table = TABLE (obj);
211 g_object_unref (table->atko);
213 parent_class->finalize (obj);
217 table_interface_new (AtkObject *obj)
220 TABLE(g_object_new (TABLE_TYPE, NULL));
221 new_table->atko = obj;
228 static Accessibility_Accessible
229 impl__get_caption (PortableServer_Servant _servant,
230 CORBA_Environment * ev)
232 Table *table = TABLE (bonobo_object_from_servant (_servant));
233 AtkObject *atk_object;
234 Accessibility_Accessible rv;
236 atk_object = g_object_new (ATK_TYPE_OBJECT, NULL);
237 atk_object_set_name (atk_object, atk_table_get_caption (ATK_TABLE(table-> atko)));
238 rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(atk_object)));
244 static Accessibility_Accessible
245 impl__get_summary (PortableServer_Servant _servant,
246 CORBA_Environment * ev)
248 Table *table = TABLE (bonobo_object_from_servant (_servant));
249 AtkObject *atk_object;
250 Accessibility_Accessible rv;
252 atk_object = atk_table_get_summary (ATK_TABLE(table->atko));
253 rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(atk_object)));
260 impl__get_nRows (PortableServer_Servant _servant,
261 CORBA_Environment * ev)
263 Table *table = TABLE (bonobo_object_from_servant (_servant));
265 atk_table_get_n_rows (ATK_TABLE(table->atko) );
271 impl__get_nColumns (PortableServer_Servant _servant,
272 CORBA_Environment * ev)
274 Table *table = TABLE (bonobo_object_from_servant (_servant));
276 atk_table_get_n_columns (ATK_TABLE(table->atko));
281 static Accessibility_Accessible
282 impl_getAccessibleAt (PortableServer_Servant _servant,
283 const CORBA_long row,
284 const CORBA_long column,
285 CORBA_Environment * ev)
287 Table *table = TABLE (bonobo_object_from_servant (_servant));
288 AtkObject *atk_object;
289 Accessibility_Accessible rv;
291 atk_object = atk_table_ref_at (ATK_TABLE(table->atko),
292 (gint) row, (gint) column);
293 rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(atk_object)));
300 impl_getIndexAt (PortableServer_Servant _servant,
301 const CORBA_long row, const CORBA_long column,
302 CORBA_Environment * ev)
304 Table *table = TABLE (bonobo_object_from_servant (_servant));
306 atk_table_get_index_at (ATK_TABLE(table->atko),
307 (gint) row, (gint) column);
313 impl_getRowAtIndex (PortableServer_Servant _servant,
314 const CORBA_long index,
315 CORBA_Environment * ev)
317 Table *table = TABLE (bonobo_object_from_servant (_servant));
319 atk_table_get_row_at_index (ATK_TABLE(table->atko), (gint) index);
325 impl_getColumnAtIndex (PortableServer_Servant _servant,
326 const CORBA_long index,
327 CORBA_Environment * ev)
329 Table *table = TABLE (bonobo_object_from_servant (_servant));
331 atk_table_get_column_at_index (ATK_TABLE(table->atko), (gint) index);
337 impl_getRowDescription (PortableServer_Servant _servant,
338 const CORBA_long row,
339 CORBA_Environment * ev)
341 Table *table = TABLE (bonobo_object_from_servant (_servant));
342 return CORBA_string_dup (
343 atk_table_get_row_description (ATK_TABLE(table->atko), (gint) row));
349 impl_getColumnDescription (PortableServer_Servant _servant,
350 const CORBA_long column,
351 CORBA_Environment * ev)
353 Table *table = TABLE (bonobo_object_from_servant (_servant));
354 return CORBA_string_dup (
355 atk_table_get_column_description (ATK_TABLE(table->atko), (gint) column));
361 impl_getRowExtentAt (PortableServer_Servant _servant,
362 const CORBA_long row,
363 const CORBA_long column,
364 CORBA_Environment * ev)
366 Table *table = TABLE (bonobo_object_from_servant (_servant));
368 atk_table_get_row_extent_at (ATK_TABLE(table->atko),
369 (gint) row, (gint) column);
375 impl_getColumnExtentAt (PortableServer_Servant _servant,
376 const CORBA_long row,
377 const CORBA_long column,
378 CORBA_Environment * ev)
380 Table *table = TABLE (bonobo_object_from_servant (_servant));
382 atk_table_get_column_extent_at (ATK_TABLE(table->atko),
383 (gint) row, (gint) column);
388 static Accessibility_Table
389 impl_getRowHeader (PortableServer_Servant _servant,
390 const CORBA_long row,
391 CORBA_Environment * ev)
393 Table *table = TABLE (bonobo_object_from_servant (_servant));
395 Accessibility_Table rv;
397 header = atk_table_get_row_header (ATK_TABLE(table->atko), (gint) row);
398 rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(header)));
404 static Accessibility_Table
405 impl_getColumnHeader (PortableServer_Servant _servant,
406 const CORBA_long column,
407 CORBA_Environment * ev)
409 Table *table = TABLE (bonobo_object_from_servant (_servant));
411 Accessibility_Table rv;
413 header = atk_table_get_column_header (ATK_TABLE(table->atko), (gint) column);
414 rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(header)));
420 static Accessibility_LongSeq *
421 impl_getSelectedRows (PortableServer_Servant _servant,
422 CORBA_Environment * ev)
424 Table *table = TABLE (bonobo_object_from_servant (_servant));
427 Accessibility_LongSeq *retval;
429 length = atk_table_get_selected_rows (ATK_TABLE(table->atko), &selectedRows);
431 g_return_val_if_fail (length, NULL);
432 retval = Accessibility_LongSeq__alloc ();
433 retval->_maximum = retval->_length = (CORBA_long) length;
434 retval->_buffer = Accessibility_LongSeq_allocbuf (length);
437 retval->_buffer[length] = (CORBA_long) selectedRows[length];
438 g_free ((gpointer) selectedRows);
444 static Accessibility_LongSeq *
445 impl_getSelectedColumns (PortableServer_Servant _servant,
446 CORBA_Environment * ev)
448 Table *table = TABLE (bonobo_object_from_servant (_servant));
449 gint *selectedColumns;
451 Accessibility_LongSeq *retval;
453 length = atk_table_get_selected_columns (ATK_TABLE(table->atko), &selectedColumns);
455 g_return_val_if_fail (length, NULL);
457 retval = Accessibility_LongSeq__alloc ();
458 retval->_maximum = retval->_length = (CORBA_long) length;
459 retval->_buffer = Accessibility_LongSeq_allocbuf (length);
462 retval->_buffer[length] = (CORBA_long) selectedColumns[length];
463 g_free ((gpointer) selectedColumns);
470 impl_isRowSelected (PortableServer_Servant _servant,
471 const CORBA_long row,
472 CORBA_Environment * ev)
474 Table *table = TABLE (bonobo_object_from_servant (_servant));
475 return (CORBA_boolean)
476 atk_table_is_row_selected (ATK_TABLE(table->atko), (gint) row);
482 impl_isColumnSelected (PortableServer_Servant _servant,
483 const CORBA_long column,
484 CORBA_Environment * ev)
486 Table *table = TABLE (bonobo_object_from_servant (_servant));
487 return (CORBA_boolean)
488 atk_table_is_column_selected (ATK_TABLE(table->atko), (gint) column);
494 impl_isSelected (PortableServer_Servant _servant,
495 const CORBA_long row,
496 const CORBA_long column,
497 CORBA_Environment * ev)
499 Table *table = TABLE (bonobo_object_from_servant (_servant));
500 return (CORBA_boolean)
501 atk_table_is_selected (ATK_TABLE(table->atko),
502 (gint) row, (gint) column);