1 /* ATK - Accessibility Toolkit
2 * Copyright 2001 Sun Microsystems Inc.
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.
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.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 #include "atkselection.h"
21 * SECTION:atkselection
22 * @Short_description: The ATK interface implemented by container
23 * objects whose #AtkObject children can be selected.
26 * #AtkSelection should be implemented by UI components with children
27 * which are exposed by #atk_object_ref_child and
28 * #atk_object_get_n_children, if the use of the parent UI component
29 * ordinarily involves selection of one or more of the objects
30 * corresponding to those #AtkObject children - for example,
33 * Note that other types of "selection" (for instance text selection)
34 * are accomplished a other ATK interfaces - #AtkSelection is limited
35 * to the selection/deselection of children.
44 static void atk_selection_base_init (gpointer *g_class);
46 static guint atk_selection_signals[LAST_SIGNAL] = { 0 };
49 atk_selection_get_type (void)
51 static GType type = 0;
56 sizeof (AtkSelectionIface),
57 (GBaseInitFunc)atk_selection_base_init,
58 (GBaseFinalizeFunc) NULL,
62 type = g_type_register_static (G_TYPE_INTERFACE, "AtkSelection", &tinfo, 0);
69 atk_selection_base_init (gpointer *g_class)
71 static gboolean initialized = FALSE;
76 * AtkSelection::selection-changed:
77 * @atkselection: the object which received the signal.
79 * The "selection-changed" signal is emitted by an object which
80 * implements AtkSelection interface when the selection changes.
82 atk_selection_signals[SELECTION_CHANGED] =
83 g_signal_new ("selection_changed",
86 G_STRUCT_OFFSET (AtkSelectionIface, selection_changed),
87 (GSignalAccumulator) NULL, NULL,
88 g_cclosure_marshal_VOID__VOID,
97 * atk_selection_add_selection:
98 * @selection: a #GObject instance that implements AtkSelectionIface
99 * @i: a #gint specifying the child index.
101 * Adds the specified accessible child of the object to the
102 * object's selection.
104 * Returns: TRUE if success, FALSE otherwise.
107 atk_selection_add_selection (AtkSelection *obj,
110 AtkSelectionIface *iface;
112 g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
114 iface = ATK_SELECTION_GET_IFACE (obj);
116 if (iface->add_selection)
117 return (iface->add_selection) (obj, i);
123 * atk_selection_clear_selection:
124 * @selection: a #GObject instance that implements AtkSelectionIface
126 * Clears the selection in the object so that no children in the object
129 * Returns: TRUE if success, FALSE otherwise.
132 atk_selection_clear_selection (AtkSelection *obj)
134 AtkSelectionIface *iface;
136 g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
138 iface = ATK_SELECTION_GET_IFACE (obj);
140 if (iface->clear_selection)
141 return (iface->clear_selection) (obj);
147 * atk_selection_ref_selection:
148 * @selection: a #GObject instance that implements AtkSelectionIface
149 * @i: a #gint specifying the index in the selection set. (e.g. the
150 * ith selection as opposed to the ith child).
152 * Gets a reference to the accessible object representing the specified
153 * selected child of the object.
154 * Note: callers should not rely on %NULL or on a zero value for
155 * indication of whether AtkSelectionIface is implemented, they should
156 * use type checking/interface checking macros or the
157 * atk_get_accessible_value() convenience method.
159 * Returns: (transfer full): an #AtkObject representing the selected
160 * accessible , or %NULL if @selection does not implement this interface.
163 atk_selection_ref_selection (AtkSelection *obj,
166 AtkSelectionIface *iface;
168 g_return_val_if_fail (ATK_IS_SELECTION (obj), NULL);
170 iface = ATK_SELECTION_GET_IFACE (obj);
172 if (iface->ref_selection)
173 return (iface->ref_selection) (obj, i);
179 * atk_selection_get_selection_count:
180 * @selection: a #GObject instance that implements AtkSelectionIface
182 * Gets the number of accessible children currently selected.
183 * Note: callers should not rely on %NULL or on a zero value for
184 * indication of whether AtkSelectionIface is implemented, they should
185 * use type checking/interface checking macros or the
186 * atk_get_accessible_value() convenience method.
188 * Returns: a gint representing the number of items selected, or 0
189 * if @selection does not implement this interface.
192 atk_selection_get_selection_count (AtkSelection *obj)
194 AtkSelectionIface *iface;
196 g_return_val_if_fail (ATK_IS_SELECTION (obj), 0);
198 iface = ATK_SELECTION_GET_IFACE (obj);
200 if (iface->get_selection_count)
201 return (iface->get_selection_count) (obj);
207 * atk_selection_is_child_selected:
208 * @selection: a #GObject instance that implements AtkSelectionIface
209 * @i: a #gint specifying the child index.
211 * Determines if the current child of this object is selected
212 * Note: callers should not rely on %NULL or on a zero value for
213 * indication of whether AtkSelectionIface is implemented, they should
214 * use type checking/interface checking macros or the
215 * atk_get_accessible_value() convenience method.
217 * Returns: a gboolean representing the specified child is selected, or 0
218 * if @selection does not implement this interface.
221 atk_selection_is_child_selected (AtkSelection *obj,
224 AtkSelectionIface *iface;
226 g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
228 iface = ATK_SELECTION_GET_IFACE (obj);
230 if (iface->is_child_selected)
231 return (iface->is_child_selected) (obj, i);
237 * atk_selection_remove_selection:
238 * @selection: a #GObject instance that implements AtkSelectionIface
239 * @i: a #gint specifying the index in the selection set. (e.g. the
240 * ith selection as opposed to the ith child).
242 * Removes the specified child of the object from the object's selection.
244 * Returns: TRUE if success, FALSE otherwise.
247 atk_selection_remove_selection (AtkSelection *obj,
250 AtkSelectionIface *iface;
252 g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
254 iface = ATK_SELECTION_GET_IFACE (obj);
256 if (iface->remove_selection)
257 return (iface->remove_selection) (obj, i);
263 * atk_selection_select_all_selection:
264 * @selection: a #GObject instance that implements AtkSelectionIface
266 * Causes every child of the object to be selected if the object
267 * supports multiple selections.
269 * Returns: TRUE if success, FALSE otherwise.
272 atk_selection_select_all_selection (AtkSelection *obj)
274 AtkSelectionIface *iface;
276 g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
278 iface = ATK_SELECTION_GET_IFACE (obj);
280 if (iface->select_all_selection)
281 return (iface->select_all_selection) (obj);