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 g_object_unref (component->atko);
63 component->atko = NULL;
65 printf("atko freed, calling parent finalize\n");
66 component_parent_class->finalize (object);
70 * CORBA Accessibility::Component::contains method implementation
73 impl_accessibility_component_contains (PortableServer_Servant servant,
76 CORBA_short coord_type,
77 CORBA_Environment *ev)
80 Component *component = COMPONENT (bonobo_object_from_servant (servant));
81 retval = atk_component_contains (ATK_COMPONENT (component->atko), (gint) x, (gint) y,
82 (AtkCoordType) coord_type);
83 fprintf (stderr, "Component contains() called: %s\n", retval ? "true" : "false" );
88 * CORBA Accessibility::Component::getAccessibleAtPoint method implementation
90 static Accessibility_Accessible
91 impl_accessibility_component_get_accessible_at_point (PortableServer_Servant servant,
94 CORBA_short coord_type,
95 CORBA_Environment *ev)
97 Accessibility_Accessible retval;
98 Component *component = COMPONENT (bonobo_object_from_servant (servant));
100 child = atk_component_ref_accessible_at_point (ATK_COMPONENT (component->atko),
102 (AtkCoordType) coord_type);
103 retval = bonobo_object_corba_objref (bonobo_object (accessible_new (child)));
108 * CORBA Accessibility::Component::getExtents method implementation
111 impl_accessibility_component_get_extents (PortableServer_Servant servant,
116 const CORBA_short coord_type,
117 CORBA_Environment *ev)
119 Component *component = COMPONENT (bonobo_object_from_servant (servant));
121 atk_component_get_extents (ATK_COMPONENT (component->atko), &ix, &iy, &iw, &ih,
122 (AtkCoordType) coord_type);
123 *x = (CORBA_long) ix;
124 *y = (CORBA_long) iy;
125 *width = (CORBA_long) iw;
126 *height = (CORBA_long) ih;
130 * CORBA Accessibility::Component::getPosition method implementation
133 impl_accessibility_component_get_position (PortableServer_Servant servant,
136 const CORBA_short coord_type,
137 CORBA_Environment *ev)
139 Component *component = COMPONENT (bonobo_object_from_servant (servant));
141 atk_component_get_position (ATK_COMPONENT (component->atko), &ix, &iy,
142 (AtkCoordType) coord_type);
143 *x = (CORBA_long) ix;
144 *y = (CORBA_long) iy;
148 * CORBA Accessibility::Component::getSize method implementation
151 impl_accessibility_component_get_size (PortableServer_Servant servant,
154 CORBA_Environment *ev)
156 Component *component = COMPONENT (bonobo_object_from_servant (servant));
158 atk_component_get_size (ATK_COMPONENT (component->atko), &iw, &ih);
159 *width = (CORBA_long) iw;
160 *height = (CORBA_long) ih;
164 accessibility_component_class_init (ComponentClass *klass)
166 GObjectClass * object_class = (GObjectClass *) klass;
167 POA_Accessibility_Component__epv *epv = &klass->epv;
168 component_parent_class = g_type_class_peek_parent (klass);
170 object_class->finalize = accessibility_component_object_finalize;
172 epv->contains = impl_accessibility_component_contains;
173 epv->getAccessibleAtPoint = impl_accessibility_component_get_accessible_at_point;
174 epv->getExtents = impl_accessibility_component_get_extents;
175 epv->getPosition = impl_accessibility_component_get_position;
176 epv->getSize = impl_accessibility_component_get_size;
180 accessibility_component_init (Component *component)
185 accessibility_component_get_type (void)
187 static GType type = 0;
190 static const GTypeInfo tinfo = {
191 sizeof (ComponentClass),
192 (GBaseInitFunc) NULL,
193 (GBaseFinalizeFunc) NULL,
194 (GClassInitFunc) accessibility_component_class_init,
195 (GClassFinalizeFunc) NULL,
196 NULL, /* class data */
199 (GInstanceInitFunc) accessibility_component_init,
200 NULL /* value table */
203 * Bonobo_type_unique auto-generates a load of
204 * CORBA structures for us. All derived types must
205 * use bonobo_type_unique.
207 type = bonobo_type_unique (
209 POA_Accessibility_Component__init,
211 G_STRUCT_OFFSET (ComponentClass, epv),
213 "AccessibleComponent");
220 component_interface_new (AtkObject *o)
223 COMPONENT (g_object_new (accessibility_component_get_type (), NULL));