[Tizen] Introduce atspi_accessible_get_children API 23/289923/1
authorWoochan Lee <wc0917.lee@samsung.com>
Wed, 15 Mar 2023 11:22:56 +0000 (20:22 +0900)
committerWoochan Lee <wc0917.lee@samsung.com>
Wed, 15 Mar 2023 11:24:39 +0000 (20:24 +0900)
We called child count and child at index API to get child list.
It will helps to reduce dbus method call count and usage also better.

Change-Id: Iabd81f3988da0beb9ffcf224584f205489946872

atspi/atspi-accessible.c
atspi/atspi-accessible.h

index e5a2c7c..a0ebf6e 100644 (file)
@@ -985,6 +985,45 @@ atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
   return obj->children->len;
 }
 
+//TIZEN_ONLY(20230315) Add new API to get children
+/**
+ * atspi_accessible_get_children:
+ * @obj: a pointer to the #AtspiAccessible object on which to operate.
+ *
+ * Gets the children array contained by an #AtspiAccessible object.
+ *
+ * Returns: (element-type AtspiAccessible*) (transfer full): a #GArray of
+ *          #AtspiAccessible pointers or NULL on exception.
+ *
+ **/
+GArray *
+atspi_accessible_get_children (AtspiAccessible *obj, GError **error)
+{
+  DBusMessage *reply;
+  DBusMessageIter iter, iter_array;
+  GArray *ret;
+
+  g_return_val_if_fail (obj != NULL, NULL);
+
+  reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetChildren", error, "");
+  if (!reply)
+    return NULL;
+
+  ret = g_array_new (TRUE, TRUE, sizeof (AtspiAccessible *));
+  dbus_message_iter_init (reply, &iter);
+  dbus_message_iter_recurse (&iter, &iter_array);
+  while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
+  {
+    AtspiAccessible *accessible;
+    accessible = _atspi_dbus_return_accessible_from_iter (&iter_array);
+    ret = g_array_append_val (ret, accessible);
+  }
+  dbus_message_unref (reply);
+
+  return ret;
+}
+//
+
 /**
  * atspi_accessible_get_child_at_index:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
index 364e75e..28b8881 100644 (file)
@@ -131,6 +131,10 @@ AtspiAccessible * atspi_accessible_get_parent (AtspiAccessible *obj, GError **er
 
 gint atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error);
 
+//TIZEN_ONLY(20230315) Add new API to get children
+GArray * atspi_accessible_get_children (AtspiAccessible *obj, GError **error);
+//
+
 AtspiAccessible * atspi_accessible_get_child_at_index (AtspiAccessible *obj, gint    child_index, GError **error);
 
 gint atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error);