2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 /* selection.c : implements the Selection interface */
28 #include <libspi/accessible.h>
29 #include <libspi/selection.h>
33 spi_selection_interface_new (AtkObject *obj)
35 SpiSelection *new_selection = g_object_new (SPI_SELECTION_TYPE, NULL);
37 spi_base_construct (SPI_BASE (new_selection), G_OBJECT(obj));
44 get_selection_from_servant (PortableServer_Servant servant)
46 SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
48 g_return_val_if_fail (object, NULL);
49 g_return_val_if_fail (ATK_IS_OBJECT(object->gobj), NULL);
50 return ATK_SELECTION (object->gobj);
55 impl__get_nSelectedChildren (PortableServer_Servant servant,
56 CORBA_Environment *ev)
58 AtkSelection *selection = get_selection_from_servant (servant);
60 g_return_val_if_fail (selection != NULL, 0);
62 return atk_selection_get_selection_count (selection);
66 static Accessibility_Accessible
67 impl_getSelectedChild (PortableServer_Servant servant,
68 const CORBA_long selectedChildIndex,
69 CORBA_Environment *ev)
71 AtkObject *atk_object;
72 AtkSelection *selection = get_selection_from_servant (servant);
74 g_return_val_if_fail (selection != NULL, CORBA_OBJECT_NIL);
77 fprintf (stderr, "calling impl_getSelectedChild\n");
80 atk_object = atk_selection_ref_selection (selection,
83 g_return_val_if_fail (ATK_IS_OBJECT (atk_object), CORBA_OBJECT_NIL);
86 fprintf (stderr, "child type is %s\n",
87 g_type_name (G_OBJECT_TYPE (atk_object)));
90 return spi_accessible_new_return (atk_object, TRUE, ev);
95 impl_selectChild (PortableServer_Servant servant,
96 const CORBA_long childIndex,
97 CORBA_Environment *ev)
99 AtkSelection *selection = get_selection_from_servant (servant);
101 g_return_val_if_fail (selection != NULL, FALSE);
103 return atk_selection_add_selection (selection, childIndex);
108 impl_deselectSelectedChild (PortableServer_Servant servant,
109 const CORBA_long selectedChildIndex,
110 CORBA_Environment *ev)
112 AtkSelection *selection = get_selection_from_servant (servant);
114 g_return_val_if_fail (selection != NULL, FALSE);
116 return atk_selection_remove_selection (selection, selectedChildIndex);
121 impl_isChildSelected (PortableServer_Servant servant,
122 const CORBA_long childIndex,
123 CORBA_Environment *ev)
125 AtkSelection *selection = get_selection_from_servant (servant);
127 g_return_val_if_fail (selection != NULL, FALSE);
129 return atk_selection_is_child_selected (selection, childIndex);
134 impl_selectAll (PortableServer_Servant servant,
135 CORBA_Environment *ev)
137 AtkSelection *selection = get_selection_from_servant (servant);
139 g_return_val_if_fail (selection != NULL, FALSE);
141 return atk_selection_select_all_selection (selection);
147 impl_clearSelection (PortableServer_Servant servant,
148 CORBA_Environment *ev)
150 AtkSelection *selection = get_selection_from_servant (servant);
152 g_return_val_if_fail (selection != NULL, FALSE);
154 return atk_selection_clear_selection (selection);
159 spi_selection_class_init (SpiSelectionClass *klass)
161 POA_Accessibility_Selection__epv *epv = &klass->epv;
163 /* Initialize epv table */
165 epv->_get_nSelectedChildren = impl__get_nSelectedChildren;
166 epv->getSelectedChild = impl_getSelectedChild;
167 epv->selectChild = impl_selectChild;
168 epv->deselectSelectedChild = impl_deselectSelectedChild;
169 epv->isChildSelected = impl_isChildSelected;
170 epv->selectAll = impl_selectAll;
171 epv->clearSelection = impl_clearSelection;
176 spi_selection_init (SpiSelection *selection)
181 BONOBO_TYPE_FUNC_FULL (SpiSelection,
182 Accessibility_Selection,