Fix atspi_accessible_get_description
[platform/upstream/at-spi2-core.git] / atspi / atspi-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 "atspi-private.h"
25
26 /**
27  * atspi_selection_get_n_selected_children:
28  * @obj: a pointer to the #AtspiSelection implementor on which to operate.
29  *
30  * Get the number of children of an #AtspiSelection implementor which are
31  *        currently selected.
32  *
33  * Returns: a #gint indicating the number of #Accessible children
34  *        of the #AtspiSelection implementor which are currently selected.
35  *
36  **/
37 gint
38 atspi_selection_get_n_selected_children (AtspiSelection *obj, GError **error)
39 {
40   dbus_int32_t retval = -1;
41
42   g_return_val_if_fail (obj != NULL, -1);
43
44   _atspi_dbus_get_property (obj, atspi_interface_selection, "nSelectedChildren", error, "i", &retval);
45
46   return retval;
47 }
48
49 /**
50  * atspi_selection_get_selected_child:
51  * @obj: a pointer to the #AtspiSelection on which to operate.
52  * @selected_child_index: a #gint indicating which of the selected
53  *      children is specified.
54  *
55  * Get the i-th selected #AtspiAccessible child of an #AtspiSelection.
56  *      Note that @child_index refers to the index in the list of 'selected'
57  *      children and generally differs from that used in
58  *      #atspi_accessible_get_child_at_index() or returned by
59  *      #atspi_accessible_get_index_in_parent(). @selected_child_index must lie between 0
60  *      and #Atspi_selection_get_n_selected_children()-1, inclusive.
61  *
62  * Returns: (transfer full): a pointer to a selected #AtspiAccessible child
63  *          object, specified by @child_index.
64  *
65  **/
66 AtspiAccessible *
67 atspi_selection_get_selected_child (AtspiSelection *obj,
68                                       gint selected_child_index, GError **error)
69 {
70   dbus_int32_t d_selected_child_index = selected_child_index;
71   AtspiAccessible *child = NULL;
72
73   g_return_val_if_fail (obj != NULL, NULL);
74   
75   _atspi_dbus_call (obj, atspi_interface_selection, "GetSelectedChild", error, "i=>(so)", &d_selected_child_index, &child);
76
77   return child;
78 }
79
80 /**
81  * atspi_selection_select_child:
82  * @obj: a pointer to the #AtspiSelection on which to operate.
83  * @child_index: a #gint indicating which child of the #Accessible
84  *              is to be selected.
85  *
86  * Add a child to the selected children list of an #AtspiSelection.
87  *         For #AtspiSelection implementors that only allow
88  *         single selections, this may replace the (single) current
89  *         selection.
90  *
91  * Returns: #TRUE if the child was successfully selected, #FALSE otherwise.
92  **/
93 gboolean
94 atspi_selection_select_child (AtspiSelection *obj,
95                               gint child_index,
96                               GError **error)
97 {
98   dbus_int32_t d_child_index = child_index;
99   dbus_bool_t retval = FALSE;
100
101   g_return_val_if_fail (obj != NULL, FALSE);
102
103   _atspi_dbus_call (obj, atspi_interface_selection, "SelectChild", error, "i=>b", &d_child_index, &retval);
104
105   return retval;
106 }
107
108 /**
109  * atspi_selection_deselect_selected_child:
110  * @obj: a pointer to the #AtspiSelection on which to operate.
111  * @selected_child_index: a #gint indicating which of the selected children
112  *              of the #Accessible is to be selected.
113  *
114  * Remove a child to the selected children list of an #AtspiSelection.
115  *          Note that @child_index is the index in the selected-children list,
116  *          not the index in the parent container.  @selectedChildIndex in this
117  *          method, and @child_index in #atspi_selection_select_child
118  *          are asymmettric.
119  *
120  * Returns: #TRUE if the child was successfully deselected, #FALSE otherwise.
121  **/
122 gboolean
123 atspi_selection_deselect_selected_child (AtspiSelection *obj,
124                                          gint selected_child_index,
125                                          GError **error)
126 {
127   dbus_int32_t d_selected_child_index = selected_child_index;
128   dbus_bool_t retval = FALSE;
129
130   g_return_val_if_fail (obj != NULL, FALSE);
131
132   _atspi_dbus_call (obj, atspi_interface_selection, "DeselectSelectedChild", error, "i=>b", d_selected_child_index, &retval);
133
134   return retval;
135 }
136
137 /**
138  * atspi_selection_deselect_child:
139  * @obj: a pointer to the #AtspiSelection on which to operate.
140  * @child_index: a #gint indicating which of the children
141  *              of the #AtspiAccessible is to be de-selected.
142  *
143  * Deselect a specific child of an #AtspiSelection.
144  *          Note that @child_index is the index of the child
145  *          in the parent container.
146  * 
147  * See #atspi_selection_deselect_selected_child
148  * 
149  * Returns: #TRUE if the child was successfully deselected, #FALSE otherwise.
150  **/
151 gboolean
152 atspi_selection_deselect_child (AtspiSelection *obj,
153                                 gint child_index,
154                                 GError **error)
155 {
156   dbus_int32_t d_child_index = child_index;
157   dbus_bool_t retval = FALSE;
158
159   g_return_val_if_fail (obj != NULL, FALSE);
160
161   _atspi_dbus_call (obj, atspi_interface_selection, "DeselectChild", error, "i=>b", &d_child_index, &retval);
162
163   return retval;
164 }
165
166 /**
167  * atspi_selection_is_child_selected:
168  * @obj: a pointer to the #AtspiSelection implementor on which to operate.
169  * @child_index: an index into the #AtspiSelection's list of children.
170  *
171  * Determine whether a particular child of an #AtspiSelection implementor
172  *        is currently selected.  Note that @child_index is the index into the
173  *        standard #Accessible container's list of children.
174  *
175  * Returns: #TRUE if the specified child is currently selected,
176  *          #FALSE otherwise.
177  **/
178 gboolean
179 atspi_selection_is_child_selected (AtspiSelection *obj,
180                                    gint child_index,
181                                    GError **error)
182 {
183   dbus_int32_t d_child_index = child_index;
184   dbus_bool_t retval = FALSE;
185
186   g_return_val_if_fail (obj != NULL, FALSE);
187
188   _atspi_dbus_call (obj, atspi_interface_selection, "IsChildSelected", error, "i=>b", &d_child_index, &retval);
189
190   return retval;
191 }
192
193 /**
194  * atspi_selection_select_all:
195  * @obj: a pointer to the #AtspiSelection implementor on which to operate.
196  *
197  * Attempt to select all of the children of an #AtspiSelection implementor.
198  * Not all #AtspiSelection implementors support this operation.
199  *
200  * Returns: #TRUE if successful, #FALSE otherwise.
201  *
202  **/
203 gboolean
204 atspi_selection_select_all (AtspiSelection *obj, GError **error)
205 {
206   dbus_bool_t retval = FALSE;
207   
208   g_return_val_if_fail (obj != NULL, FALSE);
209
210   _atspi_dbus_call (obj, atspi_interface_selection, "SelectAll", error, "=>b", &retval);
211
212   return retval;
213 }
214
215 /**
216  * atspi_selection_clear_selection:
217  * @obj: a pointer to the #AtspiSelection implementor on which to operate.
218  *
219  * Clear the current selection, removing all selected children from the
220  *       specified #AtspiSelection implementor's selection list.
221  *
222  * Returns: #TRUE if successful, #FALSE otherwise.
223  *
224  **/
225 gboolean
226 atspi_selection_clear_selection (AtspiSelection *obj, GError **error)
227 {
228   dbus_bool_t retval = FALSE;
229   
230   g_return_val_if_fail (obj != NULL, FALSE);
231
232   _atspi_dbus_call (obj, atspi_interface_selection, "ClearSelection", error, "=>b", &retval);
233
234   return retval;
235 }
236
237 static void
238 atspi_selection_base_init (AtspiSelection *klass)
239 {
240 }
241
242 GType
243 atspi_selection_get_type (void)
244 {
245   static GType type = 0;
246
247   if (!type) {
248     static const GTypeInfo tinfo =
249     {
250       sizeof (AtspiSelection),
251       (GBaseInitFunc) atspi_selection_base_init,
252       (GBaseFinalizeFunc) NULL,
253     };
254
255     type = g_type_register_static (G_TYPE_INTERFACE, "AtspiSelection", &tinfo, 0);
256
257   }
258   return type;
259 }