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.
23 /* selection.c : implements the Selection interface */
27 #include <libspi/accessible.h>
28 #include <libspi/selection.h>
32 spi_selection_interface_new (AtkObject *obj)
34 SpiSelection *new_selection = g_object_new (SPI_SELECTION_TYPE, NULL);
36 spi_base_construct (SPI_BASE (new_selection), G_OBJECT(obj));
43 get_selection_from_servant (PortableServer_Servant servant)
45 SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
47 g_return_val_if_fail (object, NULL);
48 g_return_val_if_fail (ATK_IS_OBJECT(object->gobj), NULL);
49 return ATK_SELECTION (object->gobj);
54 impl__get_nSelectedChildren (PortableServer_Servant servant,
55 CORBA_Environment *ev)
57 AtkSelection *selection = get_selection_from_servant (servant);
59 g_return_val_if_fail (selection != NULL, 0);
61 return (CORBA_long) atk_selection_get_selection_count (selection);
65 static Accessibility_Accessible
66 impl_getSelectedChild (PortableServer_Servant servant,
67 const CORBA_long selectedChildIndex,
68 CORBA_Environment *ev)
70 AtkObject *atk_object;
71 AtkSelection *selection = get_selection_from_servant (servant);
73 g_return_val_if_fail (selection != NULL, CORBA_OBJECT_NIL);
76 fprintf (stderr, "calling impl_getSelectedChild\n");
79 atk_object = atk_selection_ref_selection (selection,
80 (gint) selectedChildIndex);
82 g_return_val_if_fail (ATK_IS_OBJECT (atk_object), CORBA_OBJECT_NIL);
85 fprintf (stderr, "child type is %s\n",
86 g_type_name (G_OBJECT_TYPE (atk_object)));
89 return spi_accessible_new_return (atk_object, TRUE, ev);
94 impl_selectChild (PortableServer_Servant servant,
95 const CORBA_long childIndex,
96 CORBA_Environment *ev)
98 AtkSelection *selection = get_selection_from_servant (servant);
100 g_return_val_if_fail (selection != NULL, FALSE);
102 return (CORBA_boolean)
103 atk_selection_add_selection (selection, (gint) 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 (CORBA_boolean)
117 atk_selection_remove_selection (selection, (gint) selectedChildIndex);
122 impl_isChildSelected (PortableServer_Servant servant,
123 const CORBA_long childIndex,
124 CORBA_Environment *ev)
126 AtkSelection *selection = get_selection_from_servant (servant);
128 g_return_val_if_fail (selection != NULL, FALSE);
130 return (CORBA_boolean)
131 atk_selection_is_child_selected (selection, (gint) childIndex);
136 impl_selectAll (PortableServer_Servant servant,
137 CORBA_Environment *ev)
139 AtkSelection *selection = get_selection_from_servant (servant);
141 g_return_if_fail (selection != NULL);
143 atk_selection_select_all_selection (selection);
148 impl_clearSelection (PortableServer_Servant servant,
149 CORBA_Environment *ev)
151 AtkSelection *selection = get_selection_from_servant (servant);
153 g_return_if_fail (selection != NULL);
155 atk_selection_clear_selection (selection);
160 spi_selection_class_init (SpiSelectionClass *klass)
162 POA_Accessibility_Selection__epv *epv = &klass->epv;
164 /* Initialize epv table */
166 epv->_get_nSelectedChildren = impl__get_nSelectedChildren;
167 epv->getSelectedChild = impl_getSelectedChild;
168 epv->selectChild = impl_selectChild;
169 epv->deselectSelectedChild = impl_deselectSelectedChild;
170 epv->isChildSelected = impl_isChildSelected;
171 epv->selectAll = impl_selectAll;
172 epv->clearSelection = impl_clearSelection;
177 spi_selection_init (SpiSelection *selection)
182 BONOBO_TYPE_FUNC_FULL (SpiSelection,
183 Accessibility_Selection,