Added better gtk-doc comments.
[platform/upstream/atk.git] / atk / atkselection.c
1 /* ATK -  Accessibility Toolkit
2  * Copyright 2001 Sun Microsystems Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include "atkselection.h"
21
22 GType
23 atk_selection_get_type ()
24 {
25   static GType type = 0;
26
27   if (!type) {
28     GTypeInfo tinfo =
29     {
30       sizeof (AtkSelectionIface),
31       NULL,
32       NULL,
33
34     };
35
36     type = g_type_register_static (G_TYPE_INTERFACE, "AtkSelection", &tinfo, 0);
37   }
38
39   return type;
40 }
41
42 /**
43  * atk_selection_add_selection:
44  * @selection: a GObject instance that implements AtkSelectionIface
45  * @i: a #gint specifying an accessible child of @selection 
46  *
47  * Adds the specified accessible child of the object to the
48  * object's selection.
49  **/
50 void
51 atk_selection_add_selection (AtkSelection *obj,
52                              gint         i)
53 {
54   AtkSelectionIface *iface;
55
56   g_return_if_fail (obj != NULL);
57   g_return_if_fail (ATK_IS_SELECTION (obj));
58
59   iface = ATK_SELECTION_GET_IFACE (obj);
60
61   if (iface->add_selection)
62     (iface->add_selection) (obj, i);
63 }
64
65 /**
66  * atk_selection_clear_selection:
67  * @selection: a GObject instance that implements AtkSelectionIface
68  *
69  * Clears the selection in the object so that no children in the object
70  * are selected.
71  **/
72 void
73 atk_selection_clear_selection (AtkSelection *obj)
74 {
75   AtkSelectionIface *iface;
76
77   g_return_if_fail (obj != NULL);
78   g_return_if_fail (ATK_IS_SELECTION (obj));
79
80   iface = ATK_SELECTION_GET_IFACE (obj);
81
82   if (iface->clear_selection)
83     (iface->clear_selection) (obj);
84 }
85
86 /**
87  * atk_selection_ref_selection:
88  * @selection: a GObject instance that implements AtkSelectionIface
89  * @i: a #gint specifying an accessible child of @selection 
90  *
91  * Gets a reference to the accessible object representing the specified 
92  * selected * child of the object.
93  * Note: callers should not rely on %NULL or on a zero value for
94  * indication of whether AtkSelectionIface is implemented, they should
95  * use type checking/interface checking macros or the
96  * atk_get_accessible_value() convenience method.
97  *
98  * Returns: a AtkObject* representing the selected accessible , or NULL
99  * if value does not implement this interface.
100  **/
101 AtkObject*
102 atk_selection_ref_selection (AtkSelection *obj,
103                              gint         i)
104 {
105   AtkSelectionIface *iface;
106
107   g_return_val_if_fail (obj != NULL, NULL);
108   g_return_val_if_fail (ATK_IS_SELECTION (obj), NULL);
109
110   iface = ATK_SELECTION_GET_IFACE (obj);
111
112   if (iface->ref_selection)
113     return (iface->ref_selection) (obj, i);
114   else
115     return NULL;
116 }
117
118 /**
119  * atk_selection_get_selection_count:
120  * @selection: a GObject instance that implements AtkSelectionIface
121  *
122  * Gets the number of accessible children currently selected.
123  * Note: callers should not rely on %NULL or on a zero value for
124  * indication of whether AtkSelectionIface is implemented, they should
125  * use type checking/interface checking macros or the
126  * atk_get_accessible_value() convenience method.
127  *
128  * Returns: a gint representing the number of items selected, or 0
129  * if value does not implement this interface.
130  **/
131 gint
132 atk_selection_get_selection_count (AtkSelection *obj)
133 {
134   AtkSelectionIface *iface;
135
136   g_return_val_if_fail (obj != NULL, 0);
137   g_return_val_if_fail (ATK_IS_SELECTION (obj), 0);
138
139   iface = ATK_SELECTION_GET_IFACE (obj);
140
141   if (iface->get_selection_count)
142     return (iface->get_selection_count) (obj);
143   else
144     return 0;
145 }
146
147 /**
148  * atk_selection_is_child_selected:
149  * @selection: a GObject instance that implements AtkSelectionIface
150  * @i: a #gint specifying an accessible child of @selection 
151  *
152  * Determines if the current child of this object is selected
153  * Note: callers should not rely on %NULL or on a zero value for
154  * indication of whether AtkSelectionIface is implemented, they should
155  * use type checking/interface checking macros or the
156  * atk_get_accessible_value() convenience method.
157  *
158  * Returns: a gboolean representing the specified child is selected, or 0
159  * if value does not implement this interface.
160  **/
161 gboolean
162 atk_selection_is_child_selected (AtkSelection *obj,
163                                  gint         i)
164 {
165   AtkSelectionIface *iface;
166
167   g_return_val_if_fail (obj != NULL, FALSE);
168   g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
169
170   iface = ATK_SELECTION_GET_IFACE (obj);
171
172   if (iface->is_child_selected)
173     return (iface->is_child_selected) (obj, i);
174   else
175     return FALSE;
176 }
177
178 /**
179  * atk_selection_remove_selection:
180  * @selection: a GObject instance that implements AtkSelectionIface
181  * @i: a #gint specifying an accessible child of @selection 
182  *
183  * Removes the specified child of the object from the object's selection.
184  **/
185 void
186 atk_selection_remove_selection (AtkSelection *obj,
187                                 gint         i)
188 {
189   AtkSelectionIface *iface;
190
191   g_return_if_fail (obj != NULL);
192   g_return_if_fail (ATK_IS_SELECTION (obj));
193
194   iface = ATK_SELECTION_GET_IFACE (obj);
195
196   if (iface->remove_selection)
197     (iface->remove_selection) (obj, i);
198 }
199
200 /**
201  * atk_selection_select_all_selection:
202  * @selection: a GObject instance that implements AtkSelectionIface
203  *
204  * Causes every child of the object to be selected if the object
205  * supports multiple selections.
206  **/
207 void
208 atk_selection_select_all_selection (AtkSelection *obj)
209 {
210   AtkSelectionIface *iface;
211
212   g_return_if_fail (obj != NULL);
213   g_return_if_fail (ATK_IS_SELECTION (obj));
214
215   iface = ATK_SELECTION_GET_IFACE (obj);
216
217   if (iface->select_all_selection)
218     (iface->select_all_selection) (obj);
219 }