From: billh Date: Fri, 16 Nov 2001 23:31:01 +0000 (+0000) Subject: Added initial implementations of SpiRelation and, for the C bindings X-Git-Tag: AT_SPI2_CORE_0_1_3~1075 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f88d862cb044cf78e0e10c5908ce59c3f60ecf25;p=platform%2Fupstream%2Fat-spi2-core.git Added initial implementations of SpiRelation and, for the C bindings in cspi, AccessibleRelation. Added docs, documentation coverage 95%. git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@95 e2bd861d-eb25-0410-b326-f6ed22b6b98c --- diff --git a/ChangeLog b/ChangeLog index 59b901e..c523582 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2001-16-11 Bill Haneman + * libspi/relation.h: + * libspi/relation.c: + * cspi/spi_accessible.c: + Initial implementations of AccessibleRelation methods, and docs. + * libspi/accessible.c: Fixed a bug that caused SEGV if an accessible object's description is NULL, and a client @@ -10,7 +15,9 @@ * cspi/spi_image.c: * cspi/spi_hyperlink.c: * cspi/spi_table.c: - Added docs. Doc coverage now 92%. + Added docs. + + Doc coverage now 95%. 2001-16-11 Bill Haneman diff --git a/at-bridge/bridge.c b/at-bridge/bridge.c index dc89a7a..2d988ee 100644 --- a/at-bridge/bridge.c +++ b/at-bridge/bridge.c @@ -135,8 +135,17 @@ register_atk_event_listeners () atk_add_focus_tracker (bridge_focus_tracker); atk_add_global_event_listener (bridge_property_event_listener, "Gtk:AtkObject:property-change"); atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkObject:children-changed"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkObject:model-changed"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkObject:selection-changed"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkObject:visible-data-changed"); atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkText:text-changed"); atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkText:text-caret-moved"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:row-inserted"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:row-reordered"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:row-deleted"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:column-inserted"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:column-reordered"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:column-deleted"); atk_add_key_event_listener (bridge_key_listener, NULL); } diff --git a/atk-bridge/bridge.c b/atk-bridge/bridge.c index dc89a7a..2d988ee 100644 --- a/atk-bridge/bridge.c +++ b/atk-bridge/bridge.c @@ -135,8 +135,17 @@ register_atk_event_listeners () atk_add_focus_tracker (bridge_focus_tracker); atk_add_global_event_listener (bridge_property_event_listener, "Gtk:AtkObject:property-change"); atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkObject:children-changed"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkObject:model-changed"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkObject:selection-changed"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkObject:visible-data-changed"); atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkText:text-changed"); atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkText:text-caret-moved"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:row-inserted"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:row-reordered"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:row-deleted"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:column-inserted"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:column-reordered"); + atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:column-deleted"); atk_add_key_event_listener (bridge_key_listener, NULL); } diff --git a/cspi/spi.h b/cspi/spi.h index 6875994..1a7dc53 100644 --- a/cspi/spi.h +++ b/cspi/spi.h @@ -1081,8 +1081,11 @@ AccessibleRelation_unref (AccessibleRelation *obj); AccessibleRelationType AccessibleRelation_getRelationType (AccessibleRelation *obj); +int +AccessibleRelation_getNTargets (AccessibleRelation *obj); + Accessible * -AccessibleRelation_getTarget (AccessibleRelation *obj); +AccessibleRelation_getTarget (AccessibleRelation *obj, int i); /* diff --git a/cspi/spi_accessible.c b/cspi/spi_accessible.c index 2dc78ad..bdeef1f 100644 --- a/cspi/spi_accessible.c +++ b/cspi/spi_accessible.c @@ -240,15 +240,32 @@ Accessible_getIndexInParent (Accessible *obj) * Accessible_getRelationSet: * @obj: a pointer to the #Accessible object on which to operate. * - * Not Yet Implemented. + * Get the set of #AccessibleRelation objects which describe this #Accessible object's + * relationships with other #Accessible objects. * - * Returns: a pointer to an array of #AccessibleRelations. + * Returns: an array of #AccessibleRelation pointers. * **/ AccessibleRelation ** Accessible_getRelationSet (Accessible *obj) { - return NULL; + AccessibleRelation **relations; + int n_relations; + int i; + Accessibility_RelationSet *relation_set = + Accessibility_Accessible_getRelationSet (*obj, &ev); + + /* this looks hack-ish, but it's based on the CORBA C bindings spec */ + n_relations = relation_set->_length; + relations = malloc (sizeof (AccessibleRelation *) * n_relations); + + for (i=0; i_buffer[i]); + } + relations[i] = CORBA_OBJECT_NIL; + + return relations; } /** @@ -706,3 +723,89 @@ Accessible_queryInterface (Accessible *obj, char *interface_name) return (iface != NULL) ? Obj_Add (iface) : NULL; } + +/** + * AccessibleRelation_ref: + * @obj: a pointer to the #AccessibleRelation object on which to operate. + * + * Increment the reference count for an #AccessibleRelation object. + * + * Returns: (no return code implemented yet). + * + **/ +int +AccessibleRelation_ref (AccessibleRelation *obj) +{ + Accessibility_Relation_ref (*obj, &ev); + spi_check_ev (&ev, "ref"); + return 0; +} + +/** + * AccessibleRelation_unref: + * @obj: a pointer to the #AccessibleRelation object on which to operate. + * + * Decrement the reference count for an #AccessibleRelation object. + * + * Returns: (no return code implemented yet). + * + **/ +int +AccessibleRelation_unref (AccessibleRelation *obj) +{ + Accessibility_Relation_unref (*obj, &ev); + spi_check_ev (&ev, "unref"); + return 0; +} + +/** + * AccessibleRelation_getRelationType: + * @obj: a pointer to the #AccessibleRelation object to query. + * + * Get the type of relationship represented by an #AccessibleRelation. + * + * Returns: an #AccessibleRelationType indicating the type of relation + * encapsulated in this #AccessibleRelation object. + * + **/ +AccessibleRelationType +AccessibleRelation_getRelationType (AccessibleRelation *obj) +{ + return 0; +} + +/** + * AccessibleRelation_getNTargets: + * @obj: a pointer to the #AccessibleRelation object to query. + * + * Get the number of objects which this relationship has as its + * target objects (the subject is the #Accessible from which this + * #AccessibleRelation originated). + * + * Returns: a short integer indicating how many target objects which the + * originating #Accessible object has the #AccessibleRelation + * relationship with. + **/ +int +AccessibleRelation_getNTargets (AccessibleRelation *obj) +{ + return 0; +} + +/** + * AccessibleRelation_getTarget: + * @obj: a pointer to the #AccessibleRelation object to query. + * @i: a (zero-index) integer indicating which (of possibly several) target is requested. + * + * Get the @i-th target of a specified #AccessibleRelation relationship. + * + * Returns: an #Accessible which is the @i-th object with which the + * originating #Accessible has relationship specified in the + * #AccessibleRelation object. + * + **/ +Accessible * +AccessibleRelation_getTarget (AccessibleRelation *obj, int i) +{ + return NULL; +} diff --git a/docs/at-spi-sections.txt b/docs/at-spi-sections.txt index 16579ab..2eeaa9b 100644 --- a/docs/at-spi-sections.txt +++ b/docs/at-spi-sections.txt @@ -251,7 +251,6 @@ AccessibleStateSet_contains AccessibleStateSet_equals AccessibleStateSet_isEmpty AccessibleStateSet_remove -
diff --git a/idl/Accessibility_Relation.idl b/idl/Accessibility_Relation.idl index 8941b34..b562ffc 100644 --- a/idl/Accessibility_Relation.idl +++ b/idl/Accessibility_Relation.idl @@ -39,9 +39,10 @@ module Accessibility { * This interface inherits from a base class implementing ref counts. */ - interface Relation { + interface Relation : Bonobo::Unknown { RelationType getRelationType (); - Object getTarget (); + short getNTargets (); + Object getTarget (in short index); }; }; diff --git a/idl/Relation.idl b/idl/Relation.idl index 8941b34..b562ffc 100644 --- a/idl/Relation.idl +++ b/idl/Relation.idl @@ -39,9 +39,10 @@ module Accessibility { * This interface inherits from a base class implementing ref counts. */ - interface Relation { + interface Relation : Bonobo::Unknown { RelationType getRelationType (); - Object getTarget (); + short getNTargets (); + Object getTarget (in short index); }; }; diff --git a/libspi/Makefile.am b/libspi/Makefile.am index 600b257..dd02937 100644 --- a/libspi/Makefile.am +++ b/libspi/Makefile.am @@ -23,6 +23,7 @@ libspiinclude_HEADERS = accessible.h \ hyperlink.h\ hypertext.h\ image.h\ + relation.h\ selection.h\ table.h\ text.h\ @@ -73,6 +74,8 @@ libspi_la_SOURCES = accessible.c \ image.h\ keystrokelistener.c\ keystrokelistener.h\ + relation.c\ + relation.h\ selection.c\ selection.h\ table.c\ diff --git a/libspi/accessible.c b/libspi/accessible.c index e2b5822..f0ed8ca 100644 --- a/libspi/accessible.c +++ b/libspi/accessible.c @@ -225,13 +225,22 @@ impl_accessibility_accessible_get_relation_set (PortableServer_Servant servant, CORBA_Environment *ev) { Accessibility_RelationSet *retval; -/* SpiAccessible *accessible = SPI_ACCESSIBLE (bonobo_object_from_servant (servant)); - AtkRelationSet *relation_set = atk_object_ref_relation_set (accessible->atko); */ + gint n_relations; + gint i; + SpiAccessible *accessible = SPI_ACCESSIBLE (bonobo_object_from_servant (servant)); + AtkRelationSet *relation_set = atk_object_ref_relation_set (accessible->atko); + n_relations = atk_relation_set_get_n_relations (relation_set); retval = CORBA_sequence_Accessibility_Relation__alloc (); - /* - * TODO: fill the sequence with relation set objects, themselves - * initialized from the AtkRelation object in the AtkRelationSet. - */ + CORBA_sequence_Accessibility_Relation_allocbuf (n_relations); + + for (i=0; i_buffer[i] = + CORBA_Object_duplicate (bonobo_object_corba_objref ( + spi_relation_new (atk_relation_set_get_relation (relation_set, i))), + ev); + } + printf ("SpiAccessible get_relation_set.\n"); return retval; } @@ -246,7 +255,7 @@ impl_accessibility_accessible_get_role (PortableServer_Servant servant, Accessibility_Role retval; SpiAccessible *accessible = SPI_ACCESSIBLE (bonobo_object_from_servant (servant)); AtkRole role = atk_object_get_role (accessible->atko); - retval = role; + retval = role; /* relies on ability to cast these back and forth */ printf ("SpiAccessible get_role.\n"); return (Accessibility_Role) retval; } diff --git a/libspi/hyperlink.c b/libspi/hyperlink.c index a858742..4125541 100644 --- a/libspi/hyperlink.c +++ b/libspi/hyperlink.c @@ -135,18 +135,18 @@ static void spi_hyperlink_finalize (GObject *obj) { SpiHyperlink *hyperlink = SPI_HYPERLINK(obj); - g_object_unref (hyperlink->atko); - hyperlink->atko = NULL; + g_object_unref (hyperlink->hyperlink); + hyperlink->hyperlink = NULL; parent_class->finalize (obj); } SpiHyperlink * -spi_hyperlink_interface_new (AtkObject *obj) +spi_hyperlink_new (AtkHyperlink *hyperlink) { SpiHyperlink *new_hyperlink = SPI_HYPERLINK(g_object_new (SPI_HYPERLINK_TYPE, NULL)); - new_hyperlink->atko = obj; - g_object_ref (obj); + g_object_ref (hyperlink); + new_hyperlink->hyperlink = hyperlink; return new_hyperlink; } @@ -157,7 +157,7 @@ impl__get_n_anchors (PortableServer_Servant _servant, CORBA_Environment * ev) { SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant)); - return (CORBA_short) atk_hyperlink_get_n_anchors (ATK_HYPERLINK(link->atko)); + return (CORBA_short) atk_hyperlink_get_n_anchors (ATK_HYPERLINK(link->hyperlink)); } @@ -167,7 +167,7 @@ impl__get_startIndex (PortableServer_Servant _servant, CORBA_Environment * ev) { SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant)); - return (CORBA_long) atk_hyperlink_get_start_index (ATK_HYPERLINK(link->atko)); + return (CORBA_long) atk_hyperlink_get_start_index (ATK_HYPERLINK(link->hyperlink)); } @@ -177,7 +177,7 @@ impl__get_endIndex (PortableServer_Servant _servant, CORBA_Environment * ev) { SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant)); - return (CORBA_long) atk_hyperlink_get_end_index (ATK_HYPERLINK(link->atko)); + return (CORBA_long) atk_hyperlink_get_end_index (ATK_HYPERLINK(link->hyperlink)); } @@ -189,7 +189,7 @@ impl_getURI (PortableServer_Servant _servant, SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant)); gchar *uri; CORBA_char *rv; - uri = atk_hyperlink_get_uri (ATK_HYPERLINK(link->atko), (gint) i); + uri = atk_hyperlink_get_uri (ATK_HYPERLINK(link->hyperlink), (gint) i); if (uri) { rv = CORBA_string_dup (uri); @@ -210,7 +210,7 @@ impl_getObject (PortableServer_Servant _servant, SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant)); AtkObject *atk_object; Accessibility_Accessible rv; - atk_object = atk_hyperlink_get_object (ATK_HYPERLINK(link->atko), (gint) i); + atk_object = atk_hyperlink_get_object (ATK_HYPERLINK(link->hyperlink), (gint) i); rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(atk_object))); return rv; } @@ -222,7 +222,7 @@ impl_isValid (PortableServer_Servant _servant, CORBA_Environment * ev) { SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant)); - return (CORBA_boolean) atk_hyperlink_is_valid (ATK_HYPERLINK(link->atko)); + return (CORBA_boolean) atk_hyperlink_is_valid (ATK_HYPERLINK(link->hyperlink)); } diff --git a/libspi/hyperlink.h b/libspi/hyperlink.h index 4537828..6789517 100644 --- a/libspi/hyperlink.h +++ b/libspi/hyperlink.h @@ -40,7 +40,7 @@ typedef struct _HyperlinkClass SpiHyperlinkClass; struct _Hyperlink { BonoboObject parent; - AtkObject *atko; + AtkHyperlink *hyperlink; }; struct _HyperlinkClass { @@ -52,7 +52,7 @@ GType spi_hyperlink_get_type (void); SpiHyperlink * -spi_hyperlink_interface_new (AtkObject *obj); +spi_hyperlink_new (); #ifdef __cplusplus } diff --git a/libspi/hypertext.c b/libspi/hypertext.c index cce53e1..7c750b4 100644 --- a/libspi/hypertext.c +++ b/libspi/hypertext.c @@ -183,7 +183,7 @@ impl_getLink (PortableServer_Servant _servant, link = atk_hypertext_get_link (ATK_HYPERTEXT(hypertext->atko), (gint) linkIndex); - rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_hyperlink_interface_new(ATK_OBJECT(link)))); + rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_hyperlink_new(ATK_OBJECT(link)))); return rv; } diff --git a/libspi/relation.c b/libspi/relation.c new file mode 100644 index 0000000..d3877ef --- /dev/null +++ b/libspi/relation.c @@ -0,0 +1,147 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2001 Sun Microsystems 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. + */ + +/* + * relation.c : bonobo wrapper for accessible relation implementation + * + */ +#include +#include + +#include + +/* + * This pulls the CORBA definitions for the "Accessibility::Accessible" server + */ +#include + +/* + * This pulls the definition of the relation bonobo object + */ +#include "relation.h" + +/* + * Static function declarations + */ + +static void +spi_relation_class_init (SpiRelationClass *klass); +static void +spi_relation_init (SpiRelation *relation); +static void +spi_relation_finalize (GObject *obj); +static CORBA_string +impl_getURI (PortableServer_Servant _servant, + const CORBA_long i, CORBA_Environment * ev); +static CORBA_short +impl__get_n_anchors (PortableServer_Servant _servant, + CORBA_Environment * ev); +static CORBA_long +impl__get_startIndex (PortableServer_Servant _servant, + CORBA_Environment * ev); +static CORBA_long +impl__get_endIndex (PortableServer_Servant _servant, + CORBA_Environment * ev); +static Accessibility_Accessible +impl_getObject (PortableServer_Servant _servant, + const CORBA_long i, + CORBA_Environment * ev); +static CORBA_boolean +impl_isValid (PortableServer_Servant _servant, + CORBA_Environment * ev); + +static GObjectClass *parent_class; + +GType +spi_relation_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo tinfo = { + sizeof (SpiRelationClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) spi_relation_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class data */ + sizeof (SpiRelation), + 0, /* n preallocs */ + (GInstanceInitFunc) spi_relation_init, + NULL /* value table */ + }; + + /* + * Bonobo_type_unique auto-generates a load of + * CORBA structures for us. All derived types must + * use bonobo_type_unique. + */ + type = bonobo_type_unique ( + BONOBO_OBJECT_TYPE, + POA_Accessibility_Relation__init, + NULL, + G_STRUCT_OFFSET (SpiRelationClass, epv), + &tinfo, + "SpiAccessibleRelation"); + } + + return type; +} + +static void +spi_relation_class_init (SpiRelationClass *klass) +{ + GObjectClass * object_class = (GObjectClass *) klass; + POA_Accessibility_Relation__epv *epv = &klass->epv; + parent_class = g_type_class_peek_parent (klass); + + object_class->finalize = spi_relation_finalize; + + epv->getRelationType = NULL; /* TODO: finish me! */ + epv->getNTargets = NULL; + epv->getTarget = NULL; +} + +static void +spi_relation_init (SpiRelation *relation) +{ +} + +static void +spi_relation_finalize (GObject *obj) +{ + SpiRelation *relation = SPI_RELATION(obj); + g_object_unref (relation->relation); + relation->relation = NULL; + parent_class->finalize (obj); +} + +SpiRelation * +spi_relation_new (AtkRelation *obj) +{ + SpiRelation *new_relation = + SPI_RELATION (g_object_new (SPI_RELATION_TYPE, NULL)); + new_relation->relation = obj; + g_object_ref (obj); + return new_relation; +} + diff --git a/libspi/relation.h b/libspi/relation.h new file mode 100644 index 0000000..59806af --- /dev/null +++ b/libspi/relation.h @@ -0,0 +1,62 @@ +/* AT-SPI - Assistive Technology Service Provider Interface + * + * Copyright 2001 Sun Microsystems 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. + */ + +#ifndef SPI_RELATION_H_ +#define SPI_RELATION_H_ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include +#include + +#define SPI_RELATION_TYPE (spi_relation_get_type ()) +#define SPI_RELATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_RELATION_TYPE, SpiRelation)) +#define SPI_RELATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_RELATION_TYPE, SpiRelationClass)) +#define IS_SPI_RELATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPI_RELATION_TYPE)) +#define IS_SPI_RELATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_RELATION_TYPE)) + +typedef struct _SpiRelation SpiRelation; +typedef struct _SpiRelationClass SpiRelationClass; + +struct _SpiRelation { + BonoboObject parent; + AtkRelation *relation; +}; + +struct _SpiRelationClass { + BonoboObjectClass parent_class; + POA_Accessibility_Relation__epv epv; +}; + +GType +spi_relation_get_type (void); + +SpiRelation * +spi_relation_new (AtkRelation *relation); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SPI_RELATION_H_ */