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 /* component.c : implements the Component interface */
27 #include <libspi/accessible.h>
28 #include <libspi/component.h>
30 /* Our parent Gtk object type */
31 #define PARENT_TYPE BONOBO_TYPE_OBJECT
33 /* A pointer to our parent object class */
34 static GObjectClass *spi_component_parent_class;
37 * Implemented GObject::finalize
40 accessibility_component_object_finalize (GObject *object)
42 SpiComponent *component = SPI_COMPONENT (object);
44 printf("spi_accessible_component_object_finalize called\n");
45 g_object_unref (component->atko);
46 component->atko = NULL;
48 printf("component atko freed, calling parent finalize\n");
49 spi_component_parent_class->finalize (object);
53 * CORBA Accessibility::Component::contains method implementation
56 impl_accessibility_component_contains (PortableServer_Servant servant,
59 CORBA_short coord_type,
60 CORBA_Environment *ev)
64 SpiComponent *component;
66 obj = bonobo_object_from_servant (servant);
67 g_return_val_if_fail (IS_SPI_COMPONENT(obj), FALSE);
68 component = SPI_COMPONENT (obj);
69 g_return_val_if_fail (ATK_IS_COMPONENT(component->atko), FALSE);
70 retval = atk_component_contains (ATK_COMPONENT (component->atko), (gint) x, (gint) y,
71 (AtkCoordType) coord_type);
76 * CORBA Accessibility::Component::getAccessibleAtPoint method implementation
78 static Accessibility_Accessible
79 impl_accessibility_component_get_accessible_at_point (PortableServer_Servant servant,
82 CORBA_short coord_type,
83 CORBA_Environment *ev)
86 SpiComponent *component;
87 Accessibility_Accessible retval;
90 obj = bonobo_object_from_servant (servant);
91 g_return_val_if_fail (IS_SPI_COMPONENT(obj), CORBA_OBJECT_NIL);
92 component = SPI_COMPONENT (obj);
93 g_return_val_if_fail (ATK_IS_COMPONENT(component->atko), CORBA_OBJECT_NIL);
95 child = atk_component_ref_accessible_at_point (ATK_COMPONENT (component->atko),
97 (AtkCoordType) coord_type);
98 retval = bonobo_object_corba_objref (bonobo_object (spi_accessible_new (child)));
99 return CORBA_Object_duplicate (retval, ev);
103 * CORBA Accessibility::Component::getExtents method implementation
106 impl_accessibility_component_get_extents (PortableServer_Servant servant,
111 const CORBA_short coord_type,
112 CORBA_Environment *ev)
115 SpiComponent *component;
118 obj = bonobo_object_from_servant (servant);
119 g_return_if_fail (IS_SPI_COMPONENT(obj));
120 component = SPI_COMPONENT (obj);
121 g_return_if_fail (ATK_IS_COMPONENT (component->atko));
123 atk_component_get_extents (ATK_COMPONENT (component->atko), &ix, &iy, &iw, &ih,
124 (AtkCoordType) coord_type);
125 *x = (CORBA_long) ix;
126 *y = (CORBA_long) iy;
127 *width = (CORBA_long) iw;
128 *height = (CORBA_long) ih;
132 * CORBA Accessibility::Component::getPosition method implementation
135 impl_accessibility_component_get_position (PortableServer_Servant servant,
138 const CORBA_short coord_type,
139 CORBA_Environment *ev)
141 BonoboObject *obj = bonobo_object_from_servant (servant);
142 SpiComponent *component;
145 g_return_if_fail (IS_SPI_COMPONENT(obj));
146 component = SPI_COMPONENT(obj);
147 g_return_if_fail (ATK_IS_COMPONENT(component->atko));
149 atk_component_get_position (ATK_COMPONENT (component->atko), &ix, &iy,
150 (AtkCoordType) coord_type);
151 *x = (CORBA_long) ix;
152 *y = (CORBA_long) iy;
156 * CORBA Accessibility::Component::getSize method implementation
159 impl_accessibility_component_get_size (PortableServer_Servant servant,
162 CORBA_Environment *ev)
164 SpiComponent *component;
165 BonoboObject *obj = bonobo_object_from_servant (servant);
168 g_return_if_fail (IS_SPI_COMPONENT(obj));
169 component = SPI_COMPONENT(obj);
170 g_return_if_fail (ATK_IS_COMPONENT(component->atko));
171 atk_component_get_size (ATK_COMPONENT (component->atko), &iw, &ih);
172 *width = (CORBA_long) iw;
173 *height = (CORBA_long) ih;
177 spi_component_class_init (SpiComponentClass *klass)
179 GObjectClass * object_class = (GObjectClass *) klass;
180 POA_Accessibility_Component__epv *epv = &klass->epv;
181 spi_component_parent_class = g_type_class_peek_parent (klass);
183 object_class->finalize = accessibility_component_object_finalize;
185 epv->contains = impl_accessibility_component_contains;
186 epv->getAccessibleAtPoint = impl_accessibility_component_get_accessible_at_point;
187 epv->getExtents = impl_accessibility_component_get_extents;
188 epv->getPosition = impl_accessibility_component_get_position;
189 epv->getSize = impl_accessibility_component_get_size;
193 spi_component_init (SpiComponent *component)
197 BONOBO_TYPE_FUNC_FULL (SpiComponent,
198 Accessibility_Component,
203 spi_component_interface_new (AtkObject *o)
205 SpiComponent *retval = g_object_new (SPI_COMPONENT_TYPE, NULL);