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>
34 * This pulls the CORBA definitions for the "Accessibility::Accessible" server
36 #include <libspi/Accessibility.h>
39 * This pulls the definition of the Text bonobo object
44 * Static function declarations
48 text_class_init (TextClass *klass);
50 text_init (Text *text);
52 text_finalize (GObject *obj);
54 impl_getText (PortableServer_Servant _servant,
55 const CORBA_long startOffset,
56 const CORBA_long endOffset,
57 CORBA_Environment * ev);
59 impl_getTextAfterOffset (PortableServer_Servant _servant,
60 const CORBA_long offset,
62 Accessibility_TEXT_BOUNDARY_TYPE
63 type, CORBA_long * startOffset,
64 CORBA_long * endOffset,
65 CORBA_Environment * ev);
67 impl_getTextAtOffset (PortableServer_Servant _servant,
68 const CORBA_long offset,
69 const Accessibility_TEXT_BOUNDARY_TYPE type,
70 CORBA_long * startOffset,
71 CORBA_long * endOffset,
72 CORBA_Environment * ev);
74 impl_getCharacterAtOffset (PortableServer_Servant _servant,
75 const CORBA_long offset,
76 CORBA_Environment * ev);
78 impl_getTextBeforeOffset (PortableServer_Servant _servant,
79 const CORBA_long offset,
81 Accessibility_TEXT_BOUNDARY_TYPE
82 type, CORBA_long * startOffset,
83 CORBA_long * endOffset,
84 CORBA_Environment * ev);
86 impl__get_caretOffset (PortableServer_Servant _servant,
87 CORBA_Environment * ev);
89 impl_getAttributes (PortableServer_Servant _servant,
90 const CORBA_long offset,
91 CORBA_long * startOffset,
92 CORBA_long * endOffset,
93 CORBA_Environment * ev);
95 impl_getCharacterExtents (PortableServer_Servant _servant,
96 const CORBA_long offset, CORBA_long * x,
97 CORBA_long * y, CORBA_long * width,
99 const CORBA_short coordType,
100 CORBA_Environment * ev);
102 impl__get_characterCount (PortableServer_Servant _servant,
103 CORBA_Environment * ev);
105 impl_getOffsetAtPoint (PortableServer_Servant _servant,
106 const CORBA_long x, const CORBA_long y,
107 const CORBA_short coordType,
108 CORBA_Environment * ev);
110 impl_getNSelections (PortableServer_Servant _servant,
111 CORBA_Environment * ev);
113 impl_getSelection (PortableServer_Servant _servant,
114 const CORBA_long selectionNum,
115 CORBA_long * startOffset, CORBA_long * endOffset,
116 CORBA_Environment * ev);
118 impl_addSelection (PortableServer_Servant _servant,
119 const CORBA_long startOffset,
120 const CORBA_long endOffset,
121 CORBA_Environment * ev);
123 impl_removeSelection (PortableServer_Servant _servant,
124 const CORBA_long selectionNum,
125 CORBA_Environment * ev);
127 impl_setSelection (PortableServer_Servant _servant,
128 const CORBA_long selectionNum,
129 const CORBA_long startOffset,
130 const CORBA_long endOffset,
131 CORBA_Environment * ev);
133 impl_setCaretOffset (PortableServer_Servant _servant,
134 const CORBA_long value,
135 CORBA_Environment * ev);
139 static GObjectClass *parent_class;
144 static GType type = 0;
147 static const GTypeInfo tinfo = {
149 (GBaseInitFunc) NULL,
150 (GBaseFinalizeFunc) NULL,
151 (GClassInitFunc) text_class_init,
152 (GClassFinalizeFunc) NULL,
153 NULL, /* class data */
156 (GInstanceInitFunc) text_init,
157 NULL /* value table */
161 * Bonobo_type_unique auto-generates a load of
162 * CORBA structures for us. All derived types must
163 * use bonobo_type_unique.
165 type = bonobo_type_unique (
167 POA_Accessibility_Text__init,
169 G_STRUCT_OFFSET (TextClass, epv),
178 text_class_init (TextClass *klass)
180 GObjectClass * object_class = (GObjectClass *) klass;
181 POA_Accessibility_Text__epv *epv = &klass->epv;
182 parent_class = g_type_class_peek_parent (klass);
184 object_class->finalize = text_finalize;
187 /* Initialize epv table */
189 epv->getText = impl_getText;
190 epv->getTextAfterOffset = impl_getTextAfterOffset;
191 epv->getCharacterAtOffset = impl_getCharacterAtOffset;
192 epv->getTextAtOffset = impl_getTextAtOffset;
193 epv->getTextBeforeOffset = impl_getTextBeforeOffset;
194 epv->_get_caretOffset = impl__get_caretOffset;
195 epv->getAttributes = impl_getAttributes;
196 epv->getCharacterExtents = impl_getCharacterExtents;
197 epv->_get_characterCount = impl__get_characterCount;
198 epv->getOffsetAtPoint = impl_getOffsetAtPoint;
199 epv->getNSelections = impl_getNSelections;
200 epv->getSelection = impl_getSelection;
201 epv->addSelection = impl_addSelection;
202 epv->removeSelection = impl_removeSelection;
203 epv->setSelection = impl_setSelection;
204 epv->setCaretOffset = impl_setCaretOffset;
208 text_init (Text *text)
213 text_finalize (GObject *obj)
215 Text *text = TEXT (obj);
216 g_object_unref (text->atko);
218 parent_class->finalize (obj);
222 text_interface_new (AtkObject *obj)
225 TEXT(g_object_new (TEXT_TYPE, NULL));
226 new_text->atko = obj;
234 impl_getText (PortableServer_Servant _servant,
235 const CORBA_long startOffset,
236 const CORBA_long endOffset,
237 CORBA_Environment * ev)
239 Text *text = TEXT (bonobo_object_from_servant (_servant));
243 txt = atk_text_get_text (ATK_TEXT(text->atko),
244 (gint) startOffset, (gint) endOffset);
247 rv = CORBA_string_dup (txt);
251 rv = CORBA_string_dup ("");
258 impl_getTextAfterOffset (PortableServer_Servant _servant,
259 const CORBA_long offset,
261 Accessibility_TEXT_BOUNDARY_TYPE
262 type, CORBA_long * startOffset,
263 CORBA_long * endOffset,
264 CORBA_Environment * ev)
266 Text *text = TEXT (bonobo_object_from_servant (_servant));
271 txt = atk_text_get_text_after_offset (ATK_TEXT(text->atko),
272 (gint) offset, (AtkTextBoundary) type,
273 (gint *) startOffset, (gint *) endOffset);
276 rv = CORBA_string_dup (txt);
280 rv = CORBA_string_dup ("");
287 impl_getTextAtOffset (PortableServer_Servant _servant,
288 const CORBA_long offset,
289 const Accessibility_TEXT_BOUNDARY_TYPE type,
290 CORBA_long * startOffset,
291 CORBA_long * endOffset,
292 CORBA_Environment * ev)
297 gint intStartOffset, intEndOffset;
300 fprintf (stderr, "getting bonobo-object from text servant\n");
301 obj = (bonobo_object_from_servant (_servant));
303 g_return_val_if_fail (IS_TEXT (bonobo_object_from_servant (_servant)), (CORBA_char *)"");
304 g_return_val_if_fail (ATK_IS_TEXT (text->atko), (CORBA_char *)"");
305 txt = (CORBA_char *) atk_text_get_text_at_offset (ATK_TEXT (text->atko),
306 (gint) offset, (AtkTextBoundary) type,
307 &intStartOffset, &intEndOffset);
308 *startOffset = (CORBA_long) intStartOffset;
309 *endOffset = (CORBA_long) intEndOffset;
313 rv = CORBA_string_dup (txt);
317 rv = CORBA_string_dup ("");
325 impl_getCharacterAtOffset (PortableServer_Servant _servant,
326 const CORBA_long offset,
327 CORBA_Environment * ev)
329 Text *text = TEXT (bonobo_object_from_servant (_servant));
331 atk_text_get_character_at_offset (ATK_TEXT(text->atko), (gint) offset);
336 impl_getTextBeforeOffset (PortableServer_Servant _servant,
337 const CORBA_long offset,
339 Accessibility_TEXT_BOUNDARY_TYPE
340 type, CORBA_long * startOffset,
341 CORBA_long * endOffset,
342 CORBA_Environment * ev)
344 Text *text = TEXT (bonobo_object_from_servant (_servant));
348 txt = atk_text_get_text_before_offset (ATK_TEXT(text->atko),
349 (gint) offset, (AtkTextBoundary) type,
350 (gint *) startOffset, (gint *) endOffset);
353 rv = CORBA_string_dup (txt);
357 rv = CORBA_string_dup ("");
363 impl__get_caretOffset (PortableServer_Servant _servant,
364 CORBA_Environment * ev)
366 Text *text = TEXT (bonobo_object_from_servant (_servant));
368 atk_text_get_caret_offset (ATK_TEXT(text->atko));
374 impl_getAttributes (PortableServer_Servant _servant,
375 const CORBA_long offset,
376 CORBA_long * startOffset,
377 CORBA_long * endOffset,
378 CORBA_Environment * ev)
380 Text *text = TEXT (bonobo_object_from_servant (_servant));
381 g_print ("getAttributes not implemented.\n");
387 impl_getCharacterExtents (PortableServer_Servant _servant,
388 const CORBA_long offset, CORBA_long * x,
389 CORBA_long * y, CORBA_long * width,
391 const CORBA_short coordType,
392 CORBA_Environment * ev)
394 Text *text = TEXT (bonobo_object_from_servant (_servant));
395 atk_text_get_character_extents (ATK_TEXT(text->atko), (gint) offset,
396 (gint *) x, (gint *) y, (gint *) width, (gint *) height,
397 (AtkCoordType) coordType);
403 impl__get_characterCount (PortableServer_Servant _servant,
404 CORBA_Environment * ev)
406 Text *text = TEXT (bonobo_object_from_servant (_servant));
408 atk_text_get_character_count (ATK_TEXT(text->atko));
414 impl_getOffsetAtPoint (PortableServer_Servant _servant,
415 const CORBA_long x, const CORBA_long y,
416 const CORBA_short coordType,
417 CORBA_Environment * ev)
419 Text *text = TEXT (bonobo_object_from_servant (_servant));
421 atk_text_get_offset_at_point (ATK_TEXT(text->atko),
422 (gint) x, (gint) y, (AtkCoordType) coordType);
428 impl_getNSelections (PortableServer_Servant _servant,
429 CORBA_Environment * ev)
431 Text *text = TEXT (bonobo_object_from_servant (_servant));
433 atk_text_get_n_selections (ATK_TEXT(text->atko));
439 impl_getSelection (PortableServer_Servant _servant,
440 const CORBA_long selectionNum,
441 CORBA_long * startOffset, CORBA_long * endOffset,
442 CORBA_Environment * ev)
444 Text *text = TEXT (bonobo_object_from_servant (_servant));
445 atk_text_get_selection (ATK_TEXT(text->atko), (gint) selectionNum,
446 (gint *) startOffset, (gint *) endOffset);
452 impl_addSelection (PortableServer_Servant _servant,
453 const CORBA_long startOffset,
454 const CORBA_long endOffset,
455 CORBA_Environment * ev)
457 Text *text = TEXT (bonobo_object_from_servant (_servant));
458 return (CORBA_boolean)
459 atk_text_add_selection (ATK_TEXT(text->atko),
460 (gint) startOffset, (gint) endOffset);
466 impl_removeSelection (PortableServer_Servant _servant,
467 const CORBA_long selectionNum,
468 CORBA_Environment * ev)
470 Text *text = TEXT (bonobo_object_from_servant (_servant));
471 return (CORBA_boolean)
472 atk_text_remove_selection (ATK_TEXT(text->atko), (gint) selectionNum);
478 impl_setSelection (PortableServer_Servant _servant,
479 const CORBA_long selectionNum,
480 const CORBA_long startOffset,
481 const CORBA_long endOffset,
482 CORBA_Environment * ev)
484 Text *text = TEXT (bonobo_object_from_servant (_servant));
485 return (CORBA_boolean)
486 atk_text_set_selection (ATK_TEXT(text->atko),
487 (gint) selectionNum, (gint) startOffset, (gint) endOffset);
493 impl_setCaretOffset (PortableServer_Servant _servant,
494 const CORBA_long value,
495 CORBA_Environment * ev)
497 Text *text = TEXT (bonobo_object_from_servant (_servant));
498 return (CORBA_boolean)
499 atk_text_set_caret_offset (ATK_TEXT(text->atko), (gint) value);
505 impl_getRowColAtOffset (PortableServer_Servant _servant,
506 const CORBA_long offset, CORBA_long * row,
507 CORBA_long * column, CORBA_Environment * ev)
509 Text *text = TEXT (bonobo_object_from_servant (_servant));