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);
81 return_accessibles (DBusMessage *message)
83 DBusMessageIter iter, iter_array;
84 GArray *ret = g_array_new (TRUE, TRUE, sizeof (AtspiAccessible *));
86 _ATSPI_DBUS_CHECK_SIG (message, "a(so)", NULL);
88 dbus_message_iter_init (message, &iter);
89 dbus_message_iter_recurse (&iter, &iter_array);
91 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
93 AtspiAccessible *accessible;
95 accessible = _atspi_dbus_return_accessible_from_iter (&iter_array);
96 new_array = g_array_append_val (ret, accessible);
99 /* Iter was moved already, so no need to call dbus_message_iter_next */
101 dbus_message_unref (message);
106 * atspi_collection_get_matches:
108 * @collection: The #AtspiCollection.
109 * @rule: A #AtspiMatchRule describing the match criteria.
110 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
112 * @count: The maximum number of results to return, or 0 for no limit.
115 * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
116 * #AtspiAccessibles matching the given match rule.
119 atspi_collection_get_matches (AtspiCollection *collection,
120 AtspiMatchRule *rule,
121 AtspiCollectionSortOrder sortby,
126 DBusMessage *message = new_message (collection, "GetMatches");
128 dbus_int32_t d_sortby = sortby;
129 dbus_int32_t d_count = count;
130 dbus_bool_t d_traverse = traverse;
135 if (!append_match_rule (message, rule))
137 dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
138 DBUS_TYPE_INT32, &d_count,
139 DBUS_TYPE_BOOLEAN, &d_traverse,
141 reply = _atspi_dbus_send_with_reply_and_block (message);
144 return return_accessibles (reply);
148 * atspi_collection_get_matches_to:
150 * @collection: The #AtspiCollection.
151 * @current_object: The object at which to start searching.
152 * @rule: A #AtspiMatchRule describing the match criteria.
153 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
155 * @tree: An #AtspiCollectionTreeTraversalType specifying restrictions on
156 * the objects to be traversed.
158 * @count: The maximum number of results to return, or 0 for no limit.
161 * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
162 * #AtspiAccessibles matching the given match rule after
166 atspi_collection_get_matches_to (AtspiCollection *collection,
167 AtspiAccessible *current_object,
168 AtspiMatchRule *rule,
169 AtspiCollectionSortOrder sortby,
170 AtspiCollectionTreeTraversalType tree,
176 DBusMessage *message = new_message (collection, "GetMatchesTo");
178 dbus_int32_t d_sortby = sortby;
179 dbus_int32_t d_tree = tree;
180 dbus_bool_t d_recurse = recurse;
181 dbus_int32_t d_count = count;
182 dbus_bool_t d_traverse = traverse;
187 if (!append_accessible (message, current_object))
189 if (!append_match_rule (message, rule))
191 dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
192 DBUS_TYPE_UINT32, &d_tree,
193 DBUS_TYPE_BOOLEAN, &d_recurse,
194 DBUS_TYPE_INT32, &d_count,
195 DBUS_TYPE_BOOLEAN, &d_traverse,
197 reply = _atspi_dbus_send_with_reply_and_block (message);
200 return return_accessibles (reply);
204 * atspi_collection_get_matches_from:
206 * @collection: The #AtspiCollection.
207 * @current_object: Upon reaching this object, searching should stop.
208 * @rule: A #AtspiMatchRule describing the match criteria.
209 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
211 * @tree: An #AtspiCollectionTreeTraversalType specifying restrictions on
212 * the objects to be traversed.
213 * @count: The maximum number of results to return, or 0 for no limit.
216 * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
217 * #AtspiAccessibles matching the given match rule that preceed
221 atspi_collection_get_matches_from (AtspiCollection *collection,
222 AtspiAccessible *current_object,
223 AtspiMatchRule *rule,
224 AtspiCollectionSortOrder sortby,
225 AtspiCollectionTreeTraversalType tree,
230 DBusMessage *message = new_message (collection, "GetMatchesFrom");
232 dbus_int32_t d_sortby = sortby;
233 dbus_int32_t d_tree = tree;
234 dbus_int32_t d_count = count;
235 dbus_bool_t d_traverse = traverse;
240 if (!append_accessible (message, current_object))
242 if (!append_match_rule (message, rule))
244 dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
245 DBUS_TYPE_UINT32, &d_tree,
246 DBUS_TYPE_INT32, &d_count,
247 DBUS_TYPE_BOOLEAN, &d_traverse,
249 reply = _atspi_dbus_send_with_reply_and_block (message);
252 return return_accessibles (reply);
256 * atspi_collection_get_active_descendant:
258 * @collection: The #AtspiCollection to query.
260 * Returns: (transfer full): The active descendant of #collection.
262 * Not yet implemented.
265 atspi_collection_get_active_descendant (AtspiCollection *collection, GError **error)
267 g_warning ("atspi: TODO: Implement get_active_descendants");
272 atspi_collection_base_init (AtspiCollection *klass)
277 atspi_collection_get_type (void)
279 static GType type = 0;
282 static const GTypeInfo tinfo =
284 sizeof (AtspiCollection),
285 (GBaseInitFunc) atspi_collection_base_init,
286 (GBaseFinalizeFunc) NULL,
289 type = g_type_register_static (G_TYPE_INTERFACE, "AtspiCollection", &tinfo, 0);