[atk] AtkRelation: added method that checks relationship and target
- From: Alejandro PiÃeiro Iglesias <apinheiro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [atk] AtkRelation: added method that checks relationship and target
- Date: Mon, 16 Jul 2012 22:47:57 +0000 (UTC)
commit a1d5ca861045855d9a2c25ef37734d65b081f27c
Author: Alejandro PiÃeiro <apinheiro igalia com>
Date: Tue Jul 17 00:41:06 2012 +0200
AtkRelation: added method that checks relationship and target
Note: the algorithm to make this search doesn't have a really
good theorical performance, but this is part caused by the
current internal structure by AtkRelationSet and AtkRelation
https://bugzilla.gnome.org/show_bug.cgi?id=672869
atk/atkobject.c | 3 ++-
atk/atkrelationset.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
atk/atkrelationset.h | 3 +++
3 files changed, 55 insertions(+), 1 deletions(-)
---
diff --git a/atk/atkobject.c b/atk/atkobject.c
index b197d2a..4817e16 100755
--- a/atk/atkobject.c
+++ b/atk/atkobject.c
@@ -1636,7 +1636,8 @@ atk_object_add_relationship (AtkObject *object,
g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
- if (atk_relation_set_contains (object->relation_set, relationship))
+ if (atk_relation_set_contains_target (object->relation_set,
+ relationship, target))
return FALSE;
array[0] = target;
diff --git a/atk/atkrelationset.c b/atk/atkrelationset.c
index de52320..f68ed15 100755
--- a/atk/atkrelationset.c
+++ b/atk/atkrelationset.c
@@ -339,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;
+}
diff --git a/atk/atkrelationset.h b/atk/atkrelationset.h
index 9bf572c..e0b5449 100755
--- a/atk/atkrelationset.h
+++ b/atk/atkrelationset.h
@@ -60,6 +60,9 @@ GType atk_relation_set_get_type (void);
AtkRelationSet* atk_relation_set_new (void);
gboolean atk_relation_set_contains (AtkRelationSet *set,
AtkRelationType relationship);
+gboolean atk_relation_set_contains_target (AtkRelationSet *set,
+ AtkRelationType relationship,
+ AtkObject *targe);
void atk_relation_set_remove (AtkRelationSet *set,
AtkRelation *relation);
void atk_relation_set_add (AtkRelationSet *set,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]