2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2007 IBM Corp.
6 * Copyright 2010, 2011 Novell, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 #include "atspi-private.h"
26 /* TODO: Improve documentation and implement some missing functions */
29 * atspi_collection_is_ancestor_of:
31 * Not yet implemented.
35 atspi_collection_is_ancestor_of (AtspiCollection *collection,
36 AtspiAccessible *test,
39 g_warning ("Atspi: TODO: Implement is_ancestor_of");
44 new_message (AtspiCollection *collection, char *method)
46 AtspiAccessible *accessible;
51 accessible = ATSPI_ACCESSIBLE (collection);
52 return dbus_message_new_method_call (accessible->parent.app->bus_name,
53 accessible->parent.path,
54 atspi_interface_collection,
59 append_match_rule (DBusMessage *message, AtspiMatchRule *rule)
63 dbus_message_iter_init_append (message, &iter);
64 return _atspi_match_rule_marshal (rule, &iter);
68 append_accessible (DBusMessage *message, AtspiAccessible *accessible)
72 dbus_message_iter_init_append (message, &iter);
73 dbus_message_iter_append_basic (&iter, DBUS_TYPE_OBJECT_PATH,
74 &accessible->parent.path);
75 return TRUE; /* TODO: Check for out-of-memory */
79 return_accessibles (DBusMessage *message)
81 DBusMessageIter iter, iter_array;
82 GArray *ret = g_array_new (TRUE, TRUE, sizeof (AtspiAccessible *));
84 _ATSPI_DBUS_CHECK_SIG (message, "a(so)", NULL, NULL);
86 dbus_message_iter_init (message, &iter);
87 dbus_message_iter_recurse (&iter, &iter_array);
89 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
91 AtspiAccessible *accessible;
93 accessible = _atspi_dbus_return_accessible_from_iter (&iter_array);
94 new_array = g_array_append_val (ret, accessible);
97 /* Iter was moved already, so no need to call dbus_message_iter_next */
99 dbus_message_unref (message);
104 * atspi_collection_get_matches:
106 * @collection: A pointer to the #AtspiCollection to query.
108 * @rule: An #AtspiMatchRule describing the match criteria.
110 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
113 * @count: The maximum number of results to return, or 0 for no limit.
115 * @traverse: Not supported.
117 * Gets all #AtspiAccessible objects from the @collection matching a given
120 * Returns: (element-type AtspiAccessible*) (transfer full): All
121 * #AtspiAccessible objects matching the given match rule.
124 atspi_collection_get_matches (AtspiCollection *collection,
125 AtspiMatchRule *rule,
126 AtspiCollectionSortOrder sortby,
131 DBusMessage *message = new_message (collection, "GetMatches");
133 dbus_int32_t d_sortby = sortby;
134 dbus_int32_t d_count = count;
135 dbus_bool_t d_traverse = traverse;
140 if (!append_match_rule (message, rule))
142 dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
143 DBUS_TYPE_INT32, &d_count,
144 DBUS_TYPE_BOOLEAN, &d_traverse,
146 reply = _atspi_dbus_send_with_reply_and_block (message, error);
149 return return_accessibles (reply);
153 * atspi_collection_get_matches_to:
155 * @collection: A pointer to the #AtspiCollection to query.
157 * @current_object: The object at which to start searching.
159 * @rule: An #AtspiMatchRule describing the match criteria.
161 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
164 * @tree: An #AtspiCollectionTreeTraversalType specifying restrictions on
165 * the objects to be traversed.
167 * @restrict: If #TRUE, only descendants of @current_object's parent
168 * will be returned. Otherwise (if #FALSE), any accessible may be returned
169 * if it would preceed @current_object in a flattened hierarchy.
171 * @count: The maximum number of results to return, or 0 for no limit.
173 * @traverse: Not supported.
175 * Gets all #AtspiAccessible objects from the @collection, after
176 * @current_object, matching a given @rule.
178 * Returns: (element-type AtspiAccessible*) (transfer full): All
179 * #AtspiAccessible objects matching the given match rule after
183 atspi_collection_get_matches_to (AtspiCollection *collection,
184 AtspiAccessible *current_object,
185 AtspiMatchRule *rule,
186 AtspiCollectionSortOrder sortby,
187 AtspiCollectionTreeTraversalType tree,
193 DBusMessage *message = new_message (collection, "GetMatchesTo");
195 dbus_int32_t d_sortby = sortby;
196 dbus_int32_t d_tree = tree;
197 dbus_bool_t d_restrict = restrict;
198 dbus_int32_t d_count = count;
199 dbus_bool_t d_traverse = traverse;
204 if (!append_accessible (message, current_object))
206 if (!append_match_rule (message, rule))
208 dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
209 DBUS_TYPE_UINT32, &d_tree,
210 DBUS_TYPE_BOOLEAN, &d_restrict,
211 DBUS_TYPE_INT32, &d_count,
212 DBUS_TYPE_BOOLEAN, &d_traverse,
214 reply = _atspi_dbus_send_with_reply_and_block (message, error);
217 return return_accessibles (reply);
221 * atspi_collection_get_matches_from:
223 * @collection: A pointer to the #AtspiCollection to query.
225 * @current_object: Upon reaching this object, searching should stop.
227 * @rule: An #AtspiMatchRule describing the match criteria.
229 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
232 * @tree: An #AtspiCollectionTreeTraversalType specifying restrictions on
233 * the objects to be traversed.
235 * @count: The maximum number of results to return, or 0 for no limit.
237 * @traverse: Not supported.
239 * Gets all #AtspiAccessible objects from the @collection, before
240 * @current_object, matching a given @rule.
242 * Returns: (element-type AtspiAccessible*) (transfer full): All
243 * #AtspiAccessible objects matching the given match rule that preceed
247 atspi_collection_get_matches_from (AtspiCollection *collection,
248 AtspiAccessible *current_object,
249 AtspiMatchRule *rule,
250 AtspiCollectionSortOrder sortby,
251 AtspiCollectionTreeTraversalType tree,
256 DBusMessage *message = new_message (collection, "GetMatchesFrom");
258 dbus_int32_t d_sortby = sortby;
259 dbus_int32_t d_tree = tree;
260 dbus_int32_t d_count = count;
261 dbus_bool_t d_traverse = traverse;
266 if (!append_accessible (message, current_object))
268 if (!append_match_rule (message, rule))
270 dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
271 DBUS_TYPE_UINT32, &d_tree,
272 DBUS_TYPE_INT32, &d_count,
273 DBUS_TYPE_BOOLEAN, &d_traverse,
275 reply = _atspi_dbus_send_with_reply_and_block (message, error);
278 return return_accessibles (reply);
282 * atspi_collection_get_active_descendant:
284 * Not yet implemented.
287 atspi_collection_get_active_descendant (AtspiCollection *collection, GError **error)
289 g_warning ("atspi: TODO: Implement get_active_descendants");
294 atspi_collection_base_init (AtspiCollection *klass)
299 atspi_collection_get_type (void)
301 static GType type = 0;
304 static const GTypeInfo tinfo =
306 sizeof (AtspiCollection),
307 (GBaseInitFunc) atspi_collection_base_init,
308 (GBaseFinalizeFunc) NULL,
311 type = g_type_register_static (G_TYPE_INTERFACE, "AtspiCollection", &tinfo, 0);