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 Text bonobo object
43 * Static function declarations
47 text_class_init (TextClass *klass);
49 text_init (Text *text);
51 text_finalize (GObject *obj);
53 impl_getText (PortableServer_Servant _servant,
54 const CORBA_long startOffset,
55 const CORBA_long endOffset,
56 CORBA_Environment * ev);
58 impl_getTextAfterOffset (PortableServer_Servant _servant,
59 const CORBA_long offset,
61 Accessibility_TEXT_BOUNDARY_TYPE
62 type, CORBA_long * startOffset,
63 CORBA_long * endOffset,
64 CORBA_Environment * ev);
66 impl_getTextAtOffset (PortableServer_Servant _servant,
67 const CORBA_long offset,
68 const Accessibility_TEXT_BOUNDARY_TYPE
69 type, CORBA_long * startOffset,
70 CORBA_long * endOffset,
71 CORBA_Environment * ev);
73 impl_getCharacterAtOffset (PortableServer_Servant _servant,
74 const CORBA_long offset,
75 CORBA_Environment * ev);
77 impl_getTextBeforeOffset (PortableServer_Servant _servant,
78 const CORBA_long offset,
80 Accessibility_TEXT_BOUNDARY_TYPE
81 type, CORBA_long * startOffset,
82 CORBA_long * endOffset,
83 CORBA_Environment * ev);
85 impl__get_caretOffset (PortableServer_Servant _servant,
86 CORBA_Environment * ev);
88 impl_getAttributes (PortableServer_Servant _servant,
89 const CORBA_long offset,
90 CORBA_long * startOffset,
91 CORBA_long * endOffset,
92 CORBA_Environment * ev);
94 impl_getCharacterExtents (PortableServer_Servant _servant,
95 const CORBA_long offset, CORBA_long * x,
96 CORBA_long * y, CORBA_long * width,
98 const CORBA_short coordType,
99 CORBA_Environment * ev);
101 impl__get_characterCount (PortableServer_Servant _servant,
102 CORBA_Environment * ev);
104 impl_getOffsetAtPoint (PortableServer_Servant _servant,
105 const CORBA_long x, const CORBA_long y,
106 const CORBA_short coordType,
107 CORBA_Environment * ev);
109 impl_getNSelections (PortableServer_Servant _servant,
110 CORBA_Environment * ev);
112 impl_getSelection (PortableServer_Servant _servant,
113 const CORBA_long selectionNum,
114 CORBA_long * startOffset, CORBA_long * endOffset,
115 CORBA_Environment * ev);
117 impl_addSelection (PortableServer_Servant _servant,
118 const CORBA_long startOffset,
119 const CORBA_long endOffset,
120 CORBA_Environment * ev);
122 impl_removeSelection (PortableServer_Servant _servant,
123 const CORBA_long selectionNum,
124 CORBA_Environment * ev);
126 impl_setSelection (PortableServer_Servant _servant,
127 const CORBA_long selectionNum,
128 const CORBA_long startOffset,
129 const CORBA_long endOffset,
130 CORBA_Environment * ev);
132 impl_setCaretOffset (PortableServer_Servant _servant,
133 const CORBA_long value,
134 CORBA_Environment * ev);
138 static GObjectClass *parent_class;
143 static GType type = 0;
146 static const GTypeInfo tinfo = {
148 (GBaseInitFunc) NULL,
149 (GBaseFinalizeFunc) NULL,
150 (GClassInitFunc) text_class_init,
151 (GClassFinalizeFunc) NULL,
152 NULL, /* class data */
155 (GInstanceInitFunc) text_init,
156 NULL /* value table */
160 * Bonobo_type_unique auto-generates a load of
161 * CORBA structures for us. All derived types must
162 * use bonobo_type_unique.
164 type = bonobo_type_unique (
166 POA_Accessibility_Text__init,
168 G_STRUCT_OFFSET (TextClass, epv),
177 text_class_init (TextClass *klass)
179 GObjectClass * object_class = (GObjectClass *) klass;
180 POA_Accessibility_Text__epv *epv = &klass->epv;
181 parent_class = g_type_class_peek_parent (klass);
183 object_class->finalize = text_finalize;
186 /* Initialize epv table */
188 epv->getText = impl_getText;
189 epv->getTextAfterOffset = impl_getTextAfterOffset;
190 epv->getCharacterAtOffset = impl_getCharacterAtOffset;
191 epv->getTextAtOffset = impl_getTextAtOffset;
192 epv->getTextBeforeOffset = impl_getTextBeforeOffset;
193 epv->_get_caretOffset = impl__get_caretOffset;
194 epv->getAttributes = impl_getAttributes;
195 epv->getCharacterExtents = impl_getCharacterExtents;
196 epv->_get_characterCount = impl__get_characterCount;
197 epv->getOffsetAtPoint = impl_getOffsetAtPoint;
198 epv->getNSelections = impl_getNSelections;
199 epv->getSelection = impl_getSelection;
200 epv->addSelection = impl_addSelection;
201 epv->removeSelection = impl_removeSelection;
202 epv->setSelection = impl_setSelection;
203 epv->setCaretOffset = impl_setCaretOffset;
207 text_init (Text *text)
212 text_finalize (GObject *obj)
214 Text *text = TEXT (obj);
215 g_object_unref (text->atko);
217 parent_class->finalize (obj);
221 text_interface_new (AtkObject *obj)
224 TEXT(g_object_new (TEXT_TYPE, NULL));
225 new_text->atko = obj;
233 impl_getText (PortableServer_Servant _servant,
234 const CORBA_long startOffset,
235 const CORBA_long endOffset,
236 CORBA_Environment * ev)
238 Text *text = TEXT (bonobo_object_from_servant (_servant));
242 txt = atk_text_get_text (ATK_TEXT(text->atko),
243 (gint) startOffset, (gint) endOffset);
244 rv = CORBA_string_dup (txt);
252 impl_getTextAfterOffset (PortableServer_Servant _servant,
253 const CORBA_long offset,
255 Accessibility_TEXT_BOUNDARY_TYPE
256 type, CORBA_long * startOffset,
257 CORBA_long * endOffset,
258 CORBA_Environment * ev)
260 Text *text = TEXT (bonobo_object_from_servant (_servant));
264 txt = atk_text_get_text_after_offset (ATK_TEXT(text->atko),
265 (gint) offset, (AtkTextBoundary) type,
266 (gint *) startOffset, (gint *) endOffset);
267 rv = CORBA_string_dup (txt);
275 impl_getTextAtOffset (PortableServer_Servant _servant,
276 const CORBA_long offset,
277 const Accessibility_TEXT_BOUNDARY_TYPE
278 type, CORBA_long * startOffset,
279 CORBA_long * endOffset,
280 CORBA_Environment * ev)
282 Text *text = TEXT (bonobo_object_from_servant (_servant));
286 txt = atk_text_get_text_at_offset (ATK_TEXT(text->atko),
287 (gint) offset, (AtkTextBoundary) type,
288 (gint *) startOffset, (gint *) endOffset);
289 rv = CORBA_string_dup (txt);
297 impl_getCharacterAtOffset (PortableServer_Servant _servant,
298 const CORBA_long offset,
299 CORBA_Environment * ev)
301 Text *text = TEXT (bonobo_object_from_servant (_servant));
303 atk_text_get_character_at_offset (ATK_TEXT(text->atko), (gint) offset);
308 impl_getTextBeforeOffset (PortableServer_Servant _servant,
309 const CORBA_long offset,
311 Accessibility_TEXT_BOUNDARY_TYPE
312 type, CORBA_long * startOffset,
313 CORBA_long * endOffset,
314 CORBA_Environment * ev)
316 Text *text = TEXT (bonobo_object_from_servant (_servant));
320 txt = atk_text_get_text_before_offset (ATK_TEXT(text->atko),
321 (gint) offset, (AtkTextBoundary) type,
322 (gint *) startOffset, (gint *) endOffset);
323 rv = CORBA_string_dup (txt);
329 impl__get_caretOffset (PortableServer_Servant _servant,
330 CORBA_Environment * ev)
332 Text *text = TEXT (bonobo_object_from_servant (_servant));
334 atk_text_get_caret_offset (ATK_TEXT(text->atko));
340 impl_getAttributes (PortableServer_Servant _servant,
341 const CORBA_long offset,
342 CORBA_long * startOffset,
343 CORBA_long * endOffset,
344 CORBA_Environment * ev)
346 Text *text = TEXT (bonobo_object_from_servant (_servant));
347 g_print ("getAttributes not implemented.\n");
353 impl_getCharacterExtents (PortableServer_Servant _servant,
354 const CORBA_long offset, CORBA_long * x,
355 CORBA_long * y, CORBA_long * width,
357 const CORBA_short coordType,
358 CORBA_Environment * ev)
360 Text *text = TEXT (bonobo_object_from_servant (_servant));
361 atk_text_get_character_extents (ATK_TEXT(text->atko), (gint) offset,
362 (gint *) x, (gint *) y, (gint *) width, (gint *) height,
363 (AtkCoordType) coordType);
369 impl__get_characterCount (PortableServer_Servant _servant,
370 CORBA_Environment * ev)
372 Text *text = TEXT (bonobo_object_from_servant (_servant));
374 atk_text_get_character_count (ATK_TEXT(text->atko));
380 impl_getOffsetAtPoint (PortableServer_Servant _servant,
381 const CORBA_long x, const CORBA_long y,
382 const CORBA_short coordType,
383 CORBA_Environment * ev)
385 Text *text = TEXT (bonobo_object_from_servant (_servant));
387 atk_text_get_offset_at_point (ATK_TEXT(text->atko),
388 (gint) x, (gint) y, (AtkCoordType) coordType);
394 impl_getNSelections (PortableServer_Servant _servant,
395 CORBA_Environment * ev)
397 Text *text = TEXT (bonobo_object_from_servant (_servant));
399 atk_text_get_n_selections (ATK_TEXT(text->atko));
405 impl_getSelection (PortableServer_Servant _servant,
406 const CORBA_long selectionNum,
407 CORBA_long * startOffset, CORBA_long * endOffset,
408 CORBA_Environment * ev)
410 Text *text = TEXT (bonobo_object_from_servant (_servant));
411 atk_text_get_selection (ATK_TEXT(text->atko), (gint) selectionNum,
412 (gint *) startOffset, (gint *) endOffset);
418 impl_addSelection (PortableServer_Servant _servant,
419 const CORBA_long startOffset,
420 const CORBA_long endOffset,
421 CORBA_Environment * ev)
423 Text *text = TEXT (bonobo_object_from_servant (_servant));
424 return (CORBA_boolean)
425 atk_text_add_selection (ATK_TEXT(text->atko),
426 (gint) startOffset, (gint) endOffset);
432 impl_removeSelection (PortableServer_Servant _servant,
433 const CORBA_long selectionNum,
434 CORBA_Environment * ev)
436 Text *text = TEXT (bonobo_object_from_servant (_servant));
437 return (CORBA_boolean)
438 atk_text_remove_selection (ATK_TEXT(text->atko), (gint) selectionNum);
444 impl_setSelection (PortableServer_Servant _servant,
445 const CORBA_long selectionNum,
446 const CORBA_long startOffset,
447 const CORBA_long endOffset,
448 CORBA_Environment * ev)
450 Text *text = TEXT (bonobo_object_from_servant (_servant));
451 return (CORBA_boolean)
452 atk_text_set_selection (ATK_TEXT(text->atko),
453 (gint) selectionNum, (gint) startOffset, (gint) endOffset);
459 impl_setCaretOffset (PortableServer_Servant _servant,
460 const CORBA_long value,
461 CORBA_Environment * ev)
463 Text *text = TEXT (bonobo_object_from_servant (_servant));
464 return (CORBA_boolean)
465 atk_text_set_caret_offset (ATK_TEXT(text->atko), (gint) value);
471 impl_getRowColAtOffset (PortableServer_Servant _servant,
472 const CORBA_long offset, CORBA_long * row,
473 CORBA_long * column, CORBA_Environment * ev)
475 Text *text = TEXT (bonobo_object_from_servant (_servant));