Add AT-SPI mapping for ATK_RELATION_NODE_PARENT_OF
[platform/core/uifw/at-spi2-atk.git] / cspi / spi-selection.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001, 2002 Sun Microsystems Inc.,
6  * Copyright 2001, 2002 Ximian, Inc.
7  *
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.
12  *
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.
17  *
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.
22  */
23
24 #include <cspi/spi-private.h>
25
26 /**
27  * AccessibleSelection_ref:
28  * @obj: a pointer to the #AccessibleSelection implementor on which to operate.
29  *
30  * Increment the reference count for an #AccessibleSelection object.
31  *
32  **/
33 void
34 AccessibleSelection_ref (AccessibleSelection *obj)
35 {
36   cspi_object_ref (obj);
37 }
38
39 /**
40  * AccessibleSelection_unref:
41  * @obj: a pointer to the #AccessibleSelection implementor on which to operate. 
42  *
43  * Decrement the reference count for an #Accessible object.
44  *
45  **/
46 void
47 AccessibleSelection_unref (AccessibleSelection *obj)
48 {
49   cspi_object_unref (obj);
50 }
51
52 /**
53  * AccessibleSelection_getNSelectedChildren:
54  * @obj: a pointer to the #AccessibleSelection implementor on which to operate.
55  *
56  * Get the number of children of an #AccessibleSelection implementor which are
57  *        currently selected.
58  *
59  * Returns: a #long indicating the number of #Accessible children
60  *        of the #AccessibleSelection implementor which are currently selected.
61  *
62  **/
63 long
64 AccessibleSelection_getNSelectedChildren (AccessibleSelection *obj)
65 {
66   dbus_int32_t retval;
67
68   cspi_return_val_if_fail (obj != NULL, -1);
69
70   cspi_dbus_get_property (obj, spi_interface_selection, "nSelectedChildren", NULL, "i", &retval);
71
72   cspi_return_val_if_ev ("getNSelectedChildren", -1);
73
74   return retval;
75 }
76
77 /**
78  * AccessibleSelection_getSelectedChild:
79  * @obj: a pointer to the #AccessibleSelection on which to operate.
80  * @selectedChildIndex: a #long indicating which of the selected
81  *      children is specified.
82  *
83  * Get the i-th selected #Accessible child of an #AccessibleSelection.
84  *      Note that @childIndex refers to the index in the list of 'selected'
85  *      children and generally differs from that used in
86  *      #Accessible_getChildAtIndex() or returned by
87  *      #Accessible_getIndexInParent(). @selectedChildIndex must lie between 0
88  *      and #AccessibleSelection_getNSelectedChildren()-1, inclusive.
89  *
90  * Returns: a pointer to a selected #Accessible child object,
91  *          specified by @childIndex.
92  *
93  **/
94 Accessible *
95 AccessibleSelection_getSelectedChild (AccessibleSelection *obj,
96                                       long int selectedChildIndex)
97 {
98   dbus_int32_t d_selectedChildIndex = selectedChildIndex;
99   char *path;
100   Accessible *child;
101
102   cspi_return_val_if_fail (obj != NULL, NULL);
103   
104   cspi_dbus_call (obj, spi_interface_selection, "getSelectedChild", NULL, "i=>o", &d_selectedChildIndex, &path);
105   child = cspi_ref_related_accessible (obj, path);
106   g_free (path);
107   return child;
108 }
109
110 /**
111  * AccessibleSelection_selectChild:
112  * @obj: a pointer to the #AccessibleSelection on which to operate.
113  * @childIndex: a #long indicating which child of the #Accessible
114  *              is to be selected.
115  *
116  * Add a child to the selected children list of an #AccessibleSelection.
117  *         For #AccessibleSelection implementors that only allow
118  *         single selections, this may replace the (single) current
119  *         selection.
120  *
121  * Returns: #TRUE if the child was successfully selected, #FALSE otherwise.
122  **/
123 SPIBoolean
124 AccessibleSelection_selectChild (AccessibleSelection *obj,
125                                  long int childIndex)
126 {
127   dbus_int32_t d_childIndex = childIndex;
128   dbus_bool_t retval;
129
130   cspi_return_val_if_fail (obj != NULL, FALSE);
131
132   cspi_dbus_call (obj, spi_interface_selection, "selectChild", NULL, "i=>b", &d_childIndex, &retval);
133
134   cspi_return_val_if_ev ("selectChild", FALSE);
135
136   return retval;
137 }
138
139 /**
140  * AccessibleSelection_deselectSelectedChild:
141  * @obj: a pointer to the #AccessibleSelection on which to operate.
142  * @selectedChildIndex: a #long indicating which of the selected children
143  *              of the #Accessible is to be selected.
144  *
145  * Remove a child to the selected children list of an #AccessibleSelection.
146  *          Note that @childIndex is the index in the selected-children list,
147  *          not the index in the parent container.  @selectedChildIndex in this
148  *          method, and @childIndex in #AccessibleSelection_selectChild
149  *          are asymmettric.
150  *
151  * Returns: #TRUE if the child was successfully deselected, #FALSE otherwise.
152  **/
153 SPIBoolean
154 AccessibleSelection_deselectSelectedChild (AccessibleSelection *obj,
155                                            long int selectedChildIndex)
156 {
157   dbus_int32_t d_selectedChildIndex = selectedChildIndex;
158   dbus_bool_t retval;
159
160   cspi_return_val_if_fail (obj != NULL, FALSE);
161
162   cspi_dbus_call (obj, spi_interface_selection, "deselectSelectedChild", NULL, "i=>b", &d_selectedChildIndex, &retval);
163
164   cspi_return_val_if_ev ("deselectSelectedChild", FALSE);
165
166   return retval;
167 }
168
169 /**
170  * AccessibleSelection_deselectChild:
171  * @obj: a pointer to the #AccessibleSelection on which to operate.
172  * @childIndex: a #long indicating which of the children
173  *              of the #Accessible is to be de-selected.
174  *
175  * Deselect a specific child of an #AccessibleSelection.
176  *          Note that @childIndex is the index of the child
177  *          in the parent container.
178  * 
179  * See #AccessibleSelection_deselectSelectedChild
180  *
181  * Since AT-SPI 1.8.0
182  * 
183  * Returns: #TRUE if the child was successfully deselected, #FALSE otherwise.
184  **/
185 SPIBoolean
186 AccessibleSelection_deselectChild (AccessibleSelection *obj,
187                                    long int childIndex)
188 {
189   dbus_int32_t d_childIndex = childIndex;
190   dbus_bool_t retval;
191
192   cspi_return_val_if_fail (obj != NULL, FALSE);
193
194   cspi_dbus_call (obj, spi_interface_selection, "deselectChild", NULL, "i=>b", &d_childIndex, &retval);
195
196   cspi_return_val_if_ev ("deselectChild", FALSE);
197
198   return retval;
199 }
200
201 /**
202  * AccessibleSelection_isChildSelected:
203  * @obj: a pointer to the #AccessibleSelection implementor on which to operate.
204  * @childIndex: an index into the #AccessibleSelection's list of children.
205  *
206  * Determine whether a particular child of an #AccessibleSelection implementor
207  *        is currently selected.  Note that @childIndex is the index into the
208  *        standard #Accessible container's list of children.
209  *
210  * Returns: #TRUE if the specified child is currently selected,
211  *          #FALSE otherwise.
212  **/
213 SPIBoolean
214 AccessibleSelection_isChildSelected (AccessibleSelection *obj,
215                                      long int childIndex)
216 {
217   dbus_int32_t d_childIndex = childIndex;
218   dbus_bool_t retval;
219
220   cspi_return_val_if_fail (obj != NULL, FALSE);
221
222   cspi_dbus_call (obj, spi_interface_selection, "isChildSelected", NULL, "i=>b", &d_childIndex, &retval);
223
224   cspi_return_val_if_ev ("isChildSelected", FALSE);
225
226   return retval;
227 }
228
229 /**
230  * AccessibleSelection_selectAll:
231  * @obj: a pointer to the #AccessibleSelection implementor on which to operate.
232  *
233  * Attempt to select all of the children of an #AccessibleSelection implementor.
234  * Not all #AccessibleSelection implementors support this operation.
235  *
236  * Returns: #TRUE if successful, #FALSE otherwise.
237  *
238  **/
239 SPIBoolean
240 AccessibleSelection_selectAll (AccessibleSelection *obj)
241 {
242   dbus_bool_t retval;
243   
244   cspi_return_val_if_fail (obj != NULL, FALSE);
245
246   cspi_dbus_call (obj, spi_interface_selection, "selectAll", NULL, "=>b", &retval);
247
248   cspi_return_val_if_ev ("selectAll", FALSE);
249
250   return retval;
251 }
252
253 /**
254  * AccessibleSelection_clearSelection:
255  * @obj: a pointer to the #AccessibleSelection implementor on which to operate.
256  *
257  * Clear the current selection, removing all selected children from the
258  *       specified #AccessibleSelection implementor's selection list.
259  *
260  * Returns: #TRUE if successful, #FALSE otherwise.
261  *
262  **/
263 SPIBoolean
264 AccessibleSelection_clearSelection (AccessibleSelection *obj)
265 {
266   dbus_bool_t retval;
267   
268   cspi_return_val_if_fail (obj != NULL, FALSE);
269
270   cspi_dbus_call (obj, spi_interface_selection, "clearSelection", NULL, "=>b", &retval);
271
272   return retval;
273 }
274