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 of the selection bonobo object
40 #include "selection.h"
43 * Static function declarations
47 selection_class_init (SelectionClass *klass);
49 selection_init (Selection *selection);
51 selection_finalize (GObject *obj);
53 impl__get_nSelectedChildren (PortableServer_Servant _servant,
54 CORBA_Environment * ev);
55 static Accessibility_Accessible
56 impl_getSelectedChild (PortableServer_Servant _servant,
57 const CORBA_long selectedChildIndex,
58 CORBA_Environment * ev);
60 impl_selectChild (PortableServer_Servant _servant,
61 const CORBA_long childIndex,
62 CORBA_Environment * ev);
64 impl_deselectSelectedChild (PortableServer_Servant _servant,
65 const CORBA_long selectedChildIndex,
66 CORBA_Environment * ev);
68 impl_isChildSelected (PortableServer_Servant _servant,
69 const CORBA_long childIndex,
70 CORBA_Environment * ev);
72 impl_selectAll (PortableServer_Servant _servant,
73 CORBA_Environment * ev);
75 impl_clearSelection (PortableServer_Servant _servant,
76 CORBA_Environment * ev);
79 static GObjectClass *parent_class;
82 selection_get_type (void)
84 static GType type = 0;
87 static const GTypeInfo tinfo = {
88 sizeof (SelectionClass),
90 (GBaseFinalizeFunc) NULL,
91 (GClassInitFunc) selection_class_init,
92 (GClassFinalizeFunc) NULL,
93 NULL, /* class data */
96 (GInstanceInitFunc) selection_init,
97 NULL /* value table */
101 * Bonobo_type_unique auto-generates a load of
102 * CORBA structures for us. All derived types must
103 * use bonobo_type_unique.
105 type = bonobo_type_unique (
107 POA_Accessibility_Selection__init,
109 G_STRUCT_OFFSET (SelectionClass, epv),
111 "AccessibleSelection");
118 selection_class_init (SelectionClass *klass)
120 GObjectClass * object_class = (GObjectClass *) klass;
121 POA_Accessibility_Selection__epv *epv = &klass->epv;
122 parent_class = g_type_class_peek_parent (klass);
124 object_class->finalize = selection_finalize;
127 /* Initialize epv table */
129 epv->_get_nSelectedChildren = impl__get_nSelectedChildren;
130 epv->getSelectedChild = impl_getSelectedChild;
131 epv->selectChild = impl_selectChild;
132 epv->deselectSelectedChild = impl_deselectSelectedChild;
133 epv->isChildSelected = impl_isChildSelected;
134 epv->selectAll = impl_selectAll;
135 epv->clearSelection = impl_clearSelection;
139 selection_init (Selection *selection)
144 selection_finalize (GObject *obj)
146 Selection *selection = SELECTION (obj);
147 g_object_unref (selection->atko);
148 selection->atko = NULL;
149 parent_class->finalize (obj);
153 selection_interface_new (AtkObject *obj)
155 Selection *new_selection =
156 SELECTION(g_object_new (SELECTION_TYPE, NULL));
157 new_selection->atko = obj;
159 return new_selection;
165 impl__get_nSelectedChildren (PortableServer_Servant _servant,
166 CORBA_Environment * ev)
168 Selection *selection = SELECTION (bonobo_object_from_servant (_servant));
170 atk_selection_get_selection_count (ATK_SELECTION(selection->atko));
176 static Accessibility_Accessible
177 impl_getSelectedChild (PortableServer_Servant _servant,
178 const CORBA_long selectedChildIndex,
179 CORBA_Environment * ev)
181 Selection *selection = SELECTION (bonobo_object_from_servant (_servant));
182 AtkObject *atk_object;
183 Accessibility_Accessible rv;
185 atk_object = atk_selection_ref_selection (ATK_SELECTION(selection->atko), (gint) selectedChildIndex);
186 rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(atk_object)));
193 impl_selectChild (PortableServer_Servant _servant,
194 const CORBA_long childIndex,
195 CORBA_Environment * ev)
197 Selection *selection = SELECTION (bonobo_object_from_servant (_servant));
198 return (CORBA_boolean)
199 atk_selection_add_selection (ATK_SELECTION(selection->atko), (gint) childIndex);
206 impl_deselectSelectedChild (PortableServer_Servant _servant,
207 const CORBA_long selectedChildIndex,
208 CORBA_Environment * ev)
210 Selection *selection = SELECTION (bonobo_object_from_servant (_servant));
211 return (CORBA_boolean)
212 atk_selection_remove_selection (ATK_SELECTION(selection->atko), (gint) selectedChildIndex);
218 impl_isChildSelected (PortableServer_Servant _servant,
219 const CORBA_long childIndex,
220 CORBA_Environment * ev)
222 Selection *selection = SELECTION (bonobo_object_from_servant (_servant));
223 return (CORBA_boolean)
224 atk_selection_is_child_selected (ATK_SELECTION(selection->atko), (gint) childIndex);
230 impl_selectAll (PortableServer_Servant _servant,
231 CORBA_Environment * ev)
233 Selection *selection = SELECTION (bonobo_object_from_servant (_servant));
234 atk_selection_select_all_selection (ATK_SELECTION(selection->atko));
240 impl_clearSelection (PortableServer_Servant _servant,
241 CORBA_Environment * ev)
243 Selection *selection = SELECTION (bonobo_object_from_servant (_servant));
244 atk_selection_clear_selection (ATK_SELECTION(selection->atko));