Fixed 'make dist', and added:
[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 /*
24  * component.c : bonobo wrapper for accessible component implementation
25  *
26  */
27 #include <config.h>
28 #include <bonobo/Bonobo.h>
29
30 #include <stdio.h>
31
32 /*
33  * This pulls the CORBA definitions for the "Accessibility::Accessible" server
34  */
35 #include <libspi/Accessibility.h>
36
37 /*
38  * This pulls the definition of the EditableText bonobo object
39  */
40 #include "editabletext.h"
41
42 /*
43  * Static function declarations
44  */
45
46 static void
47 editable_text_class_init (EditableTextClass *klass);
48 static void
49 editable_text_init (EditableText *editable);
50 static void
51 editable_text_finalize (GObject *obj);
52 static CORBA_boolean
53 impl_setAttributes (PortableServer_Servant _servant,
54                        const CORBA_char * attributes,
55                        const CORBA_long startPos,
56                        const CORBA_long endPos,
57                        CORBA_Environment * ev);
58 static void
59 impl_setTextContents (PortableServer_Servant _servant,
60                       const CORBA_char * newContents,
61                       CORBA_Environment * ev);
62 static void 
63 impl_insertText (PortableServer_Servant _servant,
64                  const CORBA_long position,
65                  const CORBA_char * text,
66                  const CORBA_long length,
67                  CORBA_Environment * ev);
68 static void 
69 impl_copyText (PortableServer_Servant _servant,
70                const CORBA_long startPos, const CORBA_long endPos,
71                CORBA_Environment * ev);
72 static void 
73 impl_cutText (PortableServer_Servant _servant,
74               const CORBA_long startPos, const CORBA_long endPos,
75               CORBA_Environment * ev);
76 static void 
77 impl_deleteText (PortableServer_Servant _servant,
78                  const CORBA_long startPos, const CORBA_long endPos,
79                  CORBA_Environment * ev);
80 static void
81 impl_pasteText (PortableServer_Servant _servant,
82                 const CORBA_long position, CORBA_Environment * ev);
83
84 static GObjectClass *parent_class;
85
86 GType
87 editable_text_get_type (void)
88 {
89   static GType type = 0;
90
91   if (!type) {
92     static const GTypeInfo tinfo = {
93       sizeof (EditableTextClass),
94       (GBaseInitFunc) NULL,
95       (GBaseFinalizeFunc) NULL,
96       (GClassInitFunc) editable_text_class_init,
97       (GClassFinalizeFunc) NULL,
98       NULL, /* class data */
99       sizeof (EditableText),
100       0, /* n preallocs */
101       (GInstanceInitFunc) editable_text_init,
102                         NULL /* value table */
103     };
104
105     /*
106      * Bonobo_type_unique auto-generates a load of
107      * CORBA structures for us. All derived types must
108      * use bonobo_type_unique.
109      */
110     type = bonobo_type_unique (
111                                TEXT_TYPE,
112                                POA_Accessibility_EditableText__init,
113                                NULL,
114                                G_STRUCT_OFFSET (EditableTextClass, epv),
115                                &tinfo,
116                                "AccessibleEditableText");
117   }
118
119   return type;
120 }
121
122 static void
123 editable_text_class_init (EditableTextClass *klass)
124 {
125   GObjectClass * object_class = (GObjectClass *) klass;
126   POA_Accessibility_EditableText__epv *epv = &klass->epv;
127   parent_class = g_type_class_peek_parent (klass);
128
129   object_class->finalize = editable_text_finalize;
130
131
132   /* Initialize epv table */
133
134   epv->setAttributes = impl_setAttributes;
135   epv->setTextContents = impl_setTextContents;
136   epv->insertText = impl_insertText;
137   epv->copyText = impl_copyText;
138   epv->cutText = impl_cutText;
139   epv->deleteText = impl_deleteText;
140   epv->pasteText = impl_pasteText;
141 }
142
143 static void
144 editable_text_init (EditableText *editable)
145 {
146 }
147
148 static void
149 editable_text_finalize (GObject *obj)
150 {
151   EditableText *editable = EDITABLE_TEXT(obj);
152   Text *text = TEXT(obj);
153   g_object_unref (text->atko);
154   text->atko = NULL;
155   parent_class->finalize (obj);
156 }
157
158 EditableText *
159 editable_text_interface_new (AtkObject *obj)
160 {
161   EditableText *new_editable =
162     EDITABLE_TEXT(g_object_new (EDITABLE_TEXT_TYPE, NULL));
163   TEXT (new_editable)->atko = obj;
164   g_object_ref (obj);
165 return new_editable;
166 }
167
168
169
170 static CORBA_boolean
171 impl_setAttributes (PortableServer_Servant _servant,
172                        const CORBA_char * attributes,
173                        const CORBA_long startPos,
174                        const CORBA_long endPos,
175                                          CORBA_Environment * ev)
176 {
177   g_print ("setRunAttributes not implemented.\n");
178 }
179
180
181
182 static void
183 impl_setTextContents (PortableServer_Servant _servant,
184                       const CORBA_char * newContents,
185                       CORBA_Environment * ev)
186 {
187   EditableText *editable = EDITABLE_TEXT(bonobo_object_from_servant (_servant));
188   atk_editable_text_set_text_contents (ATK_EDITABLE_TEXT( TEXT (editable)->atko),
189                                        (gchar *) newContents);
190 }
191
192
193
194 static void 
195 impl_insertText (PortableServer_Servant _servant,
196                  const CORBA_long position,
197                  const CORBA_char * text,
198                  const CORBA_long length,
199                  CORBA_Environment * ev)
200 {
201   EditableText *editable = EDITABLE_TEXT (bonobo_object_from_servant(_servant));
202   atk_editable_text_insert_text (ATK_EDITABLE_TEXT( TEXT (editable)->atko),
203                                  (gchar *) text,
204                                  (gint) length,
205                                  (gint *) &position);
206 }
207
208
209 static void 
210 impl_copyText (PortableServer_Servant _servant,
211                const CORBA_long startPos, const CORBA_long endPos,
212                CORBA_Environment * ev)
213 {
214   EditableText *editable = EDITABLE_TEXT (bonobo_object_from_servant(_servant));
215   atk_editable_text_copy_text (ATK_EDITABLE_TEXT( TEXT(editable)->atko),
216                                (gint) startPos, (gint) endPos);
217 }
218
219
220
221 static void 
222 impl_cutText (PortableServer_Servant _servant,
223               const CORBA_long startPos, const CORBA_long endPos,
224               CORBA_Environment * ev)
225 {
226   EditableText *editable = EDITABLE_TEXT (bonobo_object_from_servant(_servant));
227   atk_editable_text_cut_text (ATK_EDITABLE_TEXT(TEXT (editable)->atko),
228                                  (gint) startPos, (gint) endPos);
229 }
230
231
232
233
234 static void 
235 impl_deleteText (PortableServer_Servant _servant,
236                  const CORBA_long startPos, const CORBA_long endPos,
237                  CORBA_Environment * ev)
238 {
239   EditableText *editable = EDITABLE_TEXT (bonobo_object_from_servant(_servant));
240   atk_editable_text_delete_text (ATK_EDITABLE_TEXT( TEXT(editable)->atko),
241                                  (gint) startPos, (gint) endPos);
242 }
243
244
245 static void
246 impl_pasteText (PortableServer_Servant _servant,
247                 const CORBA_long position, CORBA_Environment * ev)
248 {
249   EditableText *editable = EDITABLE_TEXT (bonobo_object_from_servant(_servant));
250   atk_editable_text_paste_text (ATK_EDITABLE_TEXT( TEXT(editable)->atko), position);
251 }
252