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_ancester_of:
31 * @collection: The #AtspiCollection to test against.
32 * @test: The #AtspiAccessible to test.
34 * Returns: TRUE if @collection is an ancestor of @test; FALSE otherwise.
36 * Not yet implemented.
39 atspi_collection_is_ancestor_of (AtspiCollection *collection,
40 AtspiAccessible *test,
43 g_warning ("Atspi: TODO: Implement is_ancester_of");
48 new_message (AtspiCollection *collection, char *method)
50 AtspiAccessible *accessible;
55 accessible = ATSPI_ACCESSIBLE (collection);
56 return dbus_message_new_method_call (accessible->parent.app->bus_name,
57 accessible->parent.path,
58 atspi_interface_collection,
63 append_match_rule (DBusMessage *message, AtspiMatchRule *rule)
67 dbus_message_iter_init_append (message, &iter);
68 return _atspi_match_rule_marshal (rule, &iter);
72 append_accessible (DBusMessage *message, AtspiAccessible *accessible)
76 dbus_message_iter_init_append (message, &iter);
77 dbus_message_iter_append_basic (&iter, DBUS_TYPE_OBJECT_PATH,
78 &accessible->parent.path);
79 return TRUE; /* TODO: Check for out-of-memory */
83 return_accessibles (DBusMessage *message)
85 DBusMessageIter iter, iter_array;
86 GArray *ret = g_array_new (TRUE, TRUE, sizeof (AtspiAccessible *));
88 _ATSPI_DBUS_CHECK_SIG (message, "a(so)", NULL, NULL);
90 dbus_message_iter_init (message, &iter);
91 dbus_message_iter_recurse (&iter, &iter_array);
93 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
95 AtspiAccessible *accessible;
97 accessible = _atspi_dbus_return_accessible_from_iter (&iter_array);
98 new_array = g_array_append_val (ret, accessible);
101 /* Iter was moved already, so no need to call dbus_message_iter_next */
103 dbus_message_unref (message);
108 * atspi_collection_get_matches:
110 * @collection: The #AtspiCollection.
111 * @rule: A #AtspiMatchRule describing the match criteria.
112 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
114 * @count: The maximum number of results to return, or 0 for no limit.
117 * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
118 * #AtspiAccessibles matching the given match rule.
121 atspi_collection_get_matches (AtspiCollection *collection,
122 AtspiMatchRule *rule,
123 AtspiCollectionSortOrder sortby,
128 DBusMessage *message = new_message (collection, "GetMatches");
130 dbus_int32_t d_sortby = sortby;
131 dbus_int32_t d_count = count;
132 dbus_bool_t d_traverse = traverse;
137 if (!append_match_rule (message, rule))
139 dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
140 DBUS_TYPE_INT32, &d_count,
141 DBUS_TYPE_BOOLEAN, &d_traverse,
143 reply = _atspi_dbus_send_with_reply_and_block (message, error);
146 return return_accessibles (reply);
150 * atspi_collection_get_matches_to:
152 * @collection: The #AtspiCollection.
153 * @current_object: The object at which to start searching.
154 * @rule: A #AtspiMatchRule describing the match criteria.
155 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
157 * @tree: An #AtspiCollectionTreeTraversalType specifying restrictions on
158 * the objects to be traversed.
160 * @count: The maximum number of results to return, or 0 for no limit.
163 * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
164 * #AtspiAccessibles matching the given match rule after
168 atspi_collection_get_matches_to (AtspiCollection *collection,
169 AtspiAccessible *current_object,
170 AtspiMatchRule *rule,
171 AtspiCollectionSortOrder sortby,
172 AtspiCollectionTreeTraversalType tree,
178 DBusMessage *message = new_message (collection, "GetMatchesTo");
180 dbus_int32_t d_sortby = sortby;
181 dbus_int32_t d_tree = tree;
182 dbus_bool_t d_recurse = recurse;
183 dbus_int32_t d_count = count;
184 dbus_bool_t d_traverse = traverse;
189 if (!append_accessible (message, current_object))
191 if (!append_match_rule (message, rule))
193 dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
194 DBUS_TYPE_UINT32, &d_tree,
195 DBUS_TYPE_BOOLEAN, &d_recurse,
196 DBUS_TYPE_INT32, &d_count,
197 DBUS_TYPE_BOOLEAN, &d_traverse,
199 reply = _atspi_dbus_send_with_reply_and_block (message, error);
202 return return_accessibles (reply);
206 * atspi_collection_get_matches_from:
208 * @collection: The #AtspiCollection.
209 * @current_object: Upon reaching this object, searching should stop.
210 * @rule: A #AtspiMatchRule describing the match criteria.
211 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
213 * @tree: An #AtspiCollectionTreeTraversalType specifying restrictions on
214 * the objects to be traversed.
215 * @count: The maximum number of results to return, or 0 for no limit.
218 * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
219 * #AtspiAccessibles matching the given match rule that preceed
223 atspi_collection_get_matches_from (AtspiCollection *collection,
224 AtspiAccessible *current_object,
225 AtspiMatchRule *rule,
226 AtspiCollectionSortOrder sortby,
227 AtspiCollectionTreeTraversalType tree,
232 DBusMessage *message = new_message (collection, "GetMatchesFrom");
234 dbus_int32_t d_sortby = sortby;
235 dbus_int32_t d_tree = tree;
236 dbus_int32_t d_count = count;
237 dbus_bool_t d_traverse = traverse;
242 if (!append_accessible (message, current_object))
244 if (!append_match_rule (message, rule))
246 dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
247 DBUS_TYPE_UINT32, &d_tree,
248 DBUS_TYPE_INT32, &d_count,
249 DBUS_TYPE_BOOLEAN, &d_traverse,
251 reply = _atspi_dbus_send_with_reply_and_block (message, error);
254 return return_accessibles (reply);
258 * atspi_collection_get_active_descendant:
260 * @collection: The #AtspiCollection to query.
262 * Returns: (transfer full): The active descendant of #collection.
264 * Not yet implemented.
267 atspi_collection_get_active_descendant (AtspiCollection *collection, GError **error)
269 g_warning ("atspi: TODO: Implement get_active_descendants");
274 atspi_collection_base_init (AtspiCollection *klass)
279 atspi_collection_get_type (void)
281 static GType type = 0;
284 static const GTypeInfo tinfo =
286 sizeof (AtspiCollection),
287 (GBaseInitFunc) atspi_collection_base_init,
288 (GBaseFinalizeFunc) NULL,
291 type = g_type_register_static (G_TYPE_INTERFACE, "AtspiCollection", &tinfo, 0);