2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2007 IBM Corp.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #include "atspi-private.h"
25 /* TODO: Improve documentation and implement some missing functions */
28 * atspi_collection_is_ancester_of:
30 * @collection: The #AtspiCollection to test against.
31 * @test: The #AtspiAccessible to test.
33 * Returns: TRUE if @collection is an ancestor of @test; FALSE otherwise.
35 * Not yet implemented.
38 atspi_collection_is_ancestor_of (AtspiCollection *collection,
39 AtspiAccessible *test,
42 g_warning ("Atspi: TODO: Implement is_ancester_of");
47 new_message (AtspiCollection *collection, char *method)
49 AtspiAccessible *accessible;
54 accessible = ATSPI_ACCESSIBLE (collection);
55 return dbus_message_new_method_call (accessible->parent.app->bus_name,
56 accessible->parent.path,
57 atspi_interface_collection,
62 append_match_rule (DBusMessage *message, AtspiMatchRule *rule)
66 dbus_message_iter_init_append (message, &iter);
67 return _atspi_match_rule_marshal (&iter, rule);
71 append_accessible (DBusMessage *message, AtspiAccessible *accessible)
73 DBusMessageIter iter, iter_struct;
75 dbus_message_iter_init_append (message, &iter);
76 dbus_message_iter_open_container (&iter, DBUS_TYPE_STRUCT, NULL, &iter_struct);
77 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING,
78 &accessible->parent.app->bus_name);
79 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH,
80 &accessible->parent.path);
84 return_accessibles (DBusMessage *message)
86 DBusMessageIter iter, iter_array;
87 GArray *ret = g_array_new (TRUE, TRUE, sizeof (AtspiAccessible *));
89 _ATSPI_DBUS_CHECK_SIG (message, "(so)", NULL);
91 dbus_message_iter_init (message, &iter);
92 dbus_message_iter_recurse (&iter, &iter_array);
94 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
96 AtspiAccessible *accessible;
98 accessible = _atspi_dbus_return_accessible_from_iter (&iter_array);
99 new_array = g_array_append_val (ret, accessible);
102 dbus_message_iter_next (&iter_array);
104 dbus_message_unref (message);
109 * atspi_collection_get_matches:
111 * @collection: The #AtspiCollection.
112 * @rule: A #AtspiMatchRule describing the match criteria.
113 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
115 * @count: The maximum number of results to return, or 0 for no limit.
118 * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
119 * #AtspiAccessibles matching the given match rule.
122 atspi_collection_get_matches (AtspiCollection *collection,
123 AtspiMatchRule *rule,
124 AtspiCollectionSortOrder sortby,
129 DBusMessage *message = new_message (collection, "GetMatches");
131 dbus_int32_t d_sortby = sortby;
132 dbus_int32_t d_count = count;
133 dbus_bool_t d_traverse = traverse;
138 if (!append_match_rule (message, rule))
140 dbus_message_append_args (message, DBUS_TYPE_INT32, &d_sortby,
141 DBUS_TYPE_INT32, &d_count,
142 DBUS_TYPE_BOOLEAN, &d_traverse,
144 reply = _atspi_dbus_send_with_reply_and_block (message);
147 return return_accessibles (reply);
151 * atspi_collection_get_matches_to:
153 * @collection: The #AtspiCollection.
154 * @current_object: The object at which to start searching.
155 * @rule: A #AtspiMatchRule describing the match criteria.
156 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
158 * @tree: An #AtspiCollectionTreeTraversalType specifying restrictions on
159 * the objects to be traversed.
161 * @count: The maximum number of results to return, or 0 for no limit.
164 * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
165 * #AtspiAccessibles matching the given match rule after
169 atspi_collection_get_matches_to (AtspiCollection *collection,
170 AtspiAccessible *current_object,
171 AtspiMatchRule *rule,
172 AtspiCollectionSortOrder sortby,
173 AtspiCollectionTreeTraversalType tree,
179 DBusMessage *message = new_message (collection, "GetMatchesTo");
181 dbus_int32_t d_sortby = sortby;
182 dbus_int32_t d_tree = tree;
183 dbus_bool_t d_recurse = recurse;
184 dbus_int32_t d_count = count;
185 dbus_bool_t d_traverse = traverse;
190 if (!append_accessible (message, current_object))
192 if (!append_match_rule (message, rule))
194 dbus_message_append_args (message, DBUS_TYPE_INT32, &d_sortby,
195 DBUS_TYPE_INT32, &d_tree,
196 DBUS_TYPE_BOOLEAN, &d_recurse,
197 DBUS_TYPE_INT32, &d_count,
198 DBUS_TYPE_BOOLEAN, &d_traverse,
200 reply = _atspi_dbus_send_with_reply_and_block (message);
203 return return_accessibles (reply);
207 * atspi_collection_get_matches_from:
209 * @collection: The #AtspiCollection.
210 * @current_object: Upon reaching this object, searching should stop.
211 * @rule: A #AtspiMatchRule describing the match criteria.
212 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
214 * @tree: An #AtspiCollectionTreeTraversalType specifying restrictions on
215 * the objects to be traversed.
216 * @count: The maximum number of results to return, or 0 for no limit.
219 * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
220 * #AtspiAccessibles matching the given match rule that preceed
224 atspi_collection_get_matches_from (AtspiCollection *collection,
225 AtspiAccessible *current_object,
226 AtspiMatchRule *rule,
227 AtspiCollectionSortOrder sortby,
228 AtspiCollectionTreeTraversalType tree,
233 DBusMessage *message = new_message (collection, "GetMatchesFrom");
235 dbus_int32_t d_sortby = sortby;
236 dbus_int32_t d_tree = tree;
237 dbus_int32_t d_count = count;
238 dbus_bool_t d_traverse = traverse;
243 if (!append_accessible (message, current_object))
245 if (!append_match_rule (message, rule))
247 dbus_message_append_args (message, DBUS_TYPE_INT32, &d_sortby,
248 DBUS_TYPE_INT32, &d_tree,
249 DBUS_TYPE_INT32, &d_count,
250 DBUS_TYPE_BOOLEAN, &d_traverse,
252 reply = _atspi_dbus_send_with_reply_and_block (message);
255 return return_accessibles (reply);
259 * atspi_collection_get_active_descendant:
261 * @collection: The #AtspiCollection to query.
263 * Returns: (transfer full): The active descendant of #collection.
265 * Not yet implemented.
268 atspi_collection_get_active_descendant (AtspiCollection *collection, GError **error)
270 g_warning ("atspi: TODO: Implement get_active_descendants");
275 atspi_collection_base_init (AtspiCollection *klass)
280 atspi_collection_get_type (void)
282 static GType type = 0;
285 static const GTypeInfo tinfo =
287 sizeof (AtspiCollection),
288 (GBaseInitFunc) atspi_collection_base_init,
289 (GBaseFinalizeFunc) NULL,
292 type = g_type_register_static (G_TYPE_INTERFACE, "AtspiCollection", &tinfo, 0);