source: trunk/third/at-spi/libspi/selection.c @ 18422

Revision 18422, 4.9 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18421, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4 *
5 * Copyright 2001 Sun Microsystems Inc.
6 *
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.
11 *
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.
16 *
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.
21 */
22
23/* selection.c : implements the Selection interface */
24
25#include <config.h>
26#include <stdio.h>
27#include <libspi/accessible.h>
28#include <libspi/selection.h>
29
30
31SpiSelection *
32spi_selection_interface_new (AtkObject *obj)
33{
34  SpiSelection *new_selection = g_object_new (SPI_SELECTION_TYPE, NULL);
35
36  spi_base_construct (SPI_BASE (new_selection), G_OBJECT(obj));
37
38  return new_selection;
39}
40
41
42static AtkSelection *
43get_selection_from_servant (PortableServer_Servant servant)
44{
45  SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
46
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);
50}
51
52
53static CORBA_long
54impl__get_nSelectedChildren (PortableServer_Servant servant,
55                             CORBA_Environment     *ev)
56{
57  AtkSelection *selection = get_selection_from_servant (servant);
58
59  g_return_val_if_fail (selection != NULL, 0);
60
61  return atk_selection_get_selection_count (selection);
62}
63
64
65static Accessibility_Accessible
66impl_getSelectedChild (PortableServer_Servant servant,
67                       const CORBA_long       selectedChildIndex,
68                       CORBA_Environment     *ev)
69{
70  AtkObject    *atk_object;
71  AtkSelection *selection = get_selection_from_servant (servant);
72
73  g_return_val_if_fail (selection != NULL, CORBA_OBJECT_NIL);
74
75#ifdef SPI_DEBUG
76  fprintf (stderr, "calling impl_getSelectedChild\n");
77#endif
78
79  atk_object = atk_selection_ref_selection (selection,
80                                            selectedChildIndex);
81
82  g_return_val_if_fail (ATK_IS_OBJECT (atk_object), CORBA_OBJECT_NIL);
83
84#ifdef SPI_DEBUG
85  fprintf (stderr, "child type is %s\n",
86           g_type_name (G_OBJECT_TYPE (atk_object)));
87#endif
88
89  return spi_accessible_new_return (atk_object, TRUE, ev);
90}
91
92
93static CORBA_boolean
94impl_selectChild (PortableServer_Servant servant,
95                  const CORBA_long       childIndex,
96                  CORBA_Environment     *ev)
97{
98  AtkSelection *selection = get_selection_from_servant (servant);
99
100  g_return_val_if_fail (selection != NULL, FALSE);
101
102  return atk_selection_add_selection (selection, childIndex);
103}
104
105
106static CORBA_boolean
107impl_deselectSelectedChild (PortableServer_Servant servant,
108                            const CORBA_long       selectedChildIndex,
109                            CORBA_Environment     *ev)
110{
111  AtkSelection *selection = get_selection_from_servant (servant);
112
113  g_return_val_if_fail (selection != NULL, FALSE);
114
115  return atk_selection_remove_selection (selection, selectedChildIndex);
116}
117
118
119static CORBA_boolean
120impl_isChildSelected (PortableServer_Servant servant,
121                      const CORBA_long       childIndex,
122                      CORBA_Environment     *ev)
123{
124  AtkSelection *selection = get_selection_from_servant (servant);
125
126  g_return_val_if_fail (selection != NULL, FALSE);
127
128  return atk_selection_is_child_selected (selection, childIndex);
129}
130
131
132static CORBA_boolean
133impl_selectAll (PortableServer_Servant servant,
134                CORBA_Environment     *ev)
135{
136  AtkSelection *selection = get_selection_from_servant (servant);
137
138  g_return_val_if_fail (selection != NULL, FALSE);
139
140  return atk_selection_select_all_selection (selection);
141
142}
143
144
145static CORBA_boolean
146impl_clearSelection (PortableServer_Servant servant,
147                     CORBA_Environment     *ev)
148{
149  AtkSelection *selection = get_selection_from_servant (servant);
150
151  g_return_val_if_fail (selection != NULL, FALSE);
152
153  return atk_selection_clear_selection (selection);
154}
155
156
157static void
158spi_selection_class_init (SpiSelectionClass *klass)
159{
160  POA_Accessibility_Selection__epv *epv = &klass->epv;
161
162  /* Initialize epv table */
163
164  epv->_get_nSelectedChildren = impl__get_nSelectedChildren;
165  epv->getSelectedChild       = impl_getSelectedChild;
166  epv->selectChild            = impl_selectChild;
167  epv->deselectSelectedChild  = impl_deselectSelectedChild;
168  epv->isChildSelected        = impl_isChildSelected;
169  epv->selectAll              = impl_selectAll;
170  epv->clearSelection         = impl_clearSelection;
171}
172
173
174static void
175spi_selection_init (SpiSelection *selection)
176{
177}
178
179
180BONOBO_TYPE_FUNC_FULL (SpiSelection,
181                       Accessibility_Selection,
182                       SPI_TYPE_BASE,
183                       spi_selection);
Note: See TracBrowser for help on using the repository browser.