From d0405018df7bc391ef2988f03dcc836c9d563a55 Mon Sep 17 00:00:00 2001 From: billh Date: Thu, 16 Aug 2001 13:20:15 +0000 Subject: [PATCH] Added initial support for multiple interfaces on Accessible objects in at-spi. Added implementations for Accessible:getParent, getChildCount, getChildAtIndex. Improved event type matching to support listeners for either detail event subtypes (major:minor:detail) as well as major:minor. Added component.c, component.h bonobo objects (as implementors of the Component.idl interfaces). git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@26 e2bd861d-eb25-0410-b326-f6ed22b6b98c --- ChangeLog | 26 +++++++++++- libspi/Makefile.am | 3 ++ libspi/accessible.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++-- libspi/accessible.h | 2 + libspi/listener.c | 6 +++ libspi/registry.c | 8 ++-- registryd/registry.c | 8 ++-- 7 files changed, 157 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index e1b69cf..4978fdc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2001-08-16 Bill Haneman + + * libspi/accessible.c : accessible_new() : + Now we add the Component interface via bonobo_object_add_interface, + if the contained AtkObject implements AtkComponent. + * libspi/accessible.h : now include "component.h" + * libspi/component.h : + * libspi/component.c : added files - implementation of + bonobo wrapper object for Accessibility/Component + * libspi/listener.c : + Added test code to check for Accessibility/Component:1.0 + interface and report whether it is implemented by the + event source. + * libspi/registry.c : + Now we check for not only the hash of the whole event + string before relaying the event, we also check the + "minor" event string (without the detail string). + This allows event listeners to be registered against + all events of a certain major+minor type, or just + against a specific major+minor+detail type. + * libspi/accessible.c : + Added implementations for Accessible:get_parent(), + Accessible:getChildCount(), and Accessible:getChildAtIndex(). + 2001-08-15 Mark McLoughlin * libspi/Makefile.am, @@ -13,7 +37,7 @@ 2001-08-15 Mark McLoughlin - * test/app.c: use atgv[0] instead of + * test/app.c: use argv[0] instead of g_type_prgname. 2001-08-15 Mark McLoughlin diff --git a/libspi/Makefile.am b/libspi/Makefile.am index 618abda..89e3055 100644 --- a/libspi/Makefile.am +++ b/libspi/Makefile.am @@ -15,6 +15,7 @@ CFLAGS += $(DEBUG_CFLAGS) libspiincludedir = $(includedir)/libspi libspiinclude_HEADERS = accessible.h \ + component.h \ application.h \ desktop.h \ listener.h \ @@ -41,6 +42,8 @@ libspi_la_SOURCES = accessible.c \ accessible.h \ application.c \ application.h \ + component.c \ + component.h \ desktop.c \ desktop.h \ listener.c \ diff --git a/libspi/accessible.c b/libspi/accessible.c index 7e9634a..fec72e7 100644 --- a/libspi/accessible.c +++ b/libspi/accessible.c @@ -123,6 +123,52 @@ impl_accessibility_accessible_set_description (PortableServer_Servant servant, printf ("Accessible set_description called: %s\n", name); } +/* + * CORBA Accessibility::Accessible::get_parent method implementation + */ +static Accessibility_Accessible +impl_accessibility_accessible_get_parent (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + Accessibility_Accessible retval; + Accessible *accessible = ACCESSIBLE (bonobo_object_from_servant (servant)); + AtkObject *parent; + parent = atk_object_get_parent (accessible->atko); + retval = bonobo_object_corba_objref (bonobo_object (accessible_new (parent))); + printf ("Accessible get_parent called\n"); + return retval; +} + +/* + * CORBA Accessibility::Accessible::get_childCount method implementation + */ +static CORBA_long +impl_accessibility_accessible_get_child_count (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + CORBA_long retval; + Accessible *accessible = ACCESSIBLE (bonobo_object_from_servant (servant)); + retval = (CORBA_long) atk_object_get_n_accessible_children (accessible->atko); + printf ("Accessible get_childCount called: %d\n", (int) retval); + return retval; +} + +/* + * CORBA Accessibility::Accessible::getChildAtIndex method implementation + */ +static Accessibility_Accessible +impl_accessibility_accessible_get_child_at_index (PortableServer_Servant servant, + const CORBA_long index, + CORBA_Environment *ev) +{ + Accessibility_Accessible retval; + Accessible *accessible = ACCESSIBLE (bonobo_object_from_servant (servant)); + AtkObject *child = atk_object_ref_accessible_child (accessible->atko, (gint) index); + retval = bonobo_object_corba_objref ( bonobo_object (accessible_new (child))); + printf ("Accessible get_child_at_index called.\n"); + return retval; +} + static void accessible_class_init (AccessibleClass *klass) { @@ -137,9 +183,10 @@ accessible_class_init (AccessibleClass *klass) epv->_get_description = impl_accessibility_accessible_get_description; epv->_set_description = impl_accessibility_accessible_set_description; - /* epv->_get_parent = impl_accessibility_accessible_get_parent; */ - /* epv->_get_childCount = impl_accessibility_accessible_get_child_count; */ - /* epv->getChildAtIndex = impl_accessibility_accessible_get_child_at_index; */ + epv->_get_parent = impl_accessibility_accessible_get_parent; + epv->_get_childCount = impl_accessibility_accessible_get_child_count; + epv->getChildAtIndex = impl_accessibility_accessible_get_child_at_index; + /* epv->getIndexInParent = impl_accessibility_accessible_get_index_in_parent; */ /* epv->getRelationSet = impl_accessibility_accessible_get_relation_set; */ /* epv->getState = impl_accessibility_accessible_get_state; */ @@ -193,5 +240,66 @@ accessible_new (AtkObject *o) ACCESSIBLE (g_object_new (accessible_get_type (), NULL)); g_object_ref (o); retval->atko = ATK_OBJECT (o); + + /* + * TODO: add interface containers/constructors for ACTION, EDITABLE_TEXT, HYPERTEXT, + * IMAGE, SELECTION, TABLE, TEXT, VALUE. + */ + + /* add appropriate ATK interfaces */ + + /* Action: not yet implemented + if (ATK_IS_ACTION (o)) + { + bonobo_object_add_interface (bonobo_object (retval), + bonobo_object (action_interface_new (o))); + } + */ + + if (ATK_IS_COMPONENT (o)) + { + bonobo_object_add_interface (bonobo_object (retval), + bonobo_object (component_interface_new (o))); + } + + /* Others: not yet implemented + if (ATK_IS_EDITABLE_TEXT (o)) + { + bonobo_object_add_interface (bonobo_object (retval), + bonobo_object (editable_text_interface_new (o))); + } + else if (ATK_IS_HYPERTEXT (o)) + { + bonobo_object_add_interface (bonobo_object (retval), + bonobo_object (hypertext_interface_new (o))); + } + else if (ATK_IS_TEXT (o)) + { + bonobo_object_add_interface (bonobo_object (retval), + bonobo_object (text_interface_new (o))); + } + if (ATK_IS_IMAGE (o)) + { + bonobo_object_add_interface (bonobo_object (retval), + bonobo_object (image_interface_new (o))); + } + if (ATK_IS_SELECTION (o)) + { + bonobo_object_add_interface (bonobo_object (retval), + bonobo_object (selection_interface_new (o))); + } + if (ATK_IS_TABLE (o)) + { + bonobo_object_add_interface (bonobo_object (retval), + bonobo_object (table_interface_new (o))); + } + if (ATK_IS_VALUE (o)) + { + bonobo_object_add_interface (bonobo_object (retval), + bonobo_object (value_interface_new (o))); + } + + */ + return retval; } diff --git a/libspi/accessible.h b/libspi/accessible.h index 406d026..452ce78 100644 --- a/libspi/accessible.h +++ b/libspi/accessible.h @@ -48,6 +48,8 @@ typedef struct { GType accessible_get_type (void); Accessible *accessible_new (AtkObject *o); +#include "component.h" + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/libspi/listener.c b/libspi/listener.c index 0a804e7..d87aefe 100644 --- a/libspi/listener.c +++ b/libspi/listener.c @@ -81,6 +81,12 @@ impl_notify_event (PortableServer_Servant servant, CORBA_exception_id(ev)); exit(-1); } + fprintf (stderr, "source is component ? : %s\n", + Accessibility_Accessible_queryInterface (e->target, + "IDL:Accessibility/Component:1.0", + ev) + ? "yes" : "no"); + #endif Accessibility_Accessible_unref(e->target, ev); diff --git a/libspi/registry.c b/libspi/registry.c index 94c00b2..ff794f8 100644 --- a/libspi/registry.c +++ b/libspi/registry.c @@ -147,14 +147,14 @@ parse_event_type (EventTypeStruct *etype, char *event_name) { delimiter = g_utf8_get_char (":"); } + major_delim_char = g_utf8_strchr (event_name, (gssize) 32, delimiter); minor_delim_char = g_utf8_strrchr (event_name, (gssize) 255, delimiter); nbytes = (guint)((gint64) minor_delim_char - (gint64) major_delim_char); - fprintf ("nbytes = %ld", (long) nbytes); - + fprintf (stderr, "nbytes = %ld\n", (long) nbytes); if (!g_ascii_strncasecmp (event_name, "focus:", 6)) { etype->major = ETYPE_FOCUS; @@ -410,7 +410,9 @@ registry_notify_listeners ( GList *listeners, int len; ListenerStruct *ls; EventTypeStruct etype; + guint minor_hash; parse_event_type (&etype, e->type); + minor_hash = g_str_hash (etype.minor); len = g_list_length (listeners); for (n=0; nevent_type_hash, etype.hash); #endif - if ((ls->event_type_hash == etype.hash) || (TRUE)) + if ((ls->event_type_hash == etype.hash) || (ls->event_type_hash == minor_hash)) { #ifdef SPI_DEBUG fprintf(stderr, "notifying listener #%d\n", n); diff --git a/registryd/registry.c b/registryd/registry.c index 94c00b2..ff794f8 100644 --- a/registryd/registry.c +++ b/registryd/registry.c @@ -147,14 +147,14 @@ parse_event_type (EventTypeStruct *etype, char *event_name) { delimiter = g_utf8_get_char (":"); } + major_delim_char = g_utf8_strchr (event_name, (gssize) 32, delimiter); minor_delim_char = g_utf8_strrchr (event_name, (gssize) 255, delimiter); nbytes = (guint)((gint64) minor_delim_char - (gint64) major_delim_char); - fprintf ("nbytes = %ld", (long) nbytes); - + fprintf (stderr, "nbytes = %ld\n", (long) nbytes); if (!g_ascii_strncasecmp (event_name, "focus:", 6)) { etype->major = ETYPE_FOCUS; @@ -410,7 +410,9 @@ registry_notify_listeners ( GList *listeners, int len; ListenerStruct *ls; EventTypeStruct etype; + guint minor_hash; parse_event_type (&etype, e->type); + minor_hash = g_str_hash (etype.minor); len = g_list_length (listeners); for (n=0; nevent_type_hash, etype.hash); #endif - if ((ls->event_type_hash == etype.hash) || (TRUE)) + if ((ls->event_type_hash == etype.hash) || (ls->event_type_hash == minor_hash)) { #ifdef SPI_DEBUG fprintf(stderr, "notifying listener #%d\n", n); -- 2.7.4