Revved to 1.10.3, to fix previous bad dist due to libtool bug.
[atk.git] / atk / atkselection.c
blob4088fa826538fcc1842d759d1d6df44a870b0129
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"
22 enum {
23 SELECTION_CHANGED,
24 LAST_SIGNAL
27 static void atk_selection_base_init (gpointer *g_class);
29 static guint atk_selection_signals[LAST_SIGNAL] = { 0 };
31 GType
32 atk_selection_get_type (void)
34 static GType type = 0;
36 if (!type) {
37 GTypeInfo tinfo =
39 sizeof (AtkSelectionIface),
40 (GBaseInitFunc)atk_selection_base_init,
41 (GBaseFinalizeFunc) NULL,
45 type = g_type_register_static (G_TYPE_INTERFACE, "AtkSelection", &tinfo, 0);
48 return type;
51 static void
52 atk_selection_base_init (gpointer *g_class)
54 static gboolean initialized = FALSE;
56 if (! initialized)
58 atk_selection_signals[SELECTION_CHANGED] =
59 g_signal_new ("selection_changed",
60 ATK_TYPE_SELECTION,
61 G_SIGNAL_RUN_LAST,
62 G_STRUCT_OFFSET (AtkSelectionIface, selection_changed),
63 (GSignalAccumulator) NULL, NULL,
64 g_cclosure_marshal_VOID__VOID,
65 G_TYPE_NONE, 0);
68 initialized = TRUE;
72 /**
73 * atk_selection_add_selection:
74 * @selection: a #GObject instance that implements AtkSelectionIface
75 * @i: a #gint specifying the child index.
77 * Adds the specified accessible child of the object to the
78 * object's selection.
80 * Returns: TRUE if success, FALSE otherwise.
81 **/
82 gboolean
83 atk_selection_add_selection (AtkSelection *obj,
84 gint i)
86 AtkSelectionIface *iface;
88 g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
90 iface = ATK_SELECTION_GET_IFACE (obj);
92 if (iface->add_selection)
93 return (iface->add_selection) (obj, i);
94 else
95 return FALSE;
98 /**
99 * atk_selection_clear_selection:
100 * @selection: a #GObject instance that implements AtkSelectionIface
102 * Clears the selection in the object so that no children in the object
103 * are selected.
105 * Returns: TRUE if success, FALSE otherwise.
107 gboolean
108 atk_selection_clear_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->clear_selection)
117 return (iface->clear_selection) (obj);
118 else
119 return FALSE;
123 * atk_selection_ref_selection:
124 * @selection: a #GObject instance that implements AtkSelectionIface
125 * @i: a #gint specifying the index in the selection set. (e.g. the
126 * ith selection as opposed to the ith child).
128 * Gets a reference to the accessible object representing the specified
129 * selected child of the object.
130 * Note: callers should not rely on %NULL or on a zero value for
131 * indication of whether AtkSelectionIface is implemented, they should
132 * use type checking/interface checking macros or the
133 * atk_get_accessible_value() convenience method.
135 * Returns: an #AtkObject representing the selected accessible , or %NULL
136 * if @selection does not implement this interface.
138 AtkObject*
139 atk_selection_ref_selection (AtkSelection *obj,
140 gint i)
142 AtkSelectionIface *iface;
144 g_return_val_if_fail (ATK_IS_SELECTION (obj), NULL);
146 iface = ATK_SELECTION_GET_IFACE (obj);
148 if (iface->ref_selection)
149 return (iface->ref_selection) (obj, i);
150 else
151 return NULL;
155 * atk_selection_get_selection_count:
156 * @selection: a #GObject instance that implements AtkSelectionIface
158 * Gets the number of accessible children currently selected.
159 * Note: callers should not rely on %NULL or on a zero value for
160 * indication of whether AtkSelectionIface is implemented, they should
161 * use type checking/interface checking macros or the
162 * atk_get_accessible_value() convenience method.
164 * Returns: a gint representing the number of items selected, or 0
165 * if @selection does not implement this interface.
167 gint
168 atk_selection_get_selection_count (AtkSelection *obj)
170 AtkSelectionIface *iface;
172 g_return_val_if_fail (ATK_IS_SELECTION (obj), 0);
174 iface = ATK_SELECTION_GET_IFACE (obj);
176 if (iface->get_selection_count)
177 return (iface->get_selection_count) (obj);
178 else
179 return 0;
183 * atk_selection_is_child_selected:
184 * @selection: a #GObject instance that implements AtkSelectionIface
185 * @i: a #gint specifying the child index.
187 * Determines if the current child of this object is selected
188 * Note: callers should not rely on %NULL or on a zero value for
189 * indication of whether AtkSelectionIface is implemented, they should
190 * use type checking/interface checking macros or the
191 * atk_get_accessible_value() convenience method.
193 * Returns: a gboolean representing the specified child is selected, or 0
194 * if @selection does not implement this interface.
196 gboolean
197 atk_selection_is_child_selected (AtkSelection *obj,
198 gint i)
200 AtkSelectionIface *iface;
202 g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
204 iface = ATK_SELECTION_GET_IFACE (obj);
206 if (iface->is_child_selected)
207 return (iface->is_child_selected) (obj, i);
208 else
209 return FALSE;
213 * atk_selection_remove_selection:
214 * @selection: a #GObject instance that implements AtkSelectionIface
215 * @i: a #gint specifying the index in the selection set. (e.g. the
216 * ith selection as opposed to the ith child).
218 * Removes the specified child of the object from the object's selection.
220 * Returns: TRUE if success, FALSE otherwise.
222 gboolean
223 atk_selection_remove_selection (AtkSelection *obj,
224 gint i)
226 AtkSelectionIface *iface;
228 g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
230 iface = ATK_SELECTION_GET_IFACE (obj);
232 if (iface->remove_selection)
233 return (iface->remove_selection) (obj, i);
234 else
235 return FALSE;
239 * atk_selection_select_all_selection:
240 * @selection: a #GObject instance that implements AtkSelectionIface
242 * Causes every child of the object to be selected if the object
243 * supports multiple selections.
245 * Returns: TRUE if success, FALSE otherwise.
247 gboolean
248 atk_selection_select_all_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->select_all_selection)
257 return (iface->select_all_selection) (obj);
258 else
259 return FALSE;