[TIZEN] Introduce atspi_collection_get_matches_in_matches API. 95/304695/1
authorHosang Kim <hosang12.kim@samsung.com>
Thu, 30 Nov 2023 09:57:27 +0000 (18:57 +0900)
committerkim hosang <hosang12.kim@samsung.com>
Tue, 23 Jan 2024 08:02:39 +0000 (08:02 +0000)
The atspi_collection_get_matches_in_matches API retrieves all accessible objects within an AtspiCollection that match two sets of match rules.
This function takes in an AtspiCollection, two AtspiMatchRule pointers, a sorting order, and counts for each match rule.
It returns a GArray of AtspiAccessible pointers that match both rules.

This API can be used to efficiently retrieve specific subsets of accessible objects within a collection based on their properties.i
For example, you could use this API to find all buttons within a dialog box that have the word "OK" in their label.

Change-Id: Ia3c216e0800a32471b4a5251f33c8c6a7eda31aa
(cherry picked from commit 255ee78225866835b2cf036ddbb2d55133791bf6)

atspi/atspi-collection.c
atspi/atspi-collection.h

index 5a44100..d7ef6ac 100644 (file)
@@ -260,6 +260,61 @@ atspi_collection_get_matches_from (AtspiCollection *collection,
   return return_accessibles (reply);
 }
 
+//TIZEN_ONLY(20231130): Introduce atspi_collection_get_matches_in_matches API.
+/**
+ * atspi_collection_get_matches_in_matches:
+ * @collection: A pointer to the #AtspiCollection to query.
+ * @first_rule: An #AtspiMatchRule describing the initial match criteria.
+ * @second_rule: An #AtspiMatchRule describing additional match criteria.
+ * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
+ *          be sorted.
+ * @first_count: The maximum number of results to return for the initial match, or 0 for no limit.
+ * @second_count: The maximum number of results to return for the additional match, or 0 for no limit.
+ * @traverse: Not supported.
+ *
+ * Gets all #AtspiAccessible objects from the @collection that match both the @first_rule and @second_rule (if provided).
+ *
+ * Returns: (element-type AtspiAccessible*) (transfer full): All
+ *          #AtspiAccessible objects matching the given match both rules.
+ **/
+GArray *
+atspi_collection_get_matches_in_matches (AtspiCollection *collection,
+                                         AtspiMatchRule *first_rule,
+                                         AtspiMatchRule *second_rule,
+                                         AtspiCollectionSortOrder sortby,
+                                         gint first_count,
+                                         gint second_count,
+                                         gboolean traverse,
+                                         GError **error)
+{
+  DBusMessage *message = new_message (collection, "GetMatchesInMatches");
+  DBusMessage *reply;
+  dbus_int32_t d_sortby = sortby;
+  dbus_int32_t d_count1 = first_count;
+  dbus_int32_t d_count2 = second_count;
+  dbus_bool_t d_traverse = traverse;
+
+  if (!message)
+    return NULL;
+
+  if (!append_match_rule (message, first_rule))
+    return NULL;
+
+  if (!append_match_rule (message, second_rule))
+    return NULL;
+
+  dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
+                            DBUS_TYPE_INT32, &d_count1,
+                            DBUS_TYPE_INT32, &d_count2,
+                            DBUS_TYPE_BOOLEAN, &d_traverse,
+                            DBUS_TYPE_INVALID);
+  reply = _atspi_dbus_send_with_reply_and_block (message, error);
+  if (!reply)
+    return NULL;
+  return return_accessibles (reply);
+}
+//
+
 /**
  * atspi_collection_get_active_descendant:
  *
index 9b564c5..5a05260 100644 (file)
@@ -55,6 +55,10 @@ GArray * atspi_collection_get_matches_to (AtspiCollection *collection, AtspiAcce
 
 GArray * atspi_collection_get_matches_from (AtspiCollection *collection, AtspiAccessible *current_object, AtspiMatchRule *rule, AtspiCollectionSortOrder sortby, AtspiCollectionTreeTraversalType tree, gint count, gboolean traverse, GError **error);
 
+//TIZEN_ONLY(20231130): Introduce atspi_collection_get_matches_in_matches API.
+GArray * atspi_collection_get_matches_in_matches (AtspiCollection *collection, AtspiMatchRule *first_rule, AtspiMatchRule *second_rule, AtspiCollectionSortOrder sortby, gint first_count, gint second_count, gboolean traverse, GError **error);
+//
+
 AtspiAccessible * atspi_collection_get_active_descendant (AtspiCollection *collection, GError **error);
 
 G_END_DECLS