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, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include "atkselection.h"
23 * SECTION:atkselection
24 * @Short_description: The ATK interface implemented by container
25 * objects whose #AtkObject children can be selected.
28 * #AtkSelection should be implemented by UI components with children
29 * which are exposed by #atk_object_ref_child and
30 * #atk_object_get_n_children, if the use of the parent UI component
31 * ordinarily involves selection of one or more of the objects
32 * corresponding to those #AtkObject children - for example,
35 * Note that other types of "selection" (for instance text selection)
36 * are accomplished a other ATK interfaces - #AtkSelection is limited
37 * to the selection/deselection of children.
46 static void atk_selection_base_init (gpointer
*g_class
);
48 static guint atk_selection_signals
[LAST_SIGNAL
] = { 0 };
51 atk_selection_get_type (void)
53 static GType type
= 0;
58 sizeof (AtkSelectionIface
),
59 (GBaseInitFunc
)atk_selection_base_init
,
60 (GBaseFinalizeFunc
) NULL
,
64 type
= g_type_register_static (G_TYPE_INTERFACE
, "AtkSelection", &tinfo
, 0);
71 atk_selection_base_init (gpointer
*g_class
)
73 static gboolean initialized
= FALSE
;
78 * AtkSelection::selection-changed:
79 * @atkselection: the object which received the signal.
81 * The "selection-changed" signal is emitted by an object which
82 * implements AtkSelection interface when the selection changes.
84 atk_selection_signals
[SELECTION_CHANGED
] =
85 g_signal_new ("selection_changed",
88 G_STRUCT_OFFSET (AtkSelectionIface
, selection_changed
),
89 (GSignalAccumulator
) NULL
, NULL
,
90 g_cclosure_marshal_VOID__VOID
,
99 * atk_selection_add_selection:
100 * @selection: a #GObject instance that implements AtkSelectionIface
101 * @i: a #gint specifying the child index.
103 * Adds the specified accessible child of the object to the
104 * object's selection.
106 * Returns: TRUE if success, FALSE otherwise.
109 atk_selection_add_selection (AtkSelection
*obj
,
112 AtkSelectionIface
*iface
;
114 g_return_val_if_fail (ATK_IS_SELECTION (obj
), FALSE
);
116 iface
= ATK_SELECTION_GET_IFACE (obj
);
118 if (iface
->add_selection
)
119 return (iface
->add_selection
) (obj
, i
);
125 * atk_selection_clear_selection:
126 * @selection: a #GObject instance that implements AtkSelectionIface
128 * Clears the selection in the object so that no children in the object
131 * Returns: TRUE if success, FALSE otherwise.
134 atk_selection_clear_selection (AtkSelection
*obj
)
136 AtkSelectionIface
*iface
;
138 g_return_val_if_fail (ATK_IS_SELECTION (obj
), FALSE
);
140 iface
= ATK_SELECTION_GET_IFACE (obj
);
142 if (iface
->clear_selection
)
143 return (iface
->clear_selection
) (obj
);
149 * atk_selection_ref_selection:
150 * @selection: a #GObject instance that implements AtkSelectionIface
151 * @i: a #gint specifying the index in the selection set. (e.g. the
152 * ith selection as opposed to the ith child).
154 * Gets a reference to the accessible object representing the specified
155 * selected child of the object.
156 * Note: callers should not rely on %NULL or on a zero value for
157 * indication of whether AtkSelectionIface is implemented, they should
158 * use type checking/interface checking macros or the
159 * atk_get_accessible_value() convenience method.
161 * Returns: (transfer full): an #AtkObject representing the selected
162 * accessible , or %NULL if @selection does not implement this interface.
165 atk_selection_ref_selection (AtkSelection
*obj
,
168 AtkSelectionIface
*iface
;
170 g_return_val_if_fail (ATK_IS_SELECTION (obj
), NULL
);
172 iface
= ATK_SELECTION_GET_IFACE (obj
);
174 if (iface
->ref_selection
)
175 return (iface
->ref_selection
) (obj
, i
);
181 * atk_selection_get_selection_count:
182 * @selection: a #GObject instance that implements AtkSelectionIface
184 * Gets the number of accessible children currently selected.
185 * Note: callers should not rely on %NULL or on a zero value for
186 * indication of whether AtkSelectionIface is implemented, they should
187 * use type checking/interface checking macros or the
188 * atk_get_accessible_value() convenience method.
190 * Returns: a gint representing the number of items selected, or 0
191 * if @selection does not implement this interface.
194 atk_selection_get_selection_count (AtkSelection
*obj
)
196 AtkSelectionIface
*iface
;
198 g_return_val_if_fail (ATK_IS_SELECTION (obj
), 0);
200 iface
= ATK_SELECTION_GET_IFACE (obj
);
202 if (iface
->get_selection_count
)
203 return (iface
->get_selection_count
) (obj
);
209 * atk_selection_is_child_selected:
210 * @selection: a #GObject instance that implements AtkSelectionIface
211 * @i: a #gint specifying the child index.
213 * Determines if the current child of this object is selected
214 * Note: callers should not rely on %NULL or on a zero value for
215 * indication of whether AtkSelectionIface is implemented, they should
216 * use type checking/interface checking macros or the
217 * atk_get_accessible_value() convenience method.
219 * Returns: a gboolean representing the specified child is selected, or 0
220 * if @selection does not implement this interface.
223 atk_selection_is_child_selected (AtkSelection
*obj
,
226 AtkSelectionIface
*iface
;
228 g_return_val_if_fail (ATK_IS_SELECTION (obj
), FALSE
);
230 iface
= ATK_SELECTION_GET_IFACE (obj
);
232 if (iface
->is_child_selected
)
233 return (iface
->is_child_selected
) (obj
, i
);
239 * atk_selection_remove_selection:
240 * @selection: a #GObject instance that implements AtkSelectionIface
241 * @i: a #gint specifying the index in the selection set. (e.g. the
242 * ith selection as opposed to the ith child).
244 * Removes the specified child of the object from the object's selection.
246 * Returns: TRUE if success, FALSE otherwise.
249 atk_selection_remove_selection (AtkSelection
*obj
,
252 AtkSelectionIface
*iface
;
254 g_return_val_if_fail (ATK_IS_SELECTION (obj
), FALSE
);
256 iface
= ATK_SELECTION_GET_IFACE (obj
);
258 if (iface
->remove_selection
)
259 return (iface
->remove_selection
) (obj
, i
);
265 * atk_selection_select_all_selection:
266 * @selection: a #GObject instance that implements AtkSelectionIface
268 * Causes every child of the object to be selected if the object
269 * supports multiple selections.
271 * Returns: TRUE if success, FALSE otherwise.
274 atk_selection_select_all_selection (AtkSelection
*obj
)
276 AtkSelectionIface
*iface
;
278 g_return_val_if_fail (ATK_IS_SELECTION (obj
), FALSE
);
280 iface
= ATK_SELECTION_GET_IFACE (obj
);
282 if (iface
->select_all_selection
)
283 return (iface
->select_all_selection
) (obj
);