Removed po directory from Makefile.am for now.
[platform/core/uifw/at-spi2-atk.git] / libspi / editabletext.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001 Sun Microsystems Inc.
6  *
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.
11  *
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.
16  *
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.
21  */
22
23 /* editabletext.c : implements the EditableText interface */
24
25 #include <config.h>
26 #include <stdio.h>
27 #include <atk/atkeditabletext.h>
28 #include <libspi/editabletext.h>
29
30 /* Static function declarations */
31
32 static void
33 spi_editable_text_class_init (SpiEditableTextClass *klass);
34 static void
35 spi_editable_text_init (SpiEditableText *editable);
36 static CORBA_boolean
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);
42 static void
43 impl_setTextContents (PortableServer_Servant servant,
44                       const CORBA_char * newContents,
45                       CORBA_Environment *ev);
46 static void 
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);
52 static void 
53 impl_copyText (PortableServer_Servant servant,
54                const CORBA_long startPos, const CORBA_long endPos,
55                CORBA_Environment *ev);
56 static void 
57 impl_cutText (PortableServer_Servant servant,
58               const CORBA_long startPos, const CORBA_long endPos,
59               CORBA_Environment *ev);
60 static void 
61 impl_deleteText (PortableServer_Servant servant,
62                  const CORBA_long startPos, const CORBA_long endPos,
63                  CORBA_Environment *ev);
64 static void
65 impl_pasteText (PortableServer_Servant servant,
66                 const CORBA_long position, CORBA_Environment *ev);
67
68 BONOBO_TYPE_FUNC_FULL (SpiEditableText,
69                        Accessibility_EditableText,
70                        SPI_TEXT_TYPE,
71                        spi_editable_text);
72
73 static void
74 spi_editable_text_class_init (SpiEditableTextClass *klass)
75 {
76   POA_Accessibility_EditableText__epv *epv = &klass->epv;
77
78   /* Initialize epv table */
79
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;
87 }
88
89
90 static void
91 spi_editable_text_init (SpiEditableText *editable)
92 {
93 }
94
95
96 SpiEditableText *
97 spi_editable_text_interface_new (AtkObject *obj)
98 {
99   SpiEditableText *new_editable = g_object_new (
100           SPI_EDITABLE_TEXT_TYPE, NULL);
101
102   spi_text_construct (SPI_TEXT (new_editable), obj);
103
104   return new_editable;
105 }
106
107
108 static AtkEditableText *
109 get_editable_text_from_servant (PortableServer_Servant servant)
110 {
111   SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
112
113   if (!object)
114     {
115       return NULL;
116     }
117
118   return ATK_EDITABLE_TEXT (object->atko);
119 }
120
121
122 static CORBA_boolean
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)
128 {
129   AtkEditableText *editable = get_editable_text_from_servant (servant);
130
131   g_return_val_if_fail (editable != NULL, FALSE);
132
133   g_print ("setRunAttributes not implemented.\n");
134
135   return FALSE;
136 }
137
138
139 static void
140 impl_setTextContents (PortableServer_Servant servant,
141                       const CORBA_char     *newContents,
142                       CORBA_Environment    *ev)
143 {
144   AtkEditableText *editable = get_editable_text_from_servant (servant);
145
146   g_return_if_fail (editable != NULL);
147   
148   atk_editable_text_set_text_contents (editable, (gchar *) newContents);
149 }
150
151
152 static void 
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)
158 {
159   AtkEditableText *editable = get_editable_text_from_servant (servant);
160
161   g_return_if_fail (editable != NULL);
162
163   atk_editable_text_insert_text (editable,
164                                  (gchar *) text,
165                                  (gint) length,
166                                  (gint *) &position);
167 }
168
169
170 static void 
171 impl_copyText (PortableServer_Servant servant,
172                const CORBA_long startPos, const CORBA_long endPos,
173                CORBA_Environment *ev)
174 {
175   AtkEditableText *editable = get_editable_text_from_servant (servant);
176
177   g_return_if_fail (editable != NULL);
178
179   atk_editable_text_copy_text (editable, (gint) startPos, (gint) endPos);
180 }
181
182
183 static void 
184 impl_cutText (PortableServer_Servant servant,
185               const CORBA_long startPos, const CORBA_long endPos,
186               CORBA_Environment *ev)
187 {
188   AtkEditableText *editable = get_editable_text_from_servant (servant);
189
190   g_return_if_fail (editable != NULL);
191
192   atk_editable_text_cut_text (editable, (gint) startPos, (gint) endPos);
193 }
194
195
196 static void 
197 impl_deleteText (PortableServer_Servant servant,
198                  const CORBA_long startPos, const CORBA_long endPos,
199                  CORBA_Environment *ev)
200 {
201   AtkEditableText *editable = get_editable_text_from_servant (servant);
202
203   g_return_if_fail (editable != NULL);
204
205   atk_editable_text_delete_text (editable, (gint) startPos, (gint) endPos);
206 }
207
208
209 static void
210 impl_pasteText (PortableServer_Servant servant,
211                 const CORBA_long position, CORBA_Environment *ev)
212 {
213   AtkEditableText *editable = get_editable_text_from_servant (servant);
214
215   g_return_if_fail (editable != NULL);
216
217   atk_editable_text_paste_text (editable, position);
218 }