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 (rule, &iter);
71 append_accessible (DBusMessage *message, AtspiAccessible *accessible)
75 dbus_message_iter_init_append (message, &iter);
76 dbus_message_iter_append_basic (&iter, DBUS_TYPE_OBJECT_PATH,
77 &accessible->parent.path);
78 return TRUE; /* TODO: Check for out-of-memory */
82 return_accessibles (DBusMessage *message)
84 DBusMessageIter iter, iter_array;
85 GArray *ret = g_array_new (TRUE, TRUE, sizeof (AtspiAccessible *));
87 _ATSPI_DBUS_CHECK_SIG (message, "a(so)", NULL, NULL);
89 dbus_message_iter_init (message, &iter);
90 dbus_message_iter_recurse (&iter, &iter_array);
92 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
94 AtspiAccessible *accessible;
96 accessible = _atspi_dbus_return_accessible_from_iter (&iter_array);
97 new_array = g_array_append_val (ret, accessible);
100 /* Iter was moved already, so no need to call dbus_message_iter_next */
102 dbus_message_unref (message);
107 * atspi_collection_get_matches:
109 * @collection: The #AtspiCollection.
110 * @rule: A #AtspiMatchRule describing the match criteria.
111 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
113 * @count: The maximum number of results to return, or 0 for no limit.
116 * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
117 * #AtspiAccessibles matching the given match rule.
120 atspi_collection_get_matches (AtspiCollection *collection,
121 AtspiMatchRule *rule,
122 AtspiCollectionSortOrder sortby,
127 DBusMessage *message = new_message (collection, "GetMatches");
129 dbus_int32_t d_sortby = sortby;
130 dbus_int32_t d_count = count;
131 dbus_bool_t d_traverse = traverse;
136 if (!append_match_rule (message, rule))
138 dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
139 DBUS_TYPE_INT32, &d_count,
140 DBUS_TYPE_BOOLEAN, &d_traverse,
142 reply = _atspi_dbus_send_with_reply_and_block (message, error);
145 return return_accessibles (reply);
149 * atspi_collection_get_matches_to:
151 * @collection: The #AtspiCollection.
152 * @current_object: The object at which to start searching.
153 * @rule: A #AtspiMatchRule describing the match criteria.
154 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
156 * @tree: An #AtspiCollectionTreeTraversalType specifying restrictions on
157 * the objects to be traversed.
159 * @count: The maximum number of results to return, or 0 for no limit.
162 * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
163 * #AtspiAccessibles matching the given match rule after
167 atspi_collection_get_matches_to (AtspiCollection *collection,
168 AtspiAccessible *current_object,
169 AtspiMatchRule *rule,
170 AtspiCollectionSortOrder sortby,
171 AtspiCollectionTreeTraversalType tree,
177 DBusMessage *message = new_message (collection, "GetMatchesTo");
179 dbus_int32_t d_sortby = sortby;
180 dbus_int32_t d_tree = tree;
181 dbus_bool_t d_recurse = recurse;
182 dbus_int32_t d_count = count;
183 dbus_bool_t d_traverse = traverse;
188 if (!append_accessible (message, current_object))
190 if (!append_match_rule (message, rule))
192 dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
193 DBUS_TYPE_UINT32, &d_tree,
194 DBUS_TYPE_BOOLEAN, &d_recurse,
195 DBUS_TYPE_INT32, &d_count,
196 DBUS_TYPE_BOOLEAN, &d_traverse,
198 reply = _atspi_dbus_send_with_reply_and_block (message, error);
201 return return_accessibles (reply);
205 * atspi_collection_get_matches_from:
207 * @collection: The #AtspiCollection.
208 * @current_object: Upon reaching this object, searching should stop.
209 * @rule: A #AtspiMatchRule describing the match criteria.
210 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
212 * @tree: An #AtspiCollectionTreeTraversalType specifying restrictions on
213 * the objects to be traversed.
214 * @count: The maximum number of results to return, or 0 for no limit.
217 * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
218 * #AtspiAccessibles matching the given match rule that preceed
222 atspi_collection_get_matches_from (AtspiCollection *collection,
223 AtspiAccessible *current_object,
224 AtspiMatchRule *rule,
225 AtspiCollectionSortOrder sortby,
226 AtspiCollectionTreeTraversalType tree,
231 DBusMessage *message = new_message (collection, "GetMatchesFrom");
233 dbus_int32_t d_sortby = sortby;
234 dbus_int32_t d_tree = tree;
235 dbus_int32_t d_count = count;
236 dbus_bool_t d_traverse = traverse;
241 if (!append_accessible (message, current_object))
243 if (!append_match_rule (message, rule))
245 dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
246 DBUS_TYPE_UINT32, &d_tree,
247 DBUS_TYPE_INT32, &d_count,
248 DBUS_TYPE_BOOLEAN, &d_traverse,
250 reply = _atspi_dbus_send_with_reply_and_block (message, error);
253 return return_accessibles (reply);
257 * atspi_collection_get_active_descendant:
259 * @collection: The #AtspiCollection to query.
261 * Returns: (transfer full): The active descendant of #collection.
263 * Not yet implemented.
266 atspi_collection_get_active_descendant (AtspiCollection *collection, GError **error)
268 g_warning ("atspi: TODO: Implement get_active_descendants");
273 atspi_collection_base_init (AtspiCollection *klass)
278 atspi_collection_get_type (void)
280 static GType type = 0;
283 static const GTypeInfo tinfo =
285 sizeof (AtspiCollection),
286 (GBaseInitFunc) atspi_collection_base_init,
287 (GBaseFinalizeFunc) NULL,
290 type = g_type_register_static (G_TYPE_INTERFACE, "AtspiCollection", &tinfo, 0);