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 * accessible.c: test for accessibility 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 for the BonoboObject (Gtk Type)
40 #include "accessible.h"
43 * Our parent Gtk object type
45 #define PARENT_TYPE BONOBO_OBJECT_TYPE
48 * A pointer to our parent object class
50 static GObjectClass *accessible_parent_class;
53 * Implemented GObject::finalize
56 accessible_object_finalize (GObject *object)
58 Accessible *accessible = ACCESSIBLE (object);
60 printf("accessible_object_finalize called\n");
61 g_object_unref (accessible->atko);
62 accessible->atko = NULL;
64 printf("atko freed, calling parent finalize\n");
65 accessible_parent_class->finalize (object);
69 * CORBA Accessibility::Accessible::get_name method implementation
72 impl_accessibility_accessible_get_name (PortableServer_Servant servant,
73 CORBA_Environment *ev)
76 Accessible *accessible = ACCESSIBLE (bonobo_object_from_servant (servant));
77 retval = atk_object_get_name (accessible->atko);
79 retval = CORBA_string_dup (retval);
81 retval = CORBA_string_dup ("");
82 fprintf (stderr, "Accessible get_name called: %s\n", retval);
87 * CORBA Accessibility::Accessible::set_name method implementation
90 impl_accessibility_accessible_set_name (PortableServer_Servant servant,
91 const CORBA_char *name,
92 CORBA_Environment *ev)
94 Accessible *accessible = ACCESSIBLE (bonobo_object_from_servant (servant));
95 atk_object_set_name (accessible->atko, name);
96 printf ("Accessible set_name called: %s\n", name);
100 * CORBA Accessibility::Accessible::get_description method implementation
103 impl_accessibility_accessible_get_description (PortableServer_Servant servant,
104 CORBA_Environment *ev)
107 Accessible *accessible = ACCESSIBLE (bonobo_object_from_servant (servant));
108 retval = CORBA_string_dup (atk_object_get_description (accessible->atko));
109 fprintf (stderr, "Accessible get_description called: %s\n", retval);
114 * CORBA Accessibility::Accessible::set_description method implementation
117 impl_accessibility_accessible_set_description (PortableServer_Servant servant,
118 const CORBA_char *name,
119 CORBA_Environment *ev)
121 Accessible *accessible = ACCESSIBLE (bonobo_object_from_servant (servant));
122 atk_object_set_description (accessible->atko, name);
123 printf ("Accessible set_description called: %s\n", name);
127 * CORBA Accessibility::Accessible::get_parent method implementation
129 static Accessibility_Accessible
130 impl_accessibility_accessible_get_parent (PortableServer_Servant servant,
131 CORBA_Environment *ev)
133 Accessibility_Accessible retval;
134 Accessible *accessible = ACCESSIBLE (bonobo_object_from_servant (servant));
136 parent = atk_object_get_parent (accessible->atko);
137 retval = bonobo_object_corba_objref (bonobo_object (accessible_new (parent)));
138 printf ("Accessible get_parent called\n");
143 * CORBA Accessibility::Accessible::get_childCount method implementation
146 impl_accessibility_accessible_get_child_count (PortableServer_Servant servant,
147 CORBA_Environment *ev)
150 Accessible *accessible = ACCESSIBLE (bonobo_object_from_servant (servant));
151 retval = (CORBA_long) atk_object_get_n_accessible_children (accessible->atko);
152 printf ("Accessible get_childCount called: %d\n", (int) retval);
157 * CORBA Accessibility::Accessible::getChildAtIndex method implementation
159 static Accessibility_Accessible
160 impl_accessibility_accessible_get_child_at_index (PortableServer_Servant servant,
161 const CORBA_long index,
162 CORBA_Environment *ev)
164 Accessibility_Accessible retval;
165 Accessible *accessible = ACCESSIBLE (bonobo_object_from_servant (servant));
166 AtkObject *child = atk_object_ref_accessible_child (accessible->atko, (gint) index);
167 retval = bonobo_object_corba_objref ( bonobo_object (accessible_new (child)));
168 printf ("Accessible get_child_at_index called.\n");
173 accessible_class_init (AccessibleClass *klass)
175 GObjectClass * object_class = (GObjectClass *) klass;
176 POA_Accessibility_Accessible__epv *epv = &klass->epv;
177 accessible_parent_class = g_type_class_peek_parent (klass);
179 object_class->finalize = accessible_object_finalize;
181 epv->_get_name = impl_accessibility_accessible_get_name;
182 epv->_set_name = impl_accessibility_accessible_set_name;
183 epv->_get_description = impl_accessibility_accessible_get_description;
184 epv->_set_description = impl_accessibility_accessible_set_description;
186 epv->_get_parent = impl_accessibility_accessible_get_parent;
187 epv->_get_childCount = impl_accessibility_accessible_get_child_count;
188 epv->getChildAtIndex = impl_accessibility_accessible_get_child_at_index;
190 /* epv->getIndexInParent = impl_accessibility_accessible_get_index_in_parent; */
191 /* epv->getRelationSet = impl_accessibility_accessible_get_relation_set; */
192 /* epv->getState = impl_accessibility_accessible_get_state; */
193 /* epv->getRole = impl_accessibility_accessible_get_role; */
197 accessible_init (Accessible *accessible)
202 accessible_get_type (void)
204 static GType type = 0;
207 static const GTypeInfo tinfo = {
208 sizeof (AccessibleClass),
209 (GBaseInitFunc) NULL,
210 (GBaseFinalizeFunc) NULL,
211 (GClassInitFunc) accessible_class_init,
212 (GClassFinalizeFunc) NULL,
213 NULL, /* class data */
216 (GInstanceInitFunc) accessible_init,
217 NULL /* value table */
220 * Bonobo_type_unique auto-generates a load of
221 * CORBA structures for us. All derived types must
222 * use bonobo_type_unique.
224 type = bonobo_type_unique (
226 POA_Accessibility_Accessible__init,
228 G_STRUCT_OFFSET (AccessibleClass, epv),
237 accessible_new (AtkObject *o)
240 ACCESSIBLE (g_object_new (accessible_get_type (), NULL));
242 retval->atko = ATK_OBJECT (o);
245 * TODO: add interface containers/constructors for ACTION, EDITABLE_TEXT, HYPERTEXT,
246 * IMAGE, SELECTION, TABLE, TEXT, VALUE.
249 /* add appropriate ATK interfaces */
251 /* Action: not yet implemented
252 if (ATK_IS_ACTION (o))
254 bonobo_object_add_interface (bonobo_object (retval),
255 bonobo_object (action_interface_new (o)));
259 if (ATK_IS_COMPONENT (o))
261 bonobo_object_add_interface (bonobo_object (retval),
262 bonobo_object (component_interface_new (o)));
265 /* Others: not yet implemented
266 if (ATK_IS_EDITABLE_TEXT (o))
268 bonobo_object_add_interface (bonobo_object (retval),
269 bonobo_object (editable_text_interface_new (o)));
271 else if (ATK_IS_HYPERTEXT (o))
273 bonobo_object_add_interface (bonobo_object (retval),
274 bonobo_object (hypertext_interface_new (o)));
276 else if (ATK_IS_TEXT (o))
278 bonobo_object_add_interface (bonobo_object (retval),
279 bonobo_object (text_interface_new (o)));
281 if (ATK_IS_IMAGE (o))
283 bonobo_object_add_interface (bonobo_object (retval),
284 bonobo_object (image_interface_new (o)));
286 if (ATK_IS_SELECTION (o))
288 bonobo_object_add_interface (bonobo_object (retval),
289 bonobo_object (selection_interface_new (o)));
291 if (ATK_IS_TABLE (o))
293 bonobo_object_add_interface (bonobo_object (retval),
294 bonobo_object (table_interface_new (o)));
296 if (ATK_IS_VALUE (o))
298 bonobo_object_add_interface (bonobo_object (retval),
299 bonobo_object (value_interface_new (o)));