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::SpiAccessible" server
35 #include <libspi/Accessibility.h>
38 * This pulls the definition for the BonoboObject (Gtk Type)
40 #include "component.h"
41 #include "accessible.h"
44 * Our parent Gtk object type
46 #define PARENT_TYPE BONOBO_OBJECT_TYPE
49 * A pointer to our parent object class
51 static GObjectClass *spi_component_parent_class;
54 * Implemented GObject::finalize
57 accessibility_spi_component_object_finalize (GObject *object)
59 SpiComponent *component = SPI_COMPONENT (object);
61 printf("spi_accessible_spi_component_object_finalize called\n");
62 g_object_unref (component->atko);
63 component->atko = NULL;
65 printf("component atko freed, calling parent finalize\n");
66 spi_component_parent_class->finalize (object);
70 * CORBA Accessibility::SpiComponent::contains method implementation
73 impl_accessibility_spi_component_contains (PortableServer_Servant servant,
76 CORBA_short coord_type,
77 CORBA_Environment *ev)
81 SpiComponent *component;
83 obj = bonobo_object_from_servant (servant);
84 g_return_val_if_fail (IS_SPI_COMPONENT(obj), FALSE);
85 component = SPI_COMPONENT (obj);
86 g_return_val_if_fail (ATK_IS_COMPONENT(component->atko), FALSE);
87 retval = atk_component_contains (ATK_COMPONENT (component->atko), (gint) x, (gint) y,
88 (AtkCoordType) coord_type);
93 * CORBA Accessibility::SpiComponent::getAccessibleAtPoint method implementation
95 static Accessibility_SpiAccessible
96 impl_accessibility_spi_component_get_accessible_at_point (PortableServer_Servant servant,
99 CORBA_short coord_type,
100 CORBA_Environment *ev)
103 SpiComponent *component;
104 Accessibility_SpiAccessible retval;
107 obj = bonobo_object_from_servant (servant);
108 g_return_val_if_fail (IS_SPI_COMPONENT(obj), CORBA_OBJECT_NIL);
109 component = SPI_COMPONENT (obj);
110 g_return_val_if_fail (ATK_IS_COMPONENT(component->atko), CORBA_OBJECT_NIL);
112 child = atk_component_ref_accessible_at_point (ATK_COMPONENT (component->atko),
114 (AtkCoordType) coord_type);
115 retval = bonobo_object_corba_objref (bonobo_object (spi_accessible_new (child)));
116 return CORBA_Object_duplicate (retval, ev);
120 * CORBA Accessibility::SpiComponent::getExtents method implementation
123 impl_accessibility_spi_component_get_extents (PortableServer_Servant servant,
128 const CORBA_short coord_type,
129 CORBA_Environment *ev)
132 SpiComponent *component;
135 obj = bonobo_object_from_servant (servant);
136 g_return_if_fail (IS_SPI_COMPONENT(obj));
137 component = SPI_COMPONENT (obj);
138 g_return_if_fail (ATK_IS_COMPONENT (component->atko));
140 atk_component_get_extents (ATK_COMPONENT (component->atko), &ix, &iy, &iw, &ih,
141 (AtkCoordType) coord_type);
142 *x = (CORBA_long) ix;
143 *y = (CORBA_long) iy;
144 *width = (CORBA_long) iw;
145 *height = (CORBA_long) ih;
149 * CORBA Accessibility::SpiComponent::getPosition method implementation
152 impl_accessibility_spi_component_get_position (PortableServer_Servant servant,
155 const CORBA_short coord_type,
156 CORBA_Environment *ev)
158 BonoboObject *obj = bonobo_object_from_servant (servant);
159 SpiComponent *component;
162 g_return_if_fail (IS_SPI_COMPONENT(obj));
163 component = SPI_COMPONENT(obj);
164 g_return_if_fail (ATK_IS_COMPONENT(component->atko));
166 atk_component_get_position (ATK_COMPONENT (component->atko), &ix, &iy,
167 (AtkCoordType) coord_type);
168 *x = (CORBA_long) ix;
169 *y = (CORBA_long) iy;
173 * CORBA Accessibility::SpiComponent::getSize method implementation
176 impl_accessibility_spi_component_get_size (PortableServer_Servant servant,
179 CORBA_Environment *ev)
181 SpiComponent *component;
182 BonoboObject *obj = bonobo_object_from_servant (servant);
185 g_return_if_fail (IS_SPI_COMPONENT(obj));
186 component = SPI_COMPONENT(obj);
187 g_return_if_fail (ATK_IS_COMPONENT(component->atko));
188 atk_component_get_size (ATK_COMPONENT (component->atko), &iw, &ih);
189 *width = (CORBA_long) iw;
190 *height = (CORBA_long) ih;
194 accessibility_spi_component_class_init (SpiComponentClass *klass)
196 GObjectClass * object_class = (GObjectClass *) klass;
197 POA_Accessibility_SpiComponent__epv *epv = &klass->epv;
198 spi_component_parent_class = g_type_class_peek_parent (klass);
200 object_class->finalize = accessibility_spi_component_object_finalize;
202 epv->contains = impl_accessibility_spi_component_contains;
203 epv->getAccessibleAtPoint = impl_accessibility_spi_component_get_accessible_at_point;
204 epv->getExtents = impl_accessibility_spi_component_get_extents;
205 epv->getPosition = impl_accessibility_spi_component_get_position;
206 epv->getSize = impl_accessibility_spi_component_get_size;
210 accessibility_spi_component_init (SpiComponent *component)
215 accessibility_spi_component_get_type (void)
217 static GType type = 0;
220 static const GTypeInfo tinfo = {
221 sizeof (SpiComponentClass),
222 (GBaseInitFunc) NULL,
223 (GBaseFinalizeFunc) NULL,
224 (GClassInitFunc) accessibility_spi_component_class_init,
225 (GClassFinalizeFunc) NULL,
226 NULL, /* class data */
227 sizeof (SpiComponent),
229 (GInstanceInitFunc) accessibility_spi_component_init,
230 NULL /* value table */
233 * Bonobo_type_unique auto-generates a load of
234 * CORBA structures for us. All derived types must
235 * use bonobo_type_unique.
237 type = bonobo_type_unique (
239 POA_Accessibility_SpiComponent__init,
241 G_STRUCT_OFFSET (SpiComponentClass, epv),
243 "SpiAccessibleComponent");
250 spi_component_interface_new (AtkObject *o)
252 SpiComponent *retval =
253 SPI_COMPONENT (g_object_new (accessibility_spi_component_get_type (), NULL));