introduce new HIGHLIGHTABLE and HIGHLIGHTED states.
[platform/upstream/at-spi2-core.git] / atspi / atspi-collection.c
index 29f68fa..f4e33ef 100644 (file)
@@ -3,6 +3,7 @@
  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
  *
  * Copyright 2007 IBM Corp.
+ * Copyright 2010, 2011 Novell, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 /* TODO: Improve documentation and implement some missing functions */
 
 /**
- * atspi_collection_is_ancester_of:
- *
- * @collection: The #AtspiCollection to test against.
- * @test: The #AtspiAccessible to test.
- *
- * Returns: TRUE if @collection is an ancestor of @test; FALSE otherwise.
+ * atspi_collection_is_ancestor_of:
  *
  * Not yet implemented.
+ *
  **/
 gboolean
 atspi_collection_is_ancestor_of (AtspiCollection *collection,
                                  AtspiAccessible *test,
                                  GError **error)
 {
-  g_warning ("Atspi: TODO: Implement is_ancester_of");
+  g_warning ("Atspi: TODO: Implement is_ancestor_of");
   return FALSE;
 }
 
@@ -52,6 +49,8 @@ new_message (AtspiCollection *collection, char *method)
     return NULL;
 
   accessible = ATSPI_ACCESSIBLE (collection);
+  if (!accessible->parent.app)
+    return NULL;
   return dbus_message_new_method_call (accessible->parent.app->bus_name,
                                        accessible->parent.path,
                                        atspi_interface_collection,
@@ -75,6 +74,7 @@ append_accessible (DBusMessage *message, AtspiAccessible *accessible)
   dbus_message_iter_init_append (message, &iter);
   dbus_message_iter_append_basic (&iter, DBUS_TYPE_OBJECT_PATH,
                                   &accessible->parent.path);
+  return TRUE; /* TODO: Check for out-of-memory */
 }
 
 static GArray *
@@ -91,11 +91,8 @@ return_accessibles (DBusMessage *message)
   while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
   {
     AtspiAccessible *accessible;
-    GArray *new_array;
     accessible = _atspi_dbus_return_accessible_from_iter (&iter_array);
-    new_array = g_array_append_val (ret, accessible);
-    if (new_array)
-      ret = new_array;
+    ret = g_array_append_val (ret, accessible);
     /* Iter was moved already, so no need to call dbus_message_iter_next */
   }
   dbus_message_unref (message);
