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 selection->atk_selection = NULL;
148 parent_class->finalize (obj);
152 selection_new (AtkSelection *selection)
154 Selection *new_selection =
155 SELECTION(g_object_new (SELECTION_TYPE, NULL));
156 new_selection->atk_selection = selection;
157 return new_selection;
163 impl__get_nSelectedChildren (PortableServer_Servant _servant,
164 CORBA_Environment * ev)
166 Selection *selection = SELECTION (bonobo_object_from_servant (_servant));
168 atk_selection_get_selection_count (selection->atk_selection);
174 static Accessibility_Accessible
175 impl_getSelectedChild (PortableServer_Servant _servant,
176 const CORBA_long selectedChildIndex,
177 CORBA_Environment * ev)
179 Selection *selection = SELECTION (bonobo_object_from_servant (_servant));
180 AtkObject *atk_object;
181 Accessibility_Accessible rv;
183 atk_object = atk_selection_ref_selection (selection->atk_selection, (gint) selectedChildIndex);
184 rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(atk_object)));
191 impl_selectChild (PortableServer_Servant _servant,
192 const CORBA_long childIndex,
193 CORBA_Environment * ev)
195 Selection *selection = SELECTION (bonobo_object_from_servant (_servant));
196 return (CORBA_boolean)
197 atk_selection_add_selection (selection->atk_selection, (gint) childIndex);
204 impl_deselectSelectedChild (PortableServer_Servant _servant,
205 const CORBA_long selectedChildIndex,
206 CORBA_Environment * ev)
208 Selection *selection = SELECTION (bonobo_object_from_servant (_servant));
209 return (CORBA_boolean)
210 atk_selection_remove_selection (selection->atk_selection, (gint) selectedChildIndex);
216 impl_isChildSelected (PortableServer_Servant _servant,
217 const CORBA_long childIndex,
218 CORBA_Environment * ev)
220 Selection *selection = SELECTION (bonobo_object_from_servant (_servant));
221 return (CORBA_boolean)
222 atk_selection_is_child_selected (selection->atk_selection, (gint) childIndex);
228 impl_selectAll (PortableServer_Servant _servant,
229 CORBA_Environment * ev)
231 Selection *selection = SELECTION (bonobo_object_from_servant (_servant));
232 atk_selection_select_all_selection (selection->atk_selection);
238 impl_clearSelection (PortableServer_Servant _servant,
239 CORBA_Environment * ev)
241 Selection *selection = SELECTION (bonobo_object_from_servant (_servant));
242 atk_selection_clear_selection (selection->atk_selection);