Added implementation for a Accessibility_Accessible_getIndexInParent ();
authorbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Sat, 18 Aug 2001 16:30:07 +0000 (16:30 +0000)
committerbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Sat, 18 Aug 2001 16:30:07 +0000 (16:30 +0000)
Added headers included by cspi/spi.h.
Added initial implementation of SPI C bindings (cspi/spi_main.c).
(Not yet built).

git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@35 e2bd861d-eb25-0410-b326-f6ed22b6b98c

ChangeLog
cspi/spi-impl.h [new file with mode: 0644]
cspi/spi-roletypes.h [new file with mode: 0644]
cspi/spi-statetypes.h [new file with mode: 0644]
cspi/spi.h
cspi/spi_main.c [new file with mode: 0644]
libspi/accessible.c

index 46371f7..a0f51f3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2001-08-18  Bill Haneman <bill.haneman@sun.com>
+
+       * libspi/accessible.c: 
+       Add implementation for get_index_in_parent().
+       * cspi/spi.h : 
+       Added #include of "spi-roletypes.h", and
+       added enumerated type AccessibleCoordType.
+       Added definition for KeystrokeListener (function type).
+
+       ADDED FILES:
+       * cspi/spi-statetypes.h :
+       * cspi/spi-roletypes.h :
+       * cspi/spi-impl.h :
+       Added these headers, used by spi.h.
+       * cspi/spi_main.c : 
+       Added code (NOTE: not yet built by make).
+
 2001-08-18  Mark McLoughlin <mark@skynet.ie>
 
        * libspi/Makefile.am: generate imodule