@@ -104,16 +101,18 @@ return_accessibles (DBusMessage *message)
 
 /**
  * atspi_collection_get_matches:
- *
- * @collection: The #AtspiCollection.
- * @rule: A #AtspiMatchRule describing the match criteria.
+ * @collection: A pointer to the #AtspiCollection to query.
+ * @rule: An #AtspiMatchRule describing the match criteria.
  * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
  *          be sorted.
  * @count: The maximum number of results to return, or 0 for no limit.
- * @traverse: TODO
+ * @traverse: Not supported.
+ *
+ * Gets all #AtspiAccessible objects from the @collection matching a given
+ * @rule.  
  *
- * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
- *          #AtspiAccessibles matching the given match rule.
+ * Returns: (element-type AtspiAccessible*) (transfer full): All 
+ *          #AtspiAccessible objects matching the given match rule.
  **/
 GArray *
 atspi_collection_get_matches (AtspiCollection *collection,
@@ -138,7 +137,7 @@ atspi_collection_get_matches (AtspiCollection *collection,
                             DBUS_TYPE_INT32, &d_count,
                             DBUS_TYPE_BOOLEAN, &d_traverse,
                             DBUS_TYPE_INVALID);
-  reply = _atspi_dbus_send_with_reply_and_block (message);
+  reply = _atspi_dbus_send_with_reply_and_block (message, error);
   if (!reply)
     return NULL;
   return return_accessibles (reply);
@@ -146,20 +145,25 @@ atspi_collection_get_matches (AtspiCollection *collection,
 
 /**
  * atspi_collection_get_matches_to:
- *
- * @collection: The #AtspiCollection.
+ * @collection: A pointer to the #AtspiCollection to query.
  * @current_object: The object at which to start searching.
- * @rule: A #AtspiMatchRule describing the match criteria.
+ * @rule: An #AtspiMatchRule describing the match criteria.
  * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
  *          be sorted.
  * @tree: An #AtspiCollectionTreeTraversalType specifying restrictions on
- *        the objects to be traversed.
- * @recurse: TODO
+ *          the objects to be traversed.
+ * @limit_scope: If #TRUE, only descendants of @current_object's parent
+ *          will be returned. Otherwise (if #FALSE), any accessible may be
+ *          returned if it would preceed @current_object in a flattened
+ *          hierarchy.
  * @count: The maximum number of results to return, or 0 for no limit.
- * @traverse: TODO
+ * @traverse: Not supported.
+ *
+ * Gets all #AtspiAccessible objects from the @collection, after 
+ * @current_object, matching a given @rule.  
  *
- * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
- *          #AtspiAccessibles matching the given match rule after
+ * Returns: (element-type AtspiAccessible*) (transfer full): All
+ *          #AtspiAccessible objects matching the given match rule after
  *          @current_object.
  **/
 GArray *
@@ -168,7 +172,7 @@ atspi_collection_get_matches_to (AtspiCollection *collection,
                               AtspiMatchRule *rule,
                               AtspiCollectionSortOrder sortby,
                               AtspiCollectionTreeTraversalType tree,
-                              gboolean recurse,
+                              gboolean limit_scope,
                               gint count,
                               gboolean traverse,
                               GError **error)
@@ -177,7 +181,7 @@ atspi_collection_get_matches_to (AtspiCollection *collection,
   DBusMessage *reply;
   dbus_int32_t d_sortby = sortby;
   dbus_int32_t d_tree = tree;
-  dbus_bool_t d_recurse = recurse;
+  dbus_bool_t d_limit_scope = limit_scope;
   dbus_int32_t d_count = count;
   dbus_bool_t d_traverse = traverse;
 
@@ -190,11 +194,11 @@ atspi_collection_get_matches_to (AtspiCollection *collection,
     return NULL;
   dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
                                      DBUS_TYPE_UINT32, &d_tree,
-                            DBUS_TYPE_BOOLEAN, &d_recurse,
+                            DBUS_TYPE_BOOLEAN, &d_limit_scope,
                             DBUS_TYPE_INT32, &d_count,
                             DBUS_TYPE_BOOLEAN, &d_traverse,
                             DBUS_TYPE_INVALID);
-  reply = _atspi_dbus_send_with_reply_and_block (message);
+  reply = _atspi_dbus_send_with_reply_and_block (message, error);
   if (!reply)
     return NULL;
   return return_accessibles (reply);
@@ -202,19 +206,21 @@ atspi_collection_get_matches_to (AtspiCollection *collection,
 
 /**
  * atspi_collection_get_matches_from:
- *
- * @collection: The #AtspiCollection.
+ * @collection: A pointer to the #AtspiCollection to query.
  * @current_object: Upon reaching this object, searching should stop.
- * @rule: A #AtspiMatchRule describing the match criteria.
+ * @rule: An #AtspiMatchRule describing the match criteria.
  * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
  *          be sorted.
  * @tree: An #AtspiCollectionTreeTraversalType specifying restrictions on
- *        the objects to be traversed.
+ *          the objects to be traversed.
  * @count: The maximum number of results to return, or 0 for no limit.
- * @traverse: TODO
+ * @traverse: Not supported.
  *
- * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
- *          #AtspiAccessibles matching the given match rule that preceed
+ * Gets all #AtspiAccessible objects from the @collection, before  
+ * @current_object, matching a given @rule.  
+ *
+ * Returns: (element-type AtspiAccessible*) (transfer full): All 
+ *          #AtspiAccessible objects matching the given match rule that preceed
  *          @current_object.
  **/
 GArray *
@@ -246,7 +252,7 @@ atspi_collection_get_matches_from (AtspiCollection *collection,
                             DBUS_TYPE_INT32, &d_count,
                             DBUS_TYPE_BOOLEAN, &d_traverse,
                             DBUS_TYPE_INVALID);
-  reply = _atspi_dbus_send_with_reply_and_block (message);
+  reply = _atspi_dbus_send_with_reply_and_block (message, error);
   if (!reply)
     return NULL;
   return return_accessibles (reply);
@@ -254,11 +260,8 @@ atspi_collection_get_matches_from (AtspiCollection *collection,
 
 /**
  * atspi_collection_get_active_descendant:
- * 
- * @collection: The #AtspiCollection to query.
- *
- * Returns: (transfer full): The active descendant of #collection.
  *
+* Returns: (transfer full): The active descendant of the given object.
  * Not yet implemented.
  **/
 AtspiAccessible *