Removing bitset sentences
[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  * Copyright 2010, 2011 Novell, Inc.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public
20  * License along with this library; if not, write to the
21  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22  * Boston, MA 02111-1307, USA.
23  */
24
25 #include "atspi-private.h"
26
27 /**
28  * atspi_selection_get_n_selected_children:
29  * @obj: a pointer to the #AtspiSelection implementor on which to operate.
30  *
31  * Get the number of children of an #AtspiSelection implementor which are
32  *        currently selected.
33  *
34  * Returns: a #gint indicating the number of #Accessible children
35  *        of the #AtspiSelection implementor which are currently selected.
36  *
37  **/
38 gint
39 atspi_selection_get_n_selected_children (AtspiSelection *obj, GError **error)
40 {
41   dbus_int32_t retval = -1;
42
43   g_return_val_if_fail (obj != NULL, -1);
44
45   _atspi_dbus_get_property (obj, atspi_interface_selection, "NSelectedChildren", error, "i", &retval);
46
47   return retval;
48 }
49
50 /**
51  * atspi_selection_get_selected_child:
52  * @obj: a pointer to the #AtspiSelection on which to operate.
53  * @selected_child_index: a #gint indicating which of the selected
54  *      children is specified.
55  *
56  * Get the i-th selected #AtspiAccessible child of an #AtspiSelection.
57  *      Note that @child_index refers to the index in the list of 'selected'
58  *      children and generally differs from that used in
59  *      #atspi_accessible_get_child_at_index() or returned by
60  *      #atspi_accessible_get_index_in_parent(). @selected_child_index must lie between 0
61  *      and #Atspi_selection_get_n_selected_children()-1, inclusive.
62  *
63  * Returns: (transfer full): a pointer to a selected #AtspiAccessible child
64  *          object, specified by @child_index.
65  *
66  **/
67 AtspiAccessible *
68 atspi_selection_get_selected_child (AtspiSelection *obj,
69                                       gint selected_child_index, GError **error)
70 {
71   dbus_int32_t d_selected_child_index = selected_child_index;
72   DBusMessage *reply;
73
74   g_return_val_if_fail (obj != NULL, NULL);
75   
76   reply = _atspi_dbus_call_partial (obj, atspi_interface_selection,
77                                     "GetSelectedChild", error, "i",
78                                     d_selected_child_index);
79
80   return _atspi_dbus_return_accessible_from_message (reply);
81 }
82
83 /**
84  * atspi_selection_select_child:
85  * @obj: a pointer to the #AtspiSelection on which to operate.
86  * @child_index: a #gint indicating which child of the #Accessible
87  *              is to be selected.
88  *
89  * Add a child to the selected children list of an #AtspiSelection.
90  *         For #AtspiSelection implementors that only allow
91  *         single selections, this may replace the (single) current
92  *         selection.
93  *
94  * Returns: #TRUE if the child was successfully selected, #FALSE otherwise.
95  **/
96 gboolean
97 atspi_selection_select_child (AtspiSelection *obj,
98                               gint child_index,
99                               GError **error)
100 {
101   dbus_int32_t d_child_index = child_index;
102   dbus_bool_t retval = FALSE;
103
104   g_return_val_if_fail (obj != NULL, FALSE);
105
106   _atspi_dbus_call (obj, atspi_interface_selection, "SelectChild", error, "i=>b", &d_child_index, &retval);
107
108   return retval;
109 }
110
111 /**
112  * atspi_selection_deselect_selected_child:
113  * @obj: a pointer to the #AtspiSelection on which to operate.
114  * @selected_child_index: a #gint indicating which of the selected children
115  *              of the #Accessible is to be selected.
116  *
117  * Remove a child to the selected children list of an #AtspiSelection.
118  *          Note that @child_index is the index in the selected-children list,
119  *          not the index in the parent container.  @selectedChildIndex in this
120  *          method, and @child_index in #atspi_selection_select_child
121  *          are asymmettric.
122  *
123  * Returns: #TRUE if the child was successfully deselected, #FALSE otherwise.
124  **/
125 gboolean
126 atspi_selection_deselect_selected_child (AtspiSelection *obj,
127                                          gint selected_child_index,
128                                          GError **error)
129 {
130   dbus_int32_t d_selected_child_index = selected_child_index;
131   dbus_bool_t retval = FALSE;
132
133   g_return_val_if_fail (obj != NULL, FALSE);
134
135   _atspi_dbus_call (obj, atspi_interface_selection, "DeselectSelectedChild", error, "i=>b", d_selected_child_index, &retval);
136
137   return retval;
138 }
139
140 /**
141  * atspi_selection_deselect_child:
142  * @obj: a pointer to the #AtspiSelection on which to operate.
143  * @child_index: a #gint indicating which of the children
144  *              of the #AtspiAccessible is to be de-selected.
145  *
146  * Deselect a specific child of an #AtspiSelection.
147  *          Note that @child_index is the index of the child
148  *          in the parent container.
149  * 
150  * See #atspi_selection_deselect_selected_child
151  * 
152  * Returns: #TRUE if the child was successfully deselected, #FALSE otherwise.
153  **/
154 gboolean
155 atspi_selection_deselect_child (AtspiSelection *obj,
156                                 gint child_index,
157                                 GError **error)
158 {
159   dbus_int32_t d_child_index = child_index;
160   dbus_bool_t retval = FALSE;
161
162   g_return_val_if_fail (obj != NULL, FALSE);
163
164   _atspi_dbus_call (obj, atspi_interface_selection, "DeselectChild", error, "i=>b", &d_child_index, &retval);
165
166   return retval;
167 }
168
169 /**
170  * atspi_selection_is_child_selected:
171  * @obj: a pointer to the #AtspiSelection implementor on which to operate.
172  * @child_index: an index into the #AtspiSelection's list of children.
173  *
174  * Determine whether a particular child of an #AtspiSelection implementor
175  *        is currently selected.  Note that @child_index is the index into the
176  *        standard #Accessible container's list of children.
177  *
178  * Returns: #TRUE if the specified child is currently selected,
179  *          #FALSE otherwise.
180  **/
181 gboolean
182 atspi_selection_is_child_selected (AtspiSelection *obj,
183                                    gint child_index,
184                                    GError **error)
185 {
186   dbus_int32_t d_child_index = child_index;
187   dbus_bool_t retval = FALSE;
188
189   g_return_val_if_fail (obj != NULL, FALSE);
190
191   _atspi_dbus_call (obj, atspi_interface_selection, "IsChildSelected", error, "i=>b", &d_child_index, &retval);
192
193   return retval;
194 }
195
196 /**
197  * atspi_selection_select_all:
198  * @obj: a pointer to the #AtspiSelection implementor on which to operate.
199  *
200  * Attempt to select all of the children of an #AtspiSelection implementor.
201  * Not all #AtspiSelection implementors support this operation.
202  *
203  * Returns: #TRUE if successful, #FALSE otherwise.
204  *
205  **/
206 gboolean
207 atspi_selection_select_all (AtspiSelection *obj, GError **error)
208 {
209   dbus_bool_t retval = FALSE;
210   
211   g_return_val_if_fail (obj != NULL, FALSE);
212
213   _atspi_dbus_call (obj, atspi_interface_selection, "SelectAll", error, "=>b", &retval);
214
215   return retval;
216 }
217
218 /**
219  * atspi_selection_clear_selection:
220  * @obj: a pointer to the #AtspiSelection implementor on which to operate.
221  *
222  * Clear the current selection, removing all selected children from the
223  *       specified #AtspiSelection implementor's selection list.
224  *
225  * Returns: #TRUE if successful, #FALSE otherwise.
226  *
227  **/
228 gboolean
229 atspi_selection_clear_selection (AtspiSelection *obj, GError **error)
230 {
231   dbus_bool_t retval = FALSE;
232   
233   g_return_val_if_fail (obj != NULL, FALSE);
234
235   _atspi_dbus_call (obj, atspi_interface_selection, "ClearSelection", error, "=>b", &retval);
236
237   return retval;
238 }
239
240 static void
241 atspi_selection_base_init (AtspiSelection *klass)
242 {
243 }
244
245 GType
246 atspi_selection_get_type (void)
247 {
248   static GType type = 0;
249
250   if (!type) {
251     static const GTypeInfo tinfo =
252     {
253       sizeof (AtspiSelection),
254       (GBaseInitFunc) atspi_selection_base_init,
255       (GBaseFinalizeFunc) NULL,
256     };
257
258     type = g_type_register_static (G_TYPE_INTERFACE, "AtspiSelection", &tinfo, 0);
259
260   }
261   return type;
262 }