Updated Polish translation
[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 enum {
23   SELECTION_CHANGED,
24   LAST_SIGNAL
25 };
26
27 static void atk_selection_base_init (gpointer *g_class);
28
29 static guint atk_selection_signals[LAST_SIGNAL] = { 0 };
30
31 GType
32 atk_selection_get_type (void)
33 {
34   static GType type = 0;
35
36   if (!type) {
37     GTypeInfo tinfo =
38     {
39       sizeof (AtkSelectionIface),
40       (GBaseInitFunc)atk_selection_base_init,
41       (GBaseFinalizeFunc) NULL,
42
43     };
44
45     type = g_type_register_static (G_TYPE_INTERFACE, "AtkSelection", &tinfo, 0);
46   }
47
48   return type;
49 }
50
51 static void
52 atk_selection_base_init (gpointer *g_class)
53 {
54   static gboolean initialized = FALSE;
55
56   if (! initialized)
57     {
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);
66
67
68       initialized = TRUE;
69     }
70 }
71
72 /**
73  * atk_selection_add_selection:
74  * @selection: a #GObject instance that implements AtkSelectionIface
75  * @i: a #gint specifying the child index.
76  *
77  * Adds the specified accessible child of the object to the
78  * object's selection.
79  *
80  * Returns: TRUE if success, FALSE otherwise.
81  **/
82 gboolean
83 atk_selection_add_selection (AtkSelection *obj,
84                              gint         i)
85 {
86   AtkSelectionIface *iface;
87
88   g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
89
90   iface = ATK_SELECTION_GET_IFACE (obj);
91
92   if (iface->add_selection)
93     return (iface->add_selection) (obj, i);
94   else
95     return FALSE;
96 }
97
98 /**
99  * atk_selection_clear_selection:
100  * @selection: a #GObject instance that implements AtkSelectionIface
101  *
102  * Clears the selection in the object so that no children in the object
103  * are selected.
104  *
105  * Returns: TRUE if success, FALSE otherwise.
106  **/
107 gboolean
108 atk_selection_clear_selection (AtkSelection *obj)
109 {
110   AtkSelectionIface *iface;
111
112   g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
113
114   iface = ATK_SELECTION_GET_IFACE (obj);
115
116   if (iface->clear_selection)
117     return (iface->clear_selection) (obj);
118   else
119     return FALSE;
120 }
121
122 /**
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).
127  *
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.
134  *
135  * Returns: an #AtkObject representing the selected accessible , or %NULL
136  * if @selection does not implement this interface.
137  **/
138 AtkObject*
139 atk_selection_ref_selection (AtkSelection *obj,
140                              gint         i)
141 {
142   AtkSelectionIface *iface;
143
144   g_return_val_if_fail (ATK_IS_SELECTION (obj), NULL);
145
146   iface = ATK_SELECTION_GET_IFACE (obj);
147
148   if (iface->ref_selection)
149     return (iface->ref_selection) (obj, i);
150   else
151     return NULL;
152 }
153
154 /**
155  * atk_selection_get_selection_count:
156  * @selection: a #GObject instance that implements AtkSelectionIface
157  *
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.
163  *
164  * Returns: a gint representing the number of items selected, or 0
165  * if @selection does not implement this interface.
166  **/
167 gint
168 atk_selection_get_selection_count (AtkSelection *obj)
169 {
170   AtkSelectionIface *iface;
171
172   g_return_val_if_fail (ATK_IS_SELECTION (obj), 0);
173
174   iface = ATK_SELECTION_GET_IFACE (obj);
175
176   if (iface->get_selection_count)
177     return (iface->get_selection_count) (obj);
178   else
179     return 0;
180 }
181
182 /**
183  * atk_selection_is_child_selected:
184  * @selection: a #GObject instance that implements AtkSelectionIface
185  * @i: a #gint specifying the child index.
186  *
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.
192  *
193  * Returns: a gboolean representing the specified child is selected, or 0
194  * if @selection does not implement this interface.
195  **/
196 gboolean
197 atk_selection_is_child_selected (AtkSelection *obj,
198                                  gint         i)
199 {
200   AtkSelectionIface *iface;
201
202   g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
203
204   iface = ATK_SELECTION_GET_IFACE (obj);
205
206   if (iface->is_child_selected)
207     return (iface->is_child_selected) (obj, i);
208   else
209     return FALSE;
210 }
211
212 /**
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).
217  *
218  * Removes the specified child of the object from the object's selection.
219  *
220  * Returns: TRUE if success, FALSE otherwise.
221  **/
222 gboolean
223 atk_selection_remove_selection (AtkSelection *obj,
224                                 gint         i)
225 {
226   AtkSelectionIface *iface;
227
228   g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
229
230   iface = ATK_SELECTION_GET_IFACE (obj);
231
232   if (iface->remove_selection)
233     return (iface->remove_selection) (obj, i);
234   else
235     return FALSE;
236 }
237
238 /**
239  * atk_selection_select_all_selection:
240  * @selection: a #GObject instance that implements AtkSelectionIface
241  *
242  * Causes every child of the object to be selected if the object
243  * supports multiple selections.
244  *
245  * Returns: TRUE if success, FALSE otherwise.
246  **/
247 gboolean
248 atk_selection_select_all_selection (AtkSelection *obj)
249 {
250   AtkSelectionIface *iface;
251
252   g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
253
254   iface = ATK_SELECTION_GET_IFACE (obj);
255
256   if (iface->select_all_selection)
257     return (iface->select_all_selection) (obj);
258   else
259     return FALSE;
260 }