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 static CORBA_unsigned_long
75 impl_getCharacterAtOffset (PortableServer_Servant _servant,
76 const CORBA_long offset,
77 CORBA_Environment * ev);
79 impl_getTextBeforeOffset (PortableServer_Servant _servant,
80 const CORBA_long offset,
82 Accessibility_TEXT_BOUNDARY_TYPE
83 type, CORBA_long * startOffset,
84 CORBA_long * endOffset,
85 CORBA_Environment * ev);
87 impl__get_caretOffset (PortableServer_Servant _servant,
88 CORBA_Environment * ev);
90 impl_getAttributes (PortableServer_Servant _servant,
91 const CORBA_long offset,
92 CORBA_long * startOffset,
93 CORBA_long * endOffset,
94 CORBA_Environment * ev);
96 impl_getCharacterExtents (PortableServer_Servant _servant,
97 const CORBA_long offset, CORBA_long * x,
98 CORBA_long * y, CORBA_long * width,
100 const CORBA_short coordType,
101 CORBA_Environment * ev);
103 impl__get_characterCount (PortableServer_Servant _servant,
104 CORBA_Environment * ev);
106 impl_getOffsetAtPoint (PortableServer_Servant _servant,
107 const CORBA_long x, const CORBA_long y,
108 const CORBA_short coordType,
109 CORBA_Environment * ev);
111 impl_getNSelections (PortableServer_Servant _servant,
112 CORBA_Environment * ev);
114 impl_getSelection (PortableServer_Servant _servant,
115 const CORBA_long selectionNum,
116 CORBA_long * startOffset, CORBA_long * endOffset,
117 CORBA_Environment * ev);
119 impl_addSelection (PortableServer_Servant _servant,
120 const CORBA_long startOffset,
121 const CORBA_long endOffset,
122 CORBA_Environment * ev);
124 impl_removeSelection (PortableServer_Servant _servant,
125 const CORBA_long selectionNum,
126 CORBA_Environment * ev);
128 impl_setSelection (PortableServer_Servant _servant,
129 const CORBA_long selectionNum,
130 const CORBA_long startOffset,
131 const CORBA_long endOffset,
132 CORBA_Environment * ev);
134 impl_setCaretOffset (PortableServer_Servant _servant,
135 const CORBA_long value,
136 CORBA_Environment * ev);
140 static GObjectClass *parent_class;
145 static GType type = 0;
148 static const GTypeInfo tinfo = {
150 (GBaseInitFunc) NULL,
151 (GBaseFinalizeFunc) NULL,
152 (GClassInitFunc) text_class_init,
153 (GClassFinalizeFunc) NULL,
154 NULL, /* class data */
157 (GInstanceInitFunc) text_init,
158 NULL /* value table */
162 * Bonobo_type_unique auto-generates a load of
163 * CORBA structures for us. All derived types must
164 * use bonobo_type_unique.
166 type = bonobo_type_unique (
168 POA_Accessibility_Text__init,
170 G_STRUCT_OFFSET (TextClass, epv),
179 text_class_init (TextClass *klass)
181 GObjectClass * object_class = (GObjectClass *) klass;
182 POA_Accessibility_Text__epv *epv = &klass->epv;
183 parent_class = g_type_class_peek_parent (klass);
185 object_class->finalize = text_finalize;
188 /* Initialize epv table */
190 epv->getText = impl_getText;
191 epv->getTextAfterOffset = impl_getTextAfterOffset;
192 epv->getCharacterAtOffset = impl_getCharacterAtOffset;
193 epv->getTextAtOffset = impl_getTextAtOffset;
194 epv->getTextBeforeOffset = impl_getTextBeforeOffset;
195 epv->_get_caretOffset = impl__get_caretOffset;
196 epv->getAttributes = impl_getAttributes;
197 epv->getCharacterExtents = impl_getCharacterExtents;
198 epv->_get_characterCount = impl__get_characterCount;
199 epv->getOffsetAtPoint = impl_getOffsetAtPoint;
200 epv->getNSelections = impl_getNSelections;
201 epv->getSelection = impl_getSelection;
202 epv->addSelection = impl_addSelection;
203 epv->removeSelection = impl_removeSelection;
204 epv->setSelection = impl_setSelection;
205 epv->setCaretOffset = impl_setCaretOffset;
209 text_init (Text *text)
214 text_finalize (GObject *obj)
216 Text *text = TEXT (obj);
217 g_object_unref (text->atko);
219 parent_class->finalize (obj);
223 text_interface_new (AtkObject *obj)
226 TEXT(g_object_new (TEXT_TYPE, NULL));
227 new_text->atko = obj;
235 impl_getText (PortableServer_Servant _servant,
236 const CORBA_long startOffset,
237 const CORBA_long endOffset,
238 CORBA_Environment * ev)
245 obj = (bonobo_object_from_servant (_servant));
246 g_return_val_if_fail (IS_TEXT (obj), (CORBA_char *)"");
248 g_return_val_if_fail (ATK_IS_TEXT (text->atko), (CORBA_char *)"");
250 txt = atk_text_get_text (ATK_TEXT(text->atko),
251 (gint) startOffset, (gint) endOffset);
254 rv = CORBA_string_dup (txt);
258 rv = CORBA_string_dup ("");
265 impl_getTextAfterOffset (PortableServer_Servant _servant,
266 const CORBA_long offset,
268 Accessibility_TEXT_BOUNDARY_TYPE
269 type, CORBA_long * startOffset,
270 CORBA_long * endOffset,
271 CORBA_Environment * ev)
276 gint intStartOffset, intEndOffset;
279 obj = (bonobo_object_from_servant (_servant));
280 g_return_val_if_fail (IS_TEXT (obj), (CORBA_char *)"");
282 g_return_val_if_fail (ATK_IS_TEXT (text->atko), (CORBA_char *)"");
284 txt = atk_text_get_text_after_offset (ATK_TEXT(text->atko),
285 (gint) offset, (AtkTextBoundary) type,
286 &intStartOffset, &intEndOffset);
287 *startOffset = (CORBA_long) intStartOffset;
288 *endOffset = (CORBA_long) intEndOffset;
292 rv = CORBA_string_dup (txt);
296 rv = CORBA_string_dup ("");
303 impl_getTextAtOffset (PortableServer_Servant _servant,
304 const CORBA_long offset,
305 const Accessibility_TEXT_BOUNDARY_TYPE type,
306 CORBA_long * startOffset,
307 CORBA_long * endOffset,
308 CORBA_Environment * ev)
313 gint intStartOffset, intEndOffset;
316 obj = (bonobo_object_from_servant (_servant));
317 g_return_val_if_fail (IS_TEXT (obj), (CORBA_char *)"");
319 g_return_val_if_fail (ATK_IS_TEXT (text->atko), (CORBA_char *)"");
321 txt = (CORBA_char *) atk_text_get_text_at_offset (ATK_TEXT (text->atko),
322 (gint) offset, (AtkTextBoundary) type,
323 &intStartOffset, &intEndOffset);
324 *startOffset = (CORBA_long) intStartOffset;
325 *endOffset = (CORBA_long) intEndOffset;
329 rv = CORBA_string_dup (txt);
333 rv = CORBA_string_dup ("");
339 static CORBA_unsigned_long
340 impl_getCharacterAtOffset (PortableServer_Servant _servant,
341 const CORBA_long offset,
342 CORBA_Environment * ev)
346 obj = (bonobo_object_from_servant (_servant));
348 g_return_val_if_fail (IS_TEXT (obj), (CORBA_unsigned_long)0);
350 g_return_val_if_fail (ATK_IS_TEXT (text->atko), (CORBA_unsigned_long)0);
352 return (CORBA_unsigned_long)
353 atk_text_get_character_at_offset (ATK_TEXT(text->atko), (gint) offset);
358 impl_getTextBeforeOffset (PortableServer_Servant _servant,
359 const CORBA_long offset,
361 Accessibility_TEXT_BOUNDARY_TYPE
362 type, CORBA_long * startOffset,
363 CORBA_long * endOffset,
364 CORBA_Environment * ev)
369 gint intStartOffset, intEndOffset;
372 obj = (bonobo_object_from_servant (_servant));
373 g_return_val_if_fail (IS_TEXT (obj), (CORBA_char *)"");
375 g_return_val_if_fail (ATK_IS_TEXT (text->atko), (CORBA_char *)"");
377 txt = atk_text_get_text_before_offset (ATK_TEXT(text->atko),
378 (gint) offset, (AtkTextBoundary) type,
379 &intStartOffset, &intEndOffset);
380 *startOffset = (CORBA_long) intStartOffset;
381 *endOffset = (CORBA_long) intEndOffset;
385 rv = CORBA_string_dup (txt);
389 rv = CORBA_string_dup ("");
395 impl__get_caretOffset (PortableServer_Servant _servant,
396 CORBA_Environment * ev)
401 obj = (bonobo_object_from_servant (_servant));
402 g_return_val_if_fail (IS_TEXT (obj), (CORBA_long)-1);
404 g_return_val_if_fail (ATK_IS_TEXT (text->atko), (CORBA_long)-1);
407 atk_text_get_caret_offset (ATK_TEXT(text->atko));
413 impl_getAttributes (PortableServer_Servant _servant,
414 const CORBA_long offset,
415 CORBA_long * startOffset,
416 CORBA_long * endOffset,
417 CORBA_Environment * ev)
422 obj = (bonobo_object_from_servant (_servant));
423 g_return_val_if_fail (IS_TEXT (obj), (CORBA_char *)"");
425 g_return_val_if_fail (ATK_IS_TEXT (text->atko), (CORBA_char *)"");
427 g_print ("getAttributes not yet implemented.\n");
431 impl_getCharacterExtents (PortableServer_Servant _servant,
432 const CORBA_long offset, CORBA_long * x,
433 CORBA_long * y, CORBA_long * width,
435 const CORBA_short coordType,
436 CORBA_Environment * ev)
441 obj = (bonobo_object_from_servant (_servant));
442 g_return_if_fail (IS_TEXT (obj));
444 g_return_if_fail (ATK_IS_TEXT (text->atko));
446 atk_text_get_character_extents (ATK_TEXT(text->atko), (gint) offset,
447 (gint *) x, (gint *) y, (gint *) width, (gint *) height,
448 (AtkCoordType) coordType);
454 impl__get_characterCount (PortableServer_Servant _servant,
455 CORBA_Environment * ev)
460 obj = (bonobo_object_from_servant (_servant));
461 g_return_val_if_fail (IS_TEXT (obj), (CORBA_long)0);
465 atk_text_get_character_count (ATK_TEXT(text->atko));
471 impl_getOffsetAtPoint (PortableServer_Servant _servant,
472 const CORBA_long x, const CORBA_long y,
473 const CORBA_short coordType,
474 CORBA_Environment * ev)
479 obj = (bonobo_object_from_servant (_servant));
480 g_return_val_if_fail (IS_TEXT (obj), (CORBA_long)-1);
484 atk_text_get_offset_at_point (ATK_TEXT(text->atko),
485 (gint) x, (gint) y, (AtkCoordType) coordType);
491 impl_getNSelections (PortableServer_Servant _servant,
492 CORBA_Environment * ev)
497 obj = (bonobo_object_from_servant (_servant));
498 g_return_val_if_fail (IS_TEXT (obj), (CORBA_long)0);
502 atk_text_get_n_selections (ATK_TEXT(text->atko));
508 impl_getSelection (PortableServer_Servant _servant,
509 const CORBA_long selectionNum,
510 CORBA_long * startOffset, CORBA_long * endOffset,
511 CORBA_Environment * ev)
516 obj = (bonobo_object_from_servant (_servant));
517 g_return_if_fail (IS_TEXT (obj));
520 atk_text_get_selection (ATK_TEXT(text->atko), (gint) selectionNum,
521 (gint *) startOffset, (gint *) endOffset);
527 impl_addSelection (PortableServer_Servant _servant,
528 const CORBA_long startOffset,
529 const CORBA_long endOffset,
530 CORBA_Environment * ev)
535 obj = (bonobo_object_from_servant (_servant));
536 g_return_val_if_fail (IS_TEXT (obj), (CORBA_boolean)FALSE);
539 return (CORBA_boolean)
540 atk_text_add_selection (ATK_TEXT(text->atko),
541 (gint) startOffset, (gint) endOffset);
547 impl_removeSelection (PortableServer_Servant _servant,
548 const CORBA_long selectionNum,
549 CORBA_Environment * ev)
554 obj = (bonobo_object_from_servant (_servant));
555 g_return_val_if_fail (IS_TEXT (obj), (CORBA_boolean)FALSE);
558 return (CORBA_boolean)
559 atk_text_remove_selection (ATK_TEXT(text->atko), (gint) selectionNum);
565 impl_setSelection (PortableServer_Servant _servant,
566 const CORBA_long selectionNum,
567 const CORBA_long startOffset,
568 const CORBA_long endOffset,
569 CORBA_Environment * ev)
574 obj = (bonobo_object_from_servant (_servant));
575 g_return_val_if_fail (IS_TEXT (obj), (CORBA_boolean)FALSE);
578 return (CORBA_boolean)
579 atk_text_set_selection (ATK_TEXT(text->atko),
580 (gint) selectionNum, (gint) startOffset, (gint) endOffset);
586 impl_setCaretOffset (PortableServer_Servant _servant,
587 const CORBA_long value,
588 CORBA_Environment * ev)
593 obj = (bonobo_object_from_servant (_servant));
594 g_return_val_if_fail (IS_TEXT (obj), (CORBA_boolean)FALSE);
597 return (CORBA_boolean)
598 atk_text_set_caret_offset (ATK_TEXT(text->atko), (gint) value);
604 impl_getRowColAtOffset (PortableServer_Servant _servant,
605 const CORBA_long offset, CORBA_long * row,
606 CORBA_long * column, CORBA_Environment * ev)
611 obj = (bonobo_object_from_servant (_servant));
612 g_return_if_fail (IS_TEXT (obj));
615 g_print ("getRowColAtOffset not yet implemented\n");