Added initial support for multiple interfaces on Accessible objects
authorbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Thu, 16 Aug 2001 13:20:15 +0000 (13:20 +0000)
committerbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Thu, 16 Aug 2001 13:20:15 +0000 (13:20 +0000)
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
libspi/Makefile.am
libspi/accessible.c
libspi/accessible.h
libspi/listener.c
libspi/registry.c
registryd/registry.c

index e1b69cf..4978fdc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2001-08-16  Bill Haneman <bill.haneman@sun.com>
+
+       * 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 <mark@skynet.ie>
 
        * libspi/Makefile.am,
 2001-08-15  Mark McLoughlin <mark@skynet.ie>
 
        * libspi/Makefile.am,
@@ -13,7 +37,7 @@
 
 2001-08-15  Mark McLoughlin <mark@skynet.ie>
 
 
 2001-08-15  Mark McLoughlin <mark@skynet.ie>
 
-       * test/app.c: use atgv[0] instead of
+       * test/app.c: use argv[0] instead of
        g_type_prgname.
 
 2001-08-15  Mark McLoughlin <mark@skynet.ie>
        g_type_prgname.
 
 2001-08-15  Mark McLoughlin <mark@skynet.ie>
index 618abda..89e3055 100644 (file)
@@ -15,6 +15,7 @@ CFLAGS += $(DEBUG_CFLAGS)
 libspiincludedir = $(includedir)/libspi
 
 libspiinclude_HEADERS = accessible.h       \
 libspiincludedir = $(includedir)/libspi
 
 libspiinclude_HEADERS = accessible.h       \
+                       component.h        \
                         application.h      \
                         desktop.h          \
                         listener.h         \
                         application.h      \
                         desktop.h          \
                         listener.h         \
@@ -41,6 +42,8 @@ libspi_la_SOURCES = accessible.c         \
                     accessible.h         \
                     application.c        \
                     application.h        \
                     accessible.h         \
                     application.c        \
                     application.h        \
+                   component.c          \
+                   component.h          \
                     desktop.c            \
                     desktop.h            \
                     listener.c           \
                     desktop.c            \
                     desktop.h            \
                     listener.c           \
index 7e9634a..fec72e7 100644 (file)
@@ -123,6 +123,52 @@ impl_accessibility_accessible_set_description (PortableServer_Servant servant,
   printf ("Accessible set_description called: %s\n", name);
 }
 
   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)
 {
 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_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;                   */
         /* 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);
                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;
 }
     return retval;
 }
index 406d026..452ce78 100644 (file)
@@ -48,6 +48,8 @@ typedef struct {
 GType                  accessible_get_type   (void);
 Accessible             *accessible_new       (AtkObject *o);
 
 GType                  accessible_get_type   (void);
 Accessible             *accessible_new       (AtkObject *o);
 
+#include "component.h"
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 0a804e7..d87aefe 100644 (file)
@@ -81,6 +81,12 @@ impl_notify_event (PortableServer_Servant     servant,
             CORBA_exception_id(ev));
     exit(-1);
   }
             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);
 
 #endif
   Accessibility_Accessible_unref(e->target, ev);
 
index 94c00b2..ff794f8 100644 (file)
@@ -147,14 +147,14 @@ parse_event_type (EventTypeStruct *etype, char *event_name)
     {
       delimiter = g_utf8_get_char (":");
     }
     {
       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);
 
   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;
   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;
   int len;
   ListenerStruct *ls;
   EventTypeStruct etype;
+  guint minor_hash;
   parse_event_type (&etype, e->type);
   parse_event_type (&etype, e->type);
+  minor_hash = g_str_hash (etype.minor);
   len = g_list_length (listeners);
 
   for (n=0; n<len; ++n)
   len = g_list_length (listeners);
 
   for (n=0; n<len; ++n)
@@ -419,7 +421,7 @@ registry_notify_listeners ( GList *listeners,
 #ifdef SPI_DEBUG
       fprintf(stderr, "event hashes: %lx %lx\n", ls->event_type_hash, etype.hash);
 #endif
 #ifdef SPI_DEBUG
       fprintf(stderr, "event hashes: %lx %lx\n", ls->event_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);
         {
 #ifdef SPI_DEBUG
           fprintf(stderr, "notifying listener #%d\n", n);
index 94c00b2..ff794f8 100644 (file)
@@ -147,14 +147,14 @@ parse_event_type (EventTypeStruct *etype, char *event_name)
     {
       delimiter = g_utf8_get_char (":");
     }
     {
       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);
 
   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;
   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;
   int len;
   ListenerStruct *ls;
   EventTypeStruct etype;
+  guint minor_hash;
   parse_event_type (&etype, e->type);
   parse_event_type (&etype, e->type);
+  minor_hash = g_str_hash (etype.minor);
   len = g_list_length (listeners);
 
   for (n=0; n<len; ++n)
   len = g_list_length (listeners);
 
   for (n=0; n<len; ++n)
@@ -419,7 +421,7 @@ registry_notify_listeners ( GList *listeners,
 #ifdef SPI_DEBUG
       fprintf(stderr, "event hashes: %lx %lx\n", ls->event_type_hash, etype.hash);
 #endif
 #ifdef SPI_DEBUG
       fprintf(stderr, "event hashes: %lx %lx\n", ls->event_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);
         {
 #ifdef SPI_DEBUG
           fprintf(stderr, "notifying listener #%d\n", n);