atkobject: Added atk_object_get_object_locale
[platform/upstream/atk.git] / atk / atkrelationset.c
index da0af10..f68ed15 100755 (executable)
@@ -216,13 +216,14 @@ atk_relation_set_get_n_relations (AtkRelationSet *set)
 }
 
 /**
- * atk_relation_set_get_relation
+ * atk_relation_set_get_relation:
  * @set: an #AtkRelationSet
  * @i: a gint representing a position in the set, starting from 0.
  *
  * Determines the relation at the specified position in the relation set.
  *
- * Returns: a #AtkRelation, which is the relation at position i in the set.
+ * Returns: (transfer none): a #AtkRelation, which is the relation at
+ * position i in the set.
  **/
 AtkRelation*
 atk_relation_set_get_relation (AtkRelationSet *set,
@@ -251,7 +252,8 @@ atk_relation_set_get_relation (AtkRelationSet *set,
  *
  * Finds a relation that matches the specified type.
  *
- * Returns: an #AtkRelation, which is a relation matching the specified type.
+ * Returns: (transfer none): an #AtkRelation, which is a relation matching the
+ * specified type.
  **/
 AtkRelation*
 atk_relation_set_get_relation_by_type (AtkRelationSet  *set,
@@ -337,3 +339,53 @@ atk_relation_set_add_relation_by_type (AtkRelationSet  *set,
     }
 }
 
+/**
+ * atk_relation_set_contains_target:
+ * @set: an #AtkRelationSet
+ * @relationship: an #AtkRelationType
+ * @target: an #AtkObject
+ *
+ * Determines whether the relation set contains a relation that
+ * matches the specified pair formed by type @relationship and object
+ * @target.
+ *
+ * Returns: %TRUE if @set contains a relation with the relationship
+ * type @relationship with an object @target, %FALSE otherwise
+ **/
+
+gboolean
+atk_relation_set_contains_target (AtkRelationSet  *set,
+                                  AtkRelationType relationship,
+                                  AtkObject       *target)
+{
+  GPtrArray *array_relations;
+  GPtrArray *array_target;
+  AtkObject *current_target;
+  AtkRelation *relation;
+  gint i;
+  gint c;
+
+  g_return_val_if_fail (ATK_IS_RELATION_SET (set), FALSE);
+  g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
+
+  array_relations = set->relations;
+  if (array_relations == NULL)
+    return FALSE;
+
+  for (i = 0; i < array_relations->len; i++)
+  {
+    relation = g_ptr_array_index (array_relations, i);
+    if (relation->relationship == relationship)
+      {
+        array_target = atk_relation_get_target (relation);
+        for (c = 0; c < array_target->len; c++)
+          {
+            current_target = g_ptr_array_index (array_target, c);
+            if (target == current_target)
+              return TRUE;
+          }
+      }
+  }
+
+  return FALSE;
+}