diff options
author | Mike Gorse <mgorse@novell.com> | 2010-11-28 10:08:02 -0500 |
---|---|---|
committer | Mike Gorse <mgorse@novell.com> | 2010-11-28 10:08:02 -0500 |
commit | ba62b6e42a04872513574b1abd2e02d44c2a6468 (patch) | |
tree | dfbb62b14e0d60cb964c20596702832cef276ba8 /atspi/atspi-relation.c | |
parent | 6f0884d36ef773439675a36090711071c4030ffd (diff) | |
download | at-spi2-core-ba62b6e42a04872513574b1abd2e02d44c2a6468.tar.gz |
Added relation set and various other fixes
Diffstat (limited to 'atspi/atspi-relation.c')
-rw-r--r-- | atspi/atspi-relation.c | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/atspi/atspi-relation.c b/atspi/atspi-relation.c new file mode 100644 index 00000000..6fc5591e --- /dev/null +++ b/atspi/atspi-relation.c @@ -0,0 +1,135 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "atspi-private.h" + +/** + * atspi_relation_get_relation_type: + * @obj: a pointer to the #AtspiRelation object to query. + * + * Get the type of relationship represented by an #AtspiRelation. + * + * Returns: an #AtspiRelationType indicating the type of relation + * encapsulated in this #AtspiRelation object. + * + **/ +AtspiRelationType +atspi_relation_get_relation_type (AtspiRelation *obj) +{ + return obj->relation_type; +} + +/** + * atspi_relation_get_n_targets: + * @obj: a pointer to the #AtspiRelation object to query. + * + * Get the number of objects which this relationship has as its + * target objects (the subject is the #Accessible from which this + * #AtspiRelation originated). + * + * Returns: a short integer indicating how many target objects which the + * originating #Accessible object has the #AtspiRelation + * relationship with. + **/ +gint +atspi_relation_get_n_targets (AtspiRelation *obj) +{ + return obj->targets->len; +} + +/** + * atspi_relation_get_target: + * @obj: a pointer to the #AtspiRelation object to query. + * @i: a (zero-index) integer indicating which (of possibly several) target is requested. + * + * Get the @i-th target of a specified #AtspiRelation relationship. + * + * Returns: (transfer full): an #AtspiAccessible which is the @i-th object + * with which the originating #AtspiAccessible has relationship + * specified in the #AtspiRelation object. + * + **/ +AtspiAccessible * +atspi_relation_get_target (AtspiRelation *obj, gint i) +{ + g_return_val_if_fail (obj, NULL); + + g_return_val_if_fail (i >= 0 && i < obj->targets->len, NULL); + return g_object_ref (g_array_index (obj->targets, AtspiAccessible *, i)); +} + +AtspiRelation * +_atspi_relation_new_from_iter (DBusMessageIter *iter) +{ + DBusMessageIter iter_struct, iter_array; + dbus_uint32_t d_type; + AtspiRelation *relation = g_object_new (ATSPI_TYPE_RELATION, NULL); + + if (!relation) + return NULL; + + dbus_message_iter_recurse (iter, &iter_struct); + dbus_message_iter_get_basic (&iter_struct, &d_type); + relation->relation_type = d_type; + dbus_message_iter_next (&iter_struct); + + relation->targets = g_array_new (TRUE, TRUE, sizeof (AtspiAccessible *)); + dbus_message_iter_recurse (&iter_struct, &iter_array); + while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID) + { + AtspiAccessible *accessible; + GArray *new_array; + accessible = _atspi_dbus_return_accessible_from_iter (&iter_array); + new_array = g_array_append_val (relation->targets, accessible); + if (new_array) + relation->targets = new_array; + /* Iter was moved already, so no need to call dbus_message_iter_next */ + } + return relation; +} + +G_DEFINE_TYPE (AtspiRelation, atspi_relation, G_TYPE_OBJECT) + +static void +atspi_relation_init (AtspiRelation *relation) +{ +} + +static void +atspi_relation_finalize (GObject *obj) +{ + AtspiRelation *relation = ATSPI_RELATION (obj); + gint i; + + for (i = 0; i < relation->targets->len; i++) + g_object_unref (g_array_index (relation->targets, AtspiAccessible *, i)); + g_array_free (relation->targets, TRUE); +} + +static void +atspi_relation_class_init (AtspiRelationClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = atspi_relation_finalize; +} |