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::Accessible" 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 *component_parent_class;
54 * Implemented GObject::finalize
57 accessibility_component_object_finalize (GObject *object)
59 Component *component = COMPONENT (object);
61 printf("accessible_component_object_finalize called\n");
62 component->atko = NULL;
64 printf("atko freed, calling parent finalize\n");
65 component_parent_class->finalize (object);
69 * CORBA Accessibility::Component::contains method implementation
72 impl_accessibility_component_contains (PortableServer_Servant servant,
75 CORBA_short coord_type,
76 CORBA_Environment *ev)
79 Component *component = COMPONENT (bonobo_object_from_servant (servant));
80 retval = atk_component_contains (ATK_COMPONENT (component->atko), (gint) x, (gint) y,
81 (AtkCoordType) coord_type);
82 fprintf (stderr, "Component contains() called: %s\n", retval ? "true" : "false" );
87 * CORBA Accessibility::Component::getAccessibleAtPoint method implementation
89 static Accessibility_Accessible
90 impl_accessibility_component_get_accessible_at_point (PortableServer_Servant servant,
93 CORBA_short coord_type,
94 CORBA_Environment *ev)
96 Accessibility_Accessible retval;
97 Component *component = COMPONENT (bonobo_object_from_servant (servant));
99 child = atk_component_ref_accessible_at_point (ATK_COMPONENT (component->atko),
101 (AtkCoordType) coord_type);
102 retval = bonobo_object_corba_objref (bonobo_object (accessible_new (child)));
107 * CORBA Accessibility::Component::getExtents method implementation
110 impl_accessibility_component_get_extents (PortableServer_Servant servant,
115 const CORBA_short coord_type,
116 CORBA_Environment *ev)
118 Component *component = COMPONENT (bonobo_object_from_servant (servant));
120 atk_component_get_extents (ATK_COMPONENT (component->atko), &ix, &iy, &iw, &ih,
121 (AtkCoordType) coord_type);
122 *x = (CORBA_long) ix;
123 *y = (CORBA_long) iy;
124 *width = (CORBA_long) iw;
125 *height = (CORBA_long) ih;
129 * CORBA Accessibility::Component::getPosition method implementation
132 impl_accessibility_component_get_position (PortableServer_Servant servant,
135 const CORBA_short coord_type,
136 CORBA_Environment *ev)
138 Component *component = COMPONENT (bonobo_object_from_servant (servant));
140 atk_component_get_position (ATK_COMPONENT (component->atko), &ix, &iy,
141 (AtkCoordType) coord_type);
142 *x = (CORBA_long) ix;
143 *y = (CORBA_long) iy;
147 * CORBA Accessibility::Component::getSize method implementation
150 impl_accessibility_component_get_size (PortableServer_Servant servant,
153 CORBA_Environment *ev)
155 Component *component = COMPONENT (bonobo_object_from_servant (servant));
157 atk_component_get_size (ATK_COMPONENT (component->atko), &iw, &ih);
158 *width = (CORBA_long) iw;
159 *height = (CORBA_long) ih;
163 accessibility_component_class_init (ComponentClass *klass)
165 GObjectClass * object_class = (GObjectClass *) klass;
166 POA_Accessibility_Component__epv *epv = &klass->epv;
167 component_parent_class = g_type_class_peek_parent (klass);
169 object_class->finalize = accessibility_component_object_finalize;
171 epv->contains = impl_accessibility_component_contains;
172 epv->getAccessibleAtPoint = impl_accessibility_component_get_accessible_at_point;
173 epv->getExtents = impl_accessibility_component_get_extents;
174 epv->getPosition = impl_accessibility_component_get_position;
175 epv->getSize = impl_accessibility_component_get_size;
179 accessibility_component_init (Component *component)
184 accessibility_component_get_type (void)
186 static GType type = 0;
189 static const GTypeInfo tinfo = {
190 sizeof (ComponentClass),
191 (GBaseInitFunc) NULL,
192 (GBaseFinalizeFunc) NULL,
193 (GClassInitFunc) accessibility_component_class_init,
194 (GClassFinalizeFunc) NULL,
195 NULL, /* class data */
198 (GInstanceInitFunc) accessibility_component_init,
199 NULL /* value table */
202 * Bonobo_type_unique auto-generates a load of
203 * CORBA structures for us. All derived types must
204 * use bonobo_type_unique.
206 type = bonobo_type_unique (
208 POA_Accessibility_Component__init,
210 G_STRUCT_OFFSET (ComponentClass, epv),
212 "AccessibleComponent");
219 component_interface_new (AtkObject *o)
222 COMPONENT (g_object_new (accessibility_component_get_type (), NULL));
223 /* don't increment AtkObject refcount, ref is held by containing Accessible instance */
224 retval->atko = ATK_OBJECT (o);