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>
36 #include "accessible.h"
39 * This pulls the definition of the selection bonobo object
41 #include "selection.h"
44 * Static function declarations
48 spi_selection_class_init (SpiSelectionClass *klass);
50 spi_selection_init (SpiSelection *selection);
52 spi_selection_finalize (GObject *obj);
54 impl__get_nSelectedChildren (PortableServer_Servant _servant,
55 CORBA_Environment * ev);
56 static Accessibility_Accessible
57 impl_getSelectedChild (PortableServer_Servant _servant,
58 const CORBA_long selectedChildIndex,
59 CORBA_Environment * ev);
61 impl_selectChild (PortableServer_Servant _servant,
62 const CORBA_long childIndex,
63 CORBA_Environment * ev);
65 impl_deselectSelectedChild (PortableServer_Servant _servant,
66 const CORBA_long selectedChildIndex,
67 CORBA_Environment * ev);
69 impl_isChildSelected (PortableServer_Servant _servant,
70 const CORBA_long childIndex,
71 CORBA_Environment * ev);
73 impl_selectAll (PortableServer_Servant _servant,
74 CORBA_Environment * ev);
76 impl_clearSelection (PortableServer_Servant _servant,
77 CORBA_Environment * ev);
80 static GObjectClass *parent_class;
83 spi_selection_get_type (void)
85 static GType type = 0;
88 static const GTypeInfo tinfo = {
89 sizeof (SpiSelectionClass),
91 (GBaseFinalizeFunc) NULL,
92 (GClassInitFunc) spi_selection_class_init,
93 (GClassFinalizeFunc) NULL,
94 NULL, /* class data */
95 sizeof (SpiSelection),
97 (GInstanceInitFunc) spi_selection_init,
98 NULL /* value table */
102 * Bonobo_type_unique auto-generates a load of
103 * CORBA structures for us. All derived types must
104 * use bonobo_type_unique.
106 type = bonobo_type_unique (
108 POA_Accessibility_Selection__init,
110 G_STRUCT_OFFSET (SpiSelectionClass, epv),
112 "SpiAccessibleSelection");
119 spi_selection_class_init (SpiSelectionClass *klass)
121 GObjectClass * object_class = (GObjectClass *) klass;
122 POA_Accessibility_Selection__epv *epv = &klass->epv;
123 parent_class = g_type_class_peek_parent (klass);
125 object_class->finalize = spi_selection_finalize;
128 /* Initialize epv table */
130 epv->_get_nSelectedChildren = impl__get_nSelectedChildren;
131 epv->getSelectedChild = impl_getSelectedChild;
132 epv->selectChild = impl_selectChild;
133 epv->deselectSelectedChild = impl_deselectSelectedChild;
134 epv->isChildSelected = impl_isChildSelected;
135 epv->selectAll = impl_selectAll;
136 epv->clearSelection = impl_clearSelection;
140 spi_selection_init (SpiSelection *selection)
145 spi_selection_finalize (GObject *obj)
147 SpiSelection *selection = SPI_SELECTION (obj);
148 g_object_unref (selection->atko);
149 selection->atko = NULL;
150 parent_class->finalize (obj);
154 spi_selection_interface_new (AtkObject *obj)
156 SpiSelection *new_selection =
157 SPI_SELECTION(g_object_new (SPI_SELECTION_TYPE, NULL));
158 new_selection->atko = obj;
160 return new_selection;
166 impl__get_nSelectedChildren (PortableServer_Servant _servant,
167 CORBA_Environment * ev)
169 BonoboObject *obj = bonobo_object_from_servant (_servant);
170 SpiSelection *selection;
172 fprintf (stderr, "calling impl__get_nSelectedChildren\n");
174 g_return_val_if_fail (IS_SPI_SELECTION (obj), 0);
175 selection = SPI_SELECTION (obj);
176 g_return_val_if_fail (ATK_IS_SELECTION (selection->atko), 0);
178 atk_selection_get_selection_count (ATK_SELECTION(selection->atko));
182 static Accessibility_Accessible
183 impl_getSelectedChild (PortableServer_Servant _servant,
184 const CORBA_long selectedChildIndex,
185 CORBA_Environment * ev)
187 BonoboObject *obj = bonobo_object_from_servant (_servant);
190 AtkObject *atk_object;
191 Accessibility_Accessible rv;
193 fprintf (stderr, "calling impl_getSelectedChild\n");
195 g_return_val_if_fail (IS_SPI_SELECTION (obj), 0);
196 selection = SPI_SELECTION (obj);
197 g_return_val_if_fail (ATK_IS_SELECTION (selection->atko), 0);
199 atk_object = atk_selection_ref_selection (ATK_SELECTION (selection->atko),
200 (gint) selectedChildIndex);
201 g_return_val_if_fail (ATK_IS_OBJECT (atk_object), NULL);
203 fprintf (stderr, "child type is %s\n", g_type_name (G_OBJECT_TYPE (atk_object)));
205 rv = bonobo_object_corba_objref (bonobo_object (spi_accessible_new (atk_object)));
206 g_object_unref (atk_object);
207 return CORBA_Object_duplicate (rv, ev);
213 impl_selectChild (PortableServer_Servant _servant,
214 const CORBA_long childIndex,
215 CORBA_Environment * ev)
217 SpiSelection *selection = SPI_SELECTION (bonobo_object_from_servant (_servant));
218 return (CORBA_boolean)
219 atk_selection_add_selection (ATK_SELECTION(selection->atko), (gint) childIndex);
226 impl_deselectSelectedChild (PortableServer_Servant _servant,
227 const CORBA_long selectedChildIndex,
228 CORBA_Environment * ev)
230 SpiSelection *selection = SPI_SELECTION (bonobo_object_from_servant (_servant));
231 return (CORBA_boolean)
232 atk_selection_remove_selection (ATK_SELECTION(selection->atko), (gint) selectedChildIndex);
238 impl_isChildSelected (PortableServer_Servant _servant,
239 const CORBA_long childIndex,
240 CORBA_Environment * ev)
242 SpiSelection *selection = SPI_SELECTION (bonobo_object_from_servant (_servant));
243 return (CORBA_boolean)
244 atk_selection_is_child_selected (ATK_SELECTION(selection->atko), (gint) childIndex);
250 impl_selectAll (PortableServer_Servant _servant,
251 CORBA_Environment * ev)
253 SpiSelection *selection = SPI_SELECTION (bonobo_object_from_servant (_servant));
254 atk_selection_select_all_selection (ATK_SELECTION(selection->atko));
260 impl_clearSelection (PortableServer_Servant _servant,
261 CORBA_Environment * ev)
263 SpiSelection *selection = SPI_SELECTION (bonobo_object_from_servant (_servant));
264 atk_selection_clear_selection (ATK_SELECTION(selection->atko));