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>
30 /* A pointer to our parent object class */
31 static GObjectClass *parent_class;
34 spi_selection_finalize (GObject *obj)
36 SpiSelection *selection = SPI_SELECTION (obj);
37 g_object_unref (selection->atko);
38 selection->atko = NULL;
39 parent_class->finalize (obj);
43 spi_selection_interface_new (AtkObject *obj)
45 SpiSelection *new_selection = g_object_new (SPI_SELECTION_TYPE, NULL);
46 new_selection->atko = obj;
54 impl__get_nSelectedChildren (PortableServer_Servant _servant,
55 CORBA_Environment * ev)
57 BonoboObject *obj = bonobo_object_from_servant (_servant);
58 SpiSelection *selection;
60 fprintf (stderr, "calling impl__get_nSelectedChildren\n");
62 g_return_val_if_fail (IS_SPI_SELECTION (obj), 0);
63 selection = SPI_SELECTION (obj);
64 g_return_val_if_fail (ATK_IS_SELECTION (selection->atko), 0);
66 atk_selection_get_selection_count (ATK_SELECTION(selection->atko));
70 static Accessibility_Accessible
71 impl_getSelectedChild (PortableServer_Servant _servant,
72 const CORBA_long selectedChildIndex,
73 CORBA_Environment * ev)
75 BonoboObject *obj = bonobo_object_from_servant (_servant);
78 AtkObject *atk_object;
79 Accessibility_Accessible rv;
81 fprintf (stderr, "calling impl_getSelectedChild\n");
83 g_return_val_if_fail (IS_SPI_SELECTION (obj), 0);
84 selection = SPI_SELECTION (obj);
85 g_return_val_if_fail (ATK_IS_SELECTION (selection->atko), 0);
87 atk_object = atk_selection_ref_selection (ATK_SELECTION (selection->atko),
88 (gint) selectedChildIndex);
89 g_return_val_if_fail (ATK_IS_OBJECT (atk_object), NULL);
91 fprintf (stderr, "child type is %s\n", g_type_name (G_OBJECT_TYPE (atk_object)));
93 rv = bonobo_object_corba_objref (bonobo_object (spi_accessible_new (atk_object)));
94 g_object_unref (atk_object);
95 return CORBA_Object_duplicate (rv, ev);
101 impl_selectChild (PortableServer_Servant _servant,
102 const CORBA_long childIndex,
103 CORBA_Environment * ev)
105 SpiSelection *selection = SPI_SELECTION (bonobo_object_from_servant (_servant));
106 return (CORBA_boolean)
107 atk_selection_add_selection (ATK_SELECTION(selection->atko), (gint) childIndex);
114 impl_deselectSelectedChild (PortableServer_Servant _servant,
115 const CORBA_long selectedChildIndex,
116 CORBA_Environment * ev)
118 SpiSelection *selection = SPI_SELECTION (bonobo_object_from_servant (_servant));
119 return (CORBA_boolean)
120 atk_selection_remove_selection (ATK_SELECTION(selection->atko), (gint) selectedChildIndex);
126 impl_isChildSelected (PortableServer_Servant _servant,
127 const CORBA_long childIndex,
128 CORBA_Environment * ev)
130 SpiSelection *selection = SPI_SELECTION (bonobo_object_from_servant (_servant));
131 return (CORBA_boolean)
132 atk_selection_is_child_selected (ATK_SELECTION(selection->atko), (gint) childIndex);
138 impl_selectAll (PortableServer_Servant _servant,
139 CORBA_Environment * ev)
141 SpiSelection *selection = SPI_SELECTION (bonobo_object_from_servant (_servant));
142 atk_selection_select_all_selection (ATK_SELECTION(selection->atko));
148 impl_clearSelection (PortableServer_Servant _servant,
149 CORBA_Environment * ev)
151 SpiSelection *selection = SPI_SELECTION (bonobo_object_from_servant (_servant));
152 atk_selection_clear_selection (ATK_SELECTION(selection->atko));
156 spi_selection_class_init (SpiSelectionClass *klass)
158 GObjectClass * object_class = (GObjectClass *) klass;
159 POA_Accessibility_Selection__epv *epv = &klass->epv;
160 parent_class = g_type_class_peek_parent (klass);
162 object_class->finalize = spi_selection_finalize;
165 /* Initialize epv table */
167 epv->_get_nSelectedChildren = impl__get_nSelectedChildren;
168 epv->getSelectedChild = impl_getSelectedChild;
169 epv->selectChild = impl_selectChild;
170 epv->deselectSelectedChild = impl_deselectSelectedChild;
171 epv->isChildSelected = impl_isChildSelected;
172 epv->selectAll = impl_selectAll;
173 epv->clearSelection = impl_clearSelection;
177 spi_selection_init (SpiSelection *selection)
181 BONOBO_TYPE_FUNC_FULL (SpiSelection,
182 Accessibility_Selection,