3c620426d8f3a800ce7a9189b3642211947539d9
[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  * @value: a GObject instance that implements AtkSelectionIface
45  * @return: void
46  **/
47 void
48 atk_selection_add_selection (AtkSelection *obj,
49                              gint         i)
50 {
51   AtkSelectionIface *iface;
52
53   g_return_if_fail (obj != NULL);
54   g_return_if_fail (ATK_IS_SELECTION (obj));
55
56   iface = ATK_SELECTION_GET_IFACE (obj);
57
58   if (iface->add_selection)
59     (iface->add_selection) (obj, i);
60 }
61
62 /**
63  * atk_selection_clear_selection:
64  * @value: a GObject instance that implements AtkSelectionIface
65  * @return: void
66  **/
67 void
68 atk_selection_clear_selection (AtkSelection *obj)
69 {
70   AtkSelectionIface *iface;
71
72   g_return_if_fail (obj != NULL);
73   g_return_if_fail (ATK_IS_SELECTION (obj));
74
75   iface = ATK_SELECTION_GET_IFACE (obj);
76
77   if (iface->clear_selection)
78     (iface->clear_selection) (obj);
79 }
80
81 /**
82  * atk_selection_ref_selection:
83  * @value: a GObject instance that implements AtkSelectionIface
84  * @return: a AtkObject* representing the selected accessible , or NULL
85  * if value does not implement this interface.
86  *
87  * WARNING: callers should not rely on %NULL or on a zero value for
88  * indication of whether AtkSelectionIface is implemented, they should
89  * use type checking/interface checking macros or the
90  * atk_get_accessible_value() convenience method.
91  **/
92 AtkObject*
93 atk_selection_ref_selection (AtkSelection *obj,
94                              gint         i)
95 {
96   AtkSelectionIface *iface;
97
98   g_return_val_if_fail (obj != NULL, NULL);
99   g_return_val_if_fail (ATK_IS_SELECTION (obj), NULL);
100
101   iface = ATK_SELECTION_GET_IFACE (obj);
102
103   if (iface->ref_selection)
104     return (iface->ref_selection) (obj, i);
105   else
106     return NULL;
107 }
108
109 /**
110  * atk_selection_get_selection_count:
111  * @value: a GObject instance that implements AtkSelectionIface
112  * @return: a gint representing the number of items selected, or 0
113  * if value does not implement this interface.
114  *
115  * WARNING: callers should not rely on %NULL or on a zero value for
116  * indication of whether AtkSelectionIface is implemented, they should
117  * use type checking/interface checking macros or the
118  * atk_get_accessible_value() convenience method.
119  **/
120 gint
121 atk_selection_get_selection_count (AtkSelection *obj)
122 {
123   AtkSelectionIface *iface;
124
125   g_return_val_if_fail (obj != NULL, 0);
126   g_return_val_if_fail (ATK_IS_SELECTION (obj), 0);
127
128   iface = ATK_SELECTION_GET_IFACE (obj);
129
130   if (iface->get_selection_count)
131     return (iface->get_selection_count) (obj);
132   else
133     return 0;
134 }
135
136 /**
137  * atk_selection_is_child_selected:
138  * @value: a GObject instance that implements AtkSelectionIface
139  * @return: a gboolean representing the specified child is selected, or 0
140  * if value does not implement this interface.
141  *
142  * WARNING: callers should not rely on %NULL or on a zero value for
143  * indication of whether AtkSelectionIface is implemented, they should
144  * use type checking/interface checking macros or the
145  * atk_get_accessible_value() convenience method.
146  **/
147 gboolean
148 atk_selection_is_child_selected (AtkSelection *obj,
149                                  gint         i)
150 {
151   AtkSelectionIface *iface;
152
153   g_return_val_if_fail (obj != NULL, FALSE);
154   g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
155
156   iface = ATK_SELECTION_GET_IFACE (obj);
157
158   if (iface->is_child_selected)
159     return (iface->is_child_selected) (obj, i);
160   else
161     return FALSE;
162 }
163
164 /**
165  * atk_selection_remove_selection:
166  * @value: a GObject instance that implements AtkSelectionIface
167  * @return: void
168  **/
169 void
170 atk_selection_remove_selection (AtkSelection *obj,
171                                 gint         i)
172 {
173   AtkSelectionIface *iface;
174
175   g_return_if_fail (obj != NULL);
176   g_return_if_fail (ATK_IS_SELECTION (obj));
177
178   iface = ATK_SELECTION_GET_IFACE (obj);
179
180   if (iface->remove_selection)
181     (iface->remove_selection) (obj, i);
182 }
183
184 /**
185  * atk_selection_select_all_selection:
186  * @value: a GObject instance that implements AtkSelectionIface
187  * @return: void
188  **/
189 void
190 atk_selection_select_all_selection (AtkSelection *obj)
191 {
192   AtkSelectionIface *iface;
193
194   g_return_if_fail (obj != NULL);
195   g_return_if_fail (ATK_IS_SELECTION (obj));
196
197   iface = ATK_SELECTION_GET_IFACE (obj);
198
199   if (iface->select_all_selection)
200     (iface->select_all_selection) (obj);
201 }