X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=atk%2Fatkrelation.c;h=835d30c848c4d4a170de324451d331826297fd2f;hb=202959b41cd96f3850190699e6959212e9a8a2b6;hp=3a6ef0c83c6131cf0319c69665b2da29f6c55ea5;hpb=eb123d5ba2aecc64fba5c669fcee2856e2478404;p=platform%2Fupstream%2Fatk.git diff --git a/atk/atkrelation.c b/atk/atkrelation.c index 3a6ef0c..835d30c 100755 --- a/atk/atkrelation.c +++ b/atk/atkrelation.c @@ -19,10 +19,19 @@ #include #include -#include "atkobject.h" -#include "atkrelation.h" -#include "atk-enum-types.h" +#include "atk.h" +/** + * SECTION:atkrelation + * @Short_description: An object used to describe a relation between a + * object and one or more other objects. + * @Title:AtkRelation + * + * An AtkRelation describes a relation between an object and one or + * more other objects. The actual relations that an object has with + * other objects are defined as an AtkRelationSet, which is a set of + * AtkRelations. + */ enum { PROP_0, @@ -130,12 +139,12 @@ atk_relation_type_register (const gchar *name) * * Returns: the string describing the AtkRelationType */ -G_CONST_RETURN gchar* +const gchar* atk_relation_type_get_name (AtkRelationType type) { GTypeClass *type_class; GEnumValue *value; - gchar *name = NULL; + const gchar *name = NULL; type_class = g_type_class_ref (ATK_TYPE_RELATION_TYPE); g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), NULL); @@ -217,13 +226,14 @@ atk_relation_type_for_name (const gchar *name) /** * atk_relation_new: - * @targets: an array of pointers to #AtkObjects + * @targets: (array length=n_targets): an array of pointers to + * #AtkObjects * @n_targets: number of #AtkObjects pointed to by @targets * @relationship: an #AtkRelationType with which to create the new * #AtkRelation * * Create a new relation for the specified key and the specified list - * of targets. + * of targets. See also atk_object_add_relationship(). * * Returns: a pointer to a new #AtkRelation **/ @@ -282,7 +292,7 @@ atk_relation_get_relation_type (AtkRelation *relation) * * Gets the target list of @relation * - * Returns: the target list of @relation + * Returns: (transfer none) (element-type Atk.Object): the target list of @relation **/ GPtrArray* atk_relation_get_target (AtkRelation *relation) @@ -310,7 +320,8 @@ delete_object_while_in_relation (gpointer callback_data, * @target: an #AtkObject * * Adds the specified AtkObject to the target for the relation, if it is - * not already present. + * not already present. See also atk_object_add_relationship(). + * * * Since: 1.9 **/ @@ -332,6 +343,35 @@ atk_relation_add_target (AtkRelation *relation, g_object_weak_ref (G_OBJECT (target), (GWeakNotify) delete_object_while_in_relation, relation->target); } +/** + * atk_relation_remove_target: + * @relation: an #AtkRelation + * @target: an #AtkObject + * + * Remove the specified AtkObject from the target for the relation. + * + * Returns: TRUE if the removal is successful. + **/ + +gboolean +atk_relation_remove_target (AtkRelation *relation, + AtkObject *target) +{ + gboolean ret = FALSE; + GPtrArray *array; + + array = atk_relation_get_target (relation); + + if (array && g_ptr_array_remove (array, target)) + { + g_object_weak_unref (G_OBJECT (target), + (GWeakNotify) delete_object_while_in_relation, + relation->target); + ret = TRUE; + } + return ret; +} + static void atk_relation_finalize (GObject *object) { @@ -374,6 +414,18 @@ atk_relation_set_property (GObject *object, relation->relationship = g_value_get_enum (value); break; case PROP_TARGET: + if (relation->target) + { + gint i; + + for (i = 0; i < relation->target->len; i++) + { + g_object_weak_unref (G_OBJECT (g_ptr_array_index (relation->target, i)), + (GWeakNotify) delete_object_while_in_relation, + relation->target); + } + g_ptr_array_free (relation->target, TRUE); + } boxed = g_value_get_boxed (value); relation->target = atk_relation_get_ptr_array_from_value_array ( (GValueArray *) boxed); break;