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.
23 /* editabletext.c : implements the EditableText interface */
27 #include <atk/atkeditabletext.h>
28 #include <libspi/editabletext.h>
30 /* Static function declarations */
33 spi_editable_text_class_init (SpiEditableTextClass *klass);
35 spi_editable_text_init (SpiEditableText *editable);
37 impl_setAttributes (PortableServer_Servant servant,
38 const CORBA_char * attributes,
39 const CORBA_long startPos,
40 const CORBA_long endPos,
41 CORBA_Environment *ev);
43 impl_setTextContents (PortableServer_Servant servant,
44 const CORBA_char * newContents,
45 CORBA_Environment *ev);
47 impl_insertText (PortableServer_Servant servant,
48 const CORBA_long position,
49 const CORBA_char * text,
50 const CORBA_long length,
51 CORBA_Environment *ev);
53 impl_copyText (PortableServer_Servant servant,
54 const CORBA_long startPos, const CORBA_long endPos,
55 CORBA_Environment *ev);
57 impl_cutText (PortableServer_Servant servant,
58 const CORBA_long startPos, const CORBA_long endPos,
59 CORBA_Environment *ev);
61 impl_deleteText (PortableServer_Servant servant,
62 const CORBA_long startPos, const CORBA_long endPos,
63 CORBA_Environment *ev);
65 impl_pasteText (PortableServer_Servant servant,
66 const CORBA_long position, CORBA_Environment *ev);
68 BONOBO_TYPE_FUNC_FULL (SpiEditableText,
69 Accessibility_EditableText,
74 spi_editable_text_class_init (SpiEditableTextClass *klass)
76 POA_Accessibility_EditableText__epv *epv = &klass->epv;
78 /* Initialize epv table */
80 epv->setAttributes = impl_setAttributes;
81 epv->setTextContents = impl_setTextContents;
82 epv->insertText = impl_insertText;
83 epv->copyText = impl_copyText;
84 epv->cutText = impl_cutText;
85 epv->deleteText = impl_deleteText;
86 epv->pasteText = impl_pasteText;
91 spi_editable_text_init (SpiEditableText *editable)
97 spi_editable_text_interface_new (AtkObject *obj)
99 SpiEditableText *new_editable = g_object_new (
100 SPI_EDITABLE_TEXT_TYPE, NULL);
102 spi_text_construct (SPI_TEXT (new_editable), obj);
108 static AtkEditableText *
109 get_editable_text_from_servant (PortableServer_Servant servant)
111 SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
118 return ATK_EDITABLE_TEXT (object->atko);
123 impl_setAttributes (PortableServer_Servant servant,
124 const CORBA_char * attributes,
125 const CORBA_long startPos,
126 const CORBA_long endPos,
127 CORBA_Environment *ev)
129 AtkEditableText *editable = get_editable_text_from_servant (servant);
131 g_return_val_if_fail (editable != NULL, FALSE);
133 g_print ("setRunAttributes not implemented.\n");
140 impl_setTextContents (PortableServer_Servant servant,
141 const CORBA_char *newContents,
142 CORBA_Environment *ev)
144 AtkEditableText *editable = get_editable_text_from_servant (servant);
146 g_return_if_fail (editable != NULL);
148 atk_editable_text_set_text_contents (editable, (gchar *) newContents);
153 impl_insertText (PortableServer_Servant servant,
154 const CORBA_long position,
155 const CORBA_char *text,
156 const CORBA_long length,
157 CORBA_Environment *ev)
159 AtkEditableText *editable = get_editable_text_from_servant (servant);
161 g_return_if_fail (editable != NULL);
163 atk_editable_text_insert_text (editable,
171 impl_copyText (PortableServer_Servant servant,
172 const CORBA_long startPos, const CORBA_long endPos,
173 CORBA_Environment *ev)
175 AtkEditableText *editable = get_editable_text_from_servant (servant);
177 g_return_if_fail (editable != NULL);
179 atk_editable_text_copy_text (editable, (gint) startPos, (gint) endPos);
184 impl_cutText (PortableServer_Servant servant,
185 const CORBA_long startPos, const CORBA_long endPos,
186 CORBA_Environment *ev)
188 AtkEditableText *editable = get_editable_text_from_servant (servant);
190 g_return_if_fail (editable != NULL);
192 atk_editable_text_cut_text (editable, (gint) startPos, (gint) endPos);
197 impl_deleteText (PortableServer_Servant servant,
198 const CORBA_long startPos, const CORBA_long endPos,
199 CORBA_Environment *ev)
201 AtkEditableText *editable = get_editable_text_from_servant (servant);
203 g_return_if_fail (editable != NULL);
205 atk_editable_text_delete_text (editable, (gint) startPos, (gint) endPos);
210 impl_pasteText (PortableServer_Servant servant,
211 const CORBA_long position, CORBA_Environment *ev)
213 AtkEditableText *editable = get_editable_text_from_servant (servant);
215 g_return_if_fail (editable != NULL);
217 atk_editable_text_paste_text (editable, position);