diff --git a/cspi/spi-impl.h b/cspi/spi-impl.h
new file mode 100644 (file)
index 0000000..28653f6
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef _SPI_IMPL_H_
+#define _SPI_IMPL_H_
+
+#include <orb/orbit.h>
+
+typedef unsigned int boolean;
+
+typedef CORBA_Object Accessible;
+typedef CORBA_Object AccessibleAction;
+typedef CORBA_Object AccessibleApplication;
+typedef CORBA_Object AccessibleComponent;
+typedef CORBA_Object AccessibleEditableText;
+typedef CORBA_Object AccessibleHyperlink;
+typedef CORBA_Object AccessibleHypertext;
+typedef CORBA_Object AccessibleImage;
+typedef CORBA_Object AccessibleRelation;
+typedef CORBA_Object AccessibleSelection;
+typedef CORBA_Object AccessibleStateSet;
+typedef CORBA_Object AccessibleTable;
+typedef CORBA_Object AccessibleText;
+typedef CORBA_Object AccessibleValue;
+typedef CORBA_Object Accessibility_Registry;
+
+#endif
diff --git a/cspi/spi-roletypes.h b/cspi/spi-roletypes.h
new file mode 100644 (file)
index 0000000..d4c25c5
--- /dev/null
@@ -0,0 +1,190 @@
+#ifndef _SPI_ROLETYPES_H_
+#define _SPI_ROLETYPES_H_
+
+/*
+ *
+ * Enumerated type for AccessibleRole
+ *
+ */
+
+typedef enum
+{
+  ROLE_INVALID,
+  /* Object is used to alert the user about something */
+  ROLE_ALERT,
+  /* Object that can be drawn into and is used to trap events */
+  ROLE_CANVAS,
+  /*
+   * A choice that can be checked or unchecked and provides a separate
+   * indicator for the current state.
+   */
+  ROLE_CHECK_BOX,
+  /* A specialized dialog that lets the user choose a color. */
+  ROLE_COLOR_CHOOSER,
+  /* The header for a column of data */
+  ROLE_COLUMN_HEADER,
+  /* A list of choices the user can select from */
+  ROLE_COMBO_BOX,
+  /* An inconifed internal frame within a DESKTOP_PANE */
+  ROLE_DESKTOP_ICON,
+  /*
+   * A pane that supports internal frames and iconified versions of those
+   * internal frames.
+   */
+  ROLE_DESKTOP_FRAME,
+  /* A top level window with title bar and a border */
+  ROLE_DIALOG,
+  /*
+   * A pane that allows the user to navigate through and select the contents
+   * of a directory
+   */
+  ROLE_DIRECTORY_PANE,
+  /*
+   * A specialized dialog that displays the files in the directory and lets
+   * the user select a file, browse a different directory, or specify a
+   * filename.
+   */
+  ROLE_FILE_CHOOSER,
+  /*
+   * A object that fills up space in a user interface
+   */
+  ROLE_FILLER,
+  /* XXX Don't know sure about this. */
+  ROLE_FOCUS_TRAVERSABLE,
+  /* A top level window with a title bar, border, menubar, etc. */
+  ROLE_FRAME,
+  /* A pane that is guaranteed to be painted on top of all panes beneath it */
+  ROLE_GLASS_PANE,
+  /*
+   * A document container for HTML, whose children
+   * represent the document content.
+   */
+  ROLE_HTML_CONTAINER,
+  /* A small fixed size picture, typically used to decorate components */
+  ROLE_ICON,
+  /* A frame-like object that is clipped by a desktop pane. */
+  ROLE_INTERNAL_FRAME,
+  /* An object used to present an icon or short string in an interface */
+  ROLE_LABEL,
+  /*
+   * A specialized pane that allows its children to be drawn in layers,
+   * providing a form of stacking order.
+   */
+  ROLE_LAYERED_PANE,
+  /*
+   * An object that presents a list of objects to the user and allows the
+   * user to select one or more of them.
+   */
+  ROLE_LIST,
+   /* An object that represents an element of a list. */
+  ROLE_LIST_ITEM,
+  /*
+   * An object usually found inside a menu bar that contains a list of
+   * actions the user can choose from.
+   */
+  ROLE_MENU,
+  /*
+   * An object usually drawn at the top of the primary dialog box of an
+   * application that contains a list of menus the user can choose from.
+   */
+  ROLE_MENU_BAR,
+  /*
+   * An object usually contained in a menu that presents an action the
+   * user can choose.
+   */
+  ROLE_MENU_ITEM,
+  /* A specialized pane whose primary use is inside a DIALOG */
+  ROLE_OPTION_PANE,
+  /* An object that is a child of a page tab list */
+  ROLE_PAGE_TAB,
+  /*
+   * An object that presents a series of panels (or page tabs), one at a time,
+   * through some mechanism provided by the object.
+   */
+  ROLE_PAGE_TAB_LIST,
+  /* A generic container that is often used to group objects. */
+  ROLE_PANEL,
+  /*
+   * A text object uses for passwords, or other places where the text
+   * content is not shown visibly to the user.
+   */
+  ROLE_PASSWORD_TEXT,
+  /*
+   * A temporary window that is usually used to offer the user a list of
+   * choices, and then hides when the user selects one of those choices.
+   */
+  ROLE_POPUP_MENU,
+  /* An object used to indicate how much of a task has been completed. */
+  ROLE_PROGRESS_BAR,
+  /*
+   * An object the user can manipulate to tell the application to do
+   * something.
+   */
+  ROLE_PUSH_BUTTON,
+  /*
+   * A specialized check box that will cause other radio buttons in the
+   * same group to become uncghecked when this one is checked.
+   */
+  ROLE_RADIO_BUTTON,
+  /*
+   * A specialized pane that has a glass pane and a layered pane as its
+   * children.
+   */
+  ROLE_ROOT_PANE,
+  /* The header for a row of data */
+  ROLE_ROW_HEADER,
+  /*
+   * An object usually used to allow a user to incrementally view a large
+   * amount of data.
+   */
+  ROLE_SCROLL_BAR,
+  /*
+   * An object that allows a user to incrementally view a large amount
+   * of information.
+   */
+  ROLE_SCROLL_PANE,
+  /*
+   * An object usually contained in a menu to provide a visible and
+   * logical separation of the contents in a menu.
+   */
+  ROLE_SEPARATOR,
+  /* An object that allows the user to select from a bounded range */
+  ROLE_SLIDER,
+  /* A specialized panel that presents two other panels at the same time. */
+  ROLE_SPLIT_PANE,
+  /* An object used to rpesent information in terms of rows and columns. */
+  ROLE_TABLE,
+  ROLE_TABLE_CELL,
+  ROLE_TABLE_COLUMN_HEADER,
+  ROLE_TABLE_ROW_HEADER,
+  /* An object that presents text to the user */
+  ROLE_TEXT,
+  /*
+   * A specialized push button that can be checked or unchecked, but does
+   * not procide a separate indicator for the current state.
+   */
+  ROLE_TOGGLE_BUTTON,
+  /*
+   * A bar or palette usually composed of push buttons or toggle buttons
+   */
+  ROLE_TOOL_BAR,
+  /*
+   * An object that provides information about another object
+   */
+  ROLE_TOOL_TIP,
+  /* An object used to repsent hierarchical information to the user. */
+  ROLE_TREE,
+  /*
+   * The object contains some Accessible information, but its role is
+   * not known.
+   */
+  ROLE_UNKNOWN,
+  /* An object usually used in a scroll pane. */
+  ROLE_VIEWPORT,
+  /* A top level window with no title or border */
+  ROLE_WINDOW,
+  /* not a valid role, used for finding end of enumeration. */
+  ROLE_LAST_DEFINED
+} ACCESSIBLE_ROLE;
+
+#endif
diff --git a/cspi/spi-statetypes.h b/cspi/spi-statetypes.h
new file mode 100644 (file)
index 0000000..82d7048
--- /dev/null
@@ -0,0 +1,89 @@
+#ifndef _SPI_STATETYPES_H_
+#define _SPI_STATETYPES_H_
+
+/*
+ *
+ * Enumerated type for accessible state
+ *
+ */
+
+typedef enum
+{
+  STATE_INVALID,
+  /* Indicates a window is currently the active window */
+  STATE_ACTIVE,
+  /* Indicates that the object is armed */
+  STATE_ARMED,
+  /* Indicates the current object is busy */
+  STATE_BUSY,
+  /* Indicates this object is currently checked */
+  STATE_CHECKED,
+  /* Indicates this object is collapsed */
+  STATE_COLLAPSED,
+  /* Indicates the user can change the contents of this object */
+  STATE_EDITABLE,
+  /* Indicates this object allows progressive disclosure of its children */
+  STATE_EXPANDABLE,
+  /* Indicates this object its expanded */
+  STATE_EXPANDED,
+  /*
+   * Indicates this object can accept keyboard focus, which means all
+   * events resulting from typing on the keyboard will normally be passed
+   * to it when it has focus
+   */
+  STATE_FOCUSABLE,
+  /* Indicates this object currently has the keyboard focus */
+  STATE_FOCUSED,
+  /* Indicates the orientation of thsi object is horizontal */
+  STATE_HORIZONTAL,
+  /* Indicates this object is minimized and is represented only by an icon */
+  STATE_ICONIFIED,
+  /*
+   * Indicates something must be done with this object before the user can
+   * interact with an object in a different window.
+   */
+  STATE_MODAL,
+  /* Indicates this (text) object can contain multiple lines of text */
+  STATE_MULTI_LINE,
+  /*
+   * Indicates this object allows more than one of its children to be
+   * selected at the same time
+   */
+  STATE_MULTISELECTABLE,
+  /* Indicates this object paints every pixel within its rectangular region. */
+  STATE_OPAQUE,
+  /* Indicates this object is currently pressed */
+  STATE_PRESSED,
+  /* Indicates the size of this object is not fixed */
+  STATE_RESIZABLE,
+  /*
+   * Indicates this object is the child of an object that allows its
+   * children to be selected and that this child is one of those children
+   * that can be selected.
+   */
+  STATE_SELECTABLE,
+  /*
+   * Indicates this object is the child of an object that allows its
+   * children to be selected and that this child is one of those children
+   * that has been selected.
+   */
+  STATE_SELECTED,
+  /* Indicates this object is sensitive */
+  STATE_SENSITIVE,
+  /*
+   * Indicates this object, the object's parent, the object's parent's
+   * parent, and so on, are all visible
+   */
+  STATE_SHOWING,
+  /* Indicates this (text) object can contain only a single line of text */
+  STATE_SINGLE_LINE,
+  /* Indicates this object is transient */
+  STATE_TRANSIENT,
+  /* Indicates the orientation of this object is vertical */
+  STATE_VERTICAL,
+  /* Indicates this object is visible */
+  STATE_VISIBLE,
+  STATE_LAST_DEFINED
+} ACCESSIBLE_STATE;
+
+#endif
index c10ccbc..18fee78 100644 (file)
@@ -5,6 +5,7 @@
 #include "spi-impl.h"
 
 /* definitions for ACCESSIBLE_STATE */
+#include "spi-roletypes.h"
 #include "spi-statetypes.h"
 
 /*
@@ -58,7 +59,10 @@ typedef struct _AccessibleEvent {
   char *detail2;
 } AccessibleEvent;
 
-
+typedef enum _AccessibleCoordType {
+  COORD_TYPE_WINDOW,
+  COORD_TYPE_SCREEN
+} AccessibleCoordType;
 
 /*
  *
@@ -67,6 +71,7 @@ typedef struct _AccessibleEvent {
  */
 
 typedef void (*AccessibleEventListener) (AccessibleEvent *e);
+typedef void (*KeystrokeListener) (AccessibleEvent *e);
 
 
 
diff --git a/cspi/spi_main.c b/cspi/spi_main.c
new file mode 100644 (file)
index 0000000..09d9be9
--- /dev/null
@@ -0,0 +1,280 @@
+/* #include <libbonobo.h> */
+#include <stdio.h>
+#include "spi.h"
+
+static CORBA_Environment ev;
+static Accessibility_Registry registry;
+
+Accessible *
+Obj_Add (Accessible object)
+{
+  /* TODO: keep list of live object refs */
+  Accessible *oref = g_malloc (sizeof (Accessible));
+  *oref = object;
+  return oref;
+}
+
+/*
+ *
+ * Basic SPI initialization and event loop function prototypes
+ *
+ */
+
+int
+SPI_init (void)
+{
+  int argc = 0;
+  CORBA_exception_init(&ev);
+  CORBA_Object oclient;
+  char *obj_id;
+
+  if (!bonobo_init (&argc, NULL))
+    {
+      g_error ("Could not initialize Bonobo");
+    }
+
+  obj_id = "OAFIID:Accessibility_Registry:proto0.1";
+
+  oclient = bonobo_activation_activate_from_id (obj_id, 0, NULL, &ev);
+  if (ev._major != CORBA_NO_EXCEPTION) {
+    fprintf (stderr,
+            ("AT-SPI error: during registry activation: %s\n"),
+            CORBA_exception_id(&ev));
+    CORBA_exception_free(&ev);
+    exit(-1);
+  }
+
+  if (CORBA_Object_is_nil (oclient, &ev))
+    {
+      g_error ("Could not locate registry");
+      exit(-1);
+    }
+
+  registry = (Accessibility_Registry) oclient;
+
+  bonobo_activate ();
+
+  return 0;
+}
+
+void
+SPI_event_main (boolean isGNOMEApp)
+{
+  if (isGNOMEApp) bonobo_main();
+  else CORBA_ORB_run (bonobo_orb(), &ev);
+}
+
+/* Not Yet Implemented */
+boolean
+SPI_eventIsReady ()
+{
+  return FALSE;
+}
+
+/* Not Yet Implemented */
+AccessibleEvent *
+SPI_nextEvent (boolean waitForEvent)
+{
+  return NULL;
+}
+
+void
+SPI_exit (void)
+{
+  exit(0);
+}
+
+/*
+ *
+ * Global functions serviced by the registry
+ *
+ */
+
+boolean
+RegisterGlobalEventListener (AccessibleEventListener *listener,
+                             char *eventType)
+{
+  Accessibility_Registry_registerGlobalEventListener (
+                         registry,
+                         *listener,
+                         eventType,
+                         &ev);
+
+  if (ev._major != CORBA_NO_EXCEPTION)
+    {
+    return FALSE;
+    }
+  else
+    {
+      return TRUE;
+    }
+}
+
+int
+GetDesktopCount ()
+{
+  return Accessibility_Registry_getDesktopCount (registry, &ev);
+}
+
+Accessible
+*getDesktop (int n)
+{
+  return Obj_Add (Accessibility_Registry_getDesktop (registry, n, &ev));
+}
+
+int
+getDesktopList (Accessible **list)
+{
+  *list = NULL;
+  return 0;
+}
+
+/* Not Yet Implemented */
+void
+registerKeystrokeListener (KeystrokeListener *listener)
+{
+  ;
+}
+
+/* Not Yet Implemented */
+void
+generateKeyEvent (long keyCode, long meta)
+{
+  ;
+}
+
+/* Not Yet Implemented */
+void
+generateMouseEvent (long x, long y, char *name)
+{
+  ;
+}
+
+/*
+ *
+ * Accessible function prototypes
+ *
+ */
+
+int
+Accessible_ref (Accessible *obj)
+{
+  return Accessibility_Accessible_ref (*obj, &ev);
+}
+
+
+int
+Accessible_unref (Accessible *obj)
+{
+  return Accessibility_Accessible_unref (*obj, &ev);
+}
+
+char *
+Accessible_getName (Accessible *obj)
+{
+  return Accessibility_Accessible__get_name (*obj, &ev);
+}
+
+char *
+Accessible_getDescription (Accessible *obj)
+{
+  return Accessibility_Accessible__get_description (*obj, &ev);
+}
+
+Accessible *
+Accessible_getParent (Accessible *obj)
+{
+  return Obj_Add (Accessibility_Accessible__get_parent (*obj, &ev));
+}
+
+long
+Accessible_getChildCount (Accessible *obj)
+{
+  return Accessibility_Accessible_getChildCount (*obj, &ev);
+}
+
+Accessible *
+Accessible_getChildAtIndex (Accessible *obj,
+                            long childIndex)
+{
+  return Obj_Add (Accessibility_Accessible_getChildAtIndex (*obj, childIndex, &ev));
+}
+
+long
+Accessible_getIndexInParent (Accessible *obj)
+{
+  return Accessibility_Accessible_getIndexInParent (*obj, &ev);
+}
+
+/* Not Yet Implemented */
+AccessibleRelation **
+Accessible_getRelationSet (Accessible *obj)
+{
+  return NULL;
+}
+
+/* Not Yet Implemented */
+char *
+Accessible_getRole (Accessible *obj)
+{
+  return "";
+}
+
+/* Not Yet Implemented */
+AccessibleStateSet *
+Accessible_getStateSet (Accessible *obj)
+{
+  return NULL;
+}
+
+
+/*
+ *
+ * AccessibleApplication function prototypes
+ *
+ */
+
+int
+AccessibleApplication_ref (AccessibleApplication *obj)
+{
+  return Accessibility_Application_ref (*obj, &ev);
+}
+
+int
+AccessibleApplication_unref (AccessibleApplication *obj)
+{
+  return Accessibility_Application_unref (*obj, &ev);
+}
+
+char *
+AccessibleApplication_getToolkitName (AccessibleApplication *obj)
+{
+  return Accessibility_Application__getToolkitName (*obj, &ev);
+}
+
+char *
+AccessibleApplication_getVersion (AccessibleApplication *obj)
+{
+  return Accessibility_Application__getVersion (*obj, &ev);
+}
+
+long
+AccessibleApplication_getID (AccessibleApplication *obj)
+{
+  return Accessibility_Application__getID (*obj, &ev);
+}
+
+/* Not Yet Implemented */
+boolean
+AccessibleApplication_pause (AccessibleApplication *obj)
+{
+  return FALSE;
+}
+
+/* Not Yet Implemented */
+boolean
+AccessibleApplication_resume (AccessibleApplication *obj)
+{
+  return FALSE;
+}
+
index fec72e7..9dd14f8 100644 (file)
@@ -140,6 +140,20 @@ impl_accessibility_accessible_get_parent (PortableServer_Servant servant,
 }
 
 /*
+ * CORBA Accessibility::Accessible::get_IndexInParent method implementation
+ */
+static CORBA_long
+impl_accessibility_accessible_get_index_in_parent (PortableServer_Servant servant,
+                                                   CORBA_Environment     *ev)
+{
+  CORBA_long retval;
+  Accessible *accessible = ACCESSIBLE (bonobo_object_from_servant (servant));
+  retval = (CORBA_long) atk_object_get_index_in_parent (accessible->atko);
+  printf ("Accessible get_index_in_parent called\n");
+  return retval;
+}
+
+/*
  * CORBA Accessibility::Accessible::get_childCount method implementation
  */
 static CORBA_long
@@ -186,8 +200,8 @@ accessible_class_init (AccessibleClass *klass)
         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->getIndexInParent = impl_accessibility_accessible_get_index_in_parent; */
         /* epv->getRelationSet = impl_accessibility_accessible_get_relation_set;      */
         /* epv->getState = impl_accessibility_accessible_get_state;                   */
         /* epv->getRole = impl_accessibility_accessible_get_role;                     */