[g-a-devel]patch for role conversions



THis patch fixes the internal role enum conversions.  It should fix some
outstanding bugs in the handling of roles in at-spi.

-Bill
? at-spi-1.0.pc
? atspi-101201-1.diff
? atspi-111101-1.diff
? atspi-111201-1.diff
? atspi-121201-2.diff
? atspi-121201-1.diff
? atspi-121201-3.diff
? atspi-121201-4.diff
? atspi-121201-5.diff
? docs/reference/cspi/tmpl/at-spi-cspi-unused.sgml
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/at-spi/ChangeLog,v
retrieving revision 1.121
diff -u -r1.121 ChangeLog
--- ChangeLog	2001/12/12 18:32:32	1.121
+++ ChangeLog	2001/12/12 21:39:48
@@ -1,5 +1,14 @@
 2001-12-12  Bill Haneman <bill haneman sun com>
 
+	* libspi/accessible.c:
+        Convert all AtkRole enumerations to Accessibility_Role enums when
+	getting a role from an AtkObject.
+	
+	* cspi/spi_accessible.c:
+	Complete the conversion of Accessibility_Role enums at runtime to
+	AccessibleRole (SPI_ROLE_*) roles in Accessible_getRole, so that
+	role enums correctly match those given in spi-roletypes.h.
+
 	* cspi/spi.h:
 	* cspi/spi_registry.c:
 	* cspi/spi_event.c:
Index: cspi/spi-roletypes.h
===================================================================
RCS file: /cvs/gnome/at-spi/cspi/spi-roletypes.h,v
retrieving revision 1.9
diff -u -r1.9 spi-roletypes.h
--- cspi/spi-roletypes.h	2001/12/12 00:28:48	1.9
+++ cspi/spi-roletypes.h	2001/12/12 21:39:48
@@ -90,23 +90,31 @@
 typedef enum
 {
   SPI_ROLE_INVALID,
+  SPI_ROLE_ACCEL_LABEL,
   SPI_ROLE_ALERT,
+  SPI_ROLE_ANIMATION,
+  SPI_ROLE_ARROW,
+  SPI_ROLE_CALENDAR,
   SPI_ROLE_CANVAS,
   SPI_ROLE_CHECK_BOX,
   SPI_ROLE_COLOR_CHOOSER,
   SPI_ROLE_COLUMN_HEADER,
   SPI_ROLE_COMBO_BOX,
-  SPI_ROLE_SPI_DESKTOP_ICON,
-  SPI_ROLE_SPI_DESKTOP_FRAME,
+  SPI_ROLE_DATE_EDITOR,
+  SPI_ROLE_DESKTOP_ICON,
+  SPI_ROLE_DESKTOP_FRAME,
+  SPI_ROLE_DIAL,
   SPI_ROLE_DIALOG,
   SPI_ROLE_DIRECTORY_PANE,
   SPI_ROLE_FILE_CHOOSER,
   SPI_ROLE_FILLER,
   SPI_ROLE_FOCUS_TRAVERSABLE,
+  SPI_ROLE_FONT_CHOOSER,
   SPI_ROLE_FRAME,
   SPI_ROLE_GLASS_PANE,
   SPI_ROLE_HTML_CONTAINER,
   SPI_ROLE_ICON,
+  SPI_ROLE_IMAGE,
   SPI_ROLE_INTERNAL_FRAME,
   SPI_ROLE_LABEL,
   SPI_ROLE_LAYERED_PANE,
@@ -124,25 +132,31 @@
   SPI_ROLE_PROGRESS_BAR,
   SPI_ROLE_PUSH_BUTTON,
   SPI_ROLE_RADIO_BUTTON,
+  SPI_ROLE_RADIO_MENU_ITEM,
   SPI_ROLE_ROOT_PANE,
   SPI_ROLE_ROW_HEADER,
   SPI_ROLE_SCROLL_BAR,
   SPI_ROLE_SCROLL_PANE,
   SPI_ROLE_SEPARATOR,
   SPI_ROLE_SLIDER,
+  SPI_ROLE_SPIN_BUTTON,
   SPI_ROLE_SPLIT_PANE,
+  SPI_ROLE_STATUS_BAR,
   SPI_ROLE_TABLE,
   SPI_ROLE_TABLE_CELL,
   SPI_ROLE_TABLE_COLUMN_HEADER,
   SPI_ROLE_TABLE_ROW_HEADER,
+  SPI_ROLE_TEAROFF_MENU_ITEM,
   SPI_ROLE_TEXT,
   SPI_ROLE_TOGGLE_BUTTON,
   SPI_ROLE_TOOL_BAR,
   SPI_ROLE_TOOL_TIP,
   SPI_ROLE_TREE,
+  SPI_ROLE_TREE_TABLE,
   SPI_ROLE_UNKNOWN,
   SPI_ROLE_VIEWPORT,
   SPI_ROLE_WINDOW,
+  SPI_ROLE_EXTENDED,
   SPI_ROLE_LAST_DEFINED
 } AccessibleRole;
 
Index: cspi/spi_accessible.c
===================================================================
RCS file: /cvs/gnome/at-spi/cspi/spi_accessible.c,v
retrieving revision 1.26
diff -u -r1.26 spi_accessible.c
--- cspi/spi_accessible.c	2001/12/12 16:46:17	1.26
+++ cspi/spi_accessible.c	2001/12/12 21:39:49
@@ -17,6 +17,7 @@
   "date editor",
   "desktop icon",
   "desktop frame",
+  "dial",
   "dialog",
   "directory pane",
   "file chooser",
@@ -65,6 +66,7 @@
   "toolbar",
   "tooltip",
   "tree",
+  "tree-table",
   "<unknown>",
   "viewport",
   "window",
@@ -73,10 +75,104 @@
 
 #define MAX_ROLES (sizeof (role_names) / sizeof (char *))
 
+static SPIBoolean
+cspi_init_role_table (AccessibleRole *role_table)
+{
+  int i;
+  for (i = 0; i < Accessibility_ROLE_LAST_DEFINED; ++i)
+    {
+      role_table [i] = SPI_ROLE_UNKNOWN;
+    }
+  role_table [Accessibility_ROLE_INVALID] = SPI_ROLE_INVALID;
+  role_table [Accessibility_ROLE_ACCELERATOR_LABEL] = SPI_ROLE_ACCEL_LABEL;
+  role_table [Accessibility_ROLE_ALERT] = SPI_ROLE_ALERT;
+  role_table [Accessibility_ROLE_ANIMATION] = SPI_ROLE_ANIMATION;
+  role_table [Accessibility_ROLE_ARROW] = SPI_ROLE_ARROW;
+  role_table [Accessibility_ROLE_CALENDAR] = SPI_ROLE_CALENDAR;
+  role_table [Accessibility_ROLE_CANVAS] = SPI_ROLE_CANVAS;
+  role_table [Accessibility_ROLE_CHECK_BOX] = SPI_ROLE_CHECK_BOX;
+  role_table [Accessibility_ROLE_COLOR_CHOOSER] = SPI_ROLE_COLOR_CHOOSER;
+  role_table [Accessibility_ROLE_COLUMN_HEADER] = SPI_ROLE_COLUMN_HEADER;
+  role_table [Accessibility_ROLE_COMBO_BOX] = SPI_ROLE_COMBO_BOX;
+  role_table [Accessibility_ROLE_DATE_EDITOR] = SPI_ROLE_DATE_EDITOR;
+  role_table [Accessibility_ROLE_DESKTOP_ICON] = SPI_ROLE_DESKTOP_ICON;
+  role_table [Accessibility_ROLE_DESKTOP_FRAME] = SPI_ROLE_DESKTOP_FRAME;
+  role_table [Accessibility_ROLE_DIAL] = SPI_ROLE_DIAL;
+  role_table [Accessibility_ROLE_DIALOG] = SPI_ROLE_DIALOG;
+  role_table [Accessibility_ROLE_DIRECTORY_PANE] = SPI_ROLE_DIRECTORY_PANE;
+  role_table [Accessibility_ROLE_FILE_CHOOSER] = SPI_ROLE_FILE_CHOOSER;
+  role_table [Accessibility_ROLE_FILLER] = SPI_ROLE_FILLER;
+  role_table [Accessibility_ROLE_FONT_CHOOSER] = SPI_ROLE_FONT_CHOOSER;
+  role_table [Accessibility_ROLE_FRAME] = SPI_ROLE_FRAME;
+  role_table [Accessibility_ROLE_GLASS_PANE] = SPI_ROLE_GLASS_PANE;
+  role_table [Accessibility_ROLE_HTML_CONTAINER] = SPI_ROLE_HTML_CONTAINER;
+  role_table [Accessibility_ROLE_ICON] = SPI_ROLE_ICON;
+  role_table [Accessibility_ROLE_IMAGE] = SPI_ROLE_IMAGE;
+  role_table [Accessibility_ROLE_INTERNAL_FRAME] = SPI_ROLE_INTERNAL_FRAME;
+  role_table [Accessibility_ROLE_LABEL] = SPI_ROLE_LABEL;
+  role_table [Accessibility_ROLE_LAYERED_PANE] = SPI_ROLE_LAYERED_PANE;
+  role_table [Accessibility_ROLE_LIST] = SPI_ROLE_LIST;
+  role_table [Accessibility_ROLE_LIST_ITEM] = SPI_ROLE_LIST_ITEM;
+  role_table [Accessibility_ROLE_MENU] = SPI_ROLE_MENU;
+  role_table [Accessibility_ROLE_MENU_BAR] = SPI_ROLE_MENU_BAR;
+  role_table [Accessibility_ROLE_MENU_ITEM] = SPI_ROLE_MENU_ITEM;
+  role_table [Accessibility_ROLE_OPTION_PANE] = SPI_ROLE_OPTION_PANE;
+  role_table [Accessibility_ROLE_PAGE_TAB] = SPI_ROLE_PAGE_TAB;
+  role_table [Accessibility_ROLE_PAGE_TAB_LIST] = SPI_ROLE_PAGE_TAB_LIST;
+  role_table [Accessibility_ROLE_PANEL] = SPI_ROLE_PANEL;
+  role_table [Accessibility_ROLE_PASSWORD_TEXT] = SPI_ROLE_PASSWORD_TEXT;
+  role_table [Accessibility_ROLE_POPUP_MENU] = SPI_ROLE_POPUP_MENU;
+  role_table [Accessibility_ROLE_PROGRESS_BAR] = SPI_ROLE_PROGRESS_BAR;
+  role_table [Accessibility_ROLE_PUSH_BUTTON] = SPI_ROLE_PUSH_BUTTON;
+  role_table [Accessibility_ROLE_RADIO_BUTTON] = SPI_ROLE_RADIO_BUTTON;
+  role_table [Accessibility_ROLE_RADIO_MENU_ITEM] = SPI_ROLE_RADIO_MENU_ITEM;
+  role_table [Accessibility_ROLE_ROOT_PANE] = SPI_ROLE_ROOT_PANE;
+  role_table [Accessibility_ROLE_ROW_HEADER] = SPI_ROLE_ROW_HEADER;
+  role_table [Accessibility_ROLE_SCROLL_BAR] = SPI_ROLE_SCROLL_BAR;
+  role_table [Accessibility_ROLE_SCROLL_PANE] = SPI_ROLE_SCROLL_PANE;
+  role_table [Accessibility_ROLE_SEPARATOR] = SPI_ROLE_SEPARATOR;
+  role_table [Accessibility_ROLE_SLIDER] = SPI_ROLE_SLIDER;
+  role_table [Accessibility_ROLE_SPIN_BUTTON] = SPI_ROLE_SPIN_BUTTON;
+  role_table [Accessibility_ROLE_SPLIT_PANE] = SPI_ROLE_SPLIT_PANE;
+  role_table [Accessibility_ROLE_STATUS_BAR] = SPI_ROLE_STATUS_BAR;
+  role_table [Accessibility_ROLE_TABLE] = SPI_ROLE_TABLE;
+  role_table [Accessibility_ROLE_TABLE_CELL] = SPI_ROLE_TABLE_CELL;
+  role_table [Accessibility_ROLE_TEAROFF_MENU_ITEM] = SPI_ROLE_TEAROFF_MENU_ITEM;
+  role_table [Accessibility_ROLE_TEXT] = SPI_ROLE_TEXT;
+  role_table [Accessibility_ROLE_TOGGLE_BUTTON] = SPI_ROLE_TOGGLE_BUTTON;
+  role_table [Accessibility_ROLE_TOOL_BAR] = SPI_ROLE_TOOL_BAR;
+  role_table [Accessibility_ROLE_TOOL_TIP] = SPI_ROLE_TOOL_TIP;
+  role_table [Accessibility_ROLE_TREE] = SPI_ROLE_TREE;
+  role_table [Accessibility_ROLE_TREE_TABLE] = SPI_ROLE_TREE_TABLE;
+  role_table [Accessibility_ROLE_UNKNOWN] = SPI_ROLE_UNKNOWN;
+  role_table [Accessibility_ROLE_VIEWPORT] = SPI_ROLE_VIEWPORT;
+  role_table [Accessibility_ROLE_WINDOW] = SPI_ROLE_WINDOW;
+  role_table [Accessibility_ROLE_EXTENDED] = SPI_ROLE_EXTENDED;
+  role_table [Accessibility_ROLE_LAST_DEFINED] = SPI_ROLE_EXTENDED;
+
+  return TRUE;
+}
+
 static AccessibleRole
 cspi_role_from_spi_role (Accessibility_Role role)
 {
-  return role; /* FIXME: need to compare, equivalence not guaranteed */
+  /* array is sized according to IDL roles because IDL roles are the index */	
+  static AccessibleRole cspi_role_table [Accessibility_ROLE_LAST_DEFINED];
+  static SPIBoolean is_initialized = FALSE;
+  AccessibleRole cspi_role;
+  if (!is_initialized)
+    {
+      is_initialized = cspi_init_role_table (cspi_role_table);	    
+    }
+  if (role >= 0 && role < Accessibility_ROLE_LAST_DEFINED)
+    {
+      cspi_role = cspi_role_table [role];	    
+    }
+  else
+    {
+      cspi_role = SPI_ROLE_EXTENDED;
+    }
+  return cspi_role; 
 }
 
 /**
@@ -84,7 +180,7 @@
  * @role: an #AccessibleRole object to query.
  *
  * Get a localizeable string that indicates the name of an #AccessibleRole.
- * Currently broken, do not use.
+ * <em>DEPRECATED.</em>
  *
  * Returns: a localizable string name for an #AccessibleRole enumerated type.
  **/
Index: docs/reference/cspi/tmpl/spi_accessible.sgml
===================================================================
RCS file: /cvs/gnome/at-spi/docs/reference/cspi/tmpl/spi_accessible.sgml,v
retrieving revision 1.3
diff -u -r1.3 spi_accessible.sgml
--- docs/reference/cspi/tmpl/spi_accessible.sgml	2001/12/12 18:23:01	1.3
+++ docs/reference/cspi/tmpl/spi_accessible.sgml	2001/12/12 21:39:50
@@ -321,23 +321,31 @@
 </para>
 
 @SPI_ROLE_INVALID: 
+ SPI_ROLE_ACCEL_LABEL: 
 @SPI_ROLE_ALERT: 
+ SPI_ROLE_ANIMATION: 
+ SPI_ROLE_ARROW: 
+ SPI_ROLE_CALENDAR: 
 @SPI_ROLE_CANVAS: 
 @SPI_ROLE_CHECK_BOX: 
 @SPI_ROLE_COLOR_CHOOSER: 
 @SPI_ROLE_COLUMN_HEADER: 
 @SPI_ROLE_COMBO_BOX: 
- SPI_ROLE_SPI_DESKTOP_ICON: 
- SPI_ROLE_SPI_DESKTOP_FRAME: 
+ SPI_ROLE_DATE_EDITOR: 
+ SPI_ROLE_DESKTOP_ICON: 
+ SPI_ROLE_DESKTOP_FRAME: 
+ SPI_ROLE_DIAL: 
 @SPI_ROLE_DIALOG: 
 @SPI_ROLE_DIRECTORY_PANE: 
 @SPI_ROLE_FILE_CHOOSER: 
 @SPI_ROLE_FILLER: 
 @SPI_ROLE_FOCUS_TRAVERSABLE: 
+ SPI_ROLE_FONT_CHOOSER: 
 @SPI_ROLE_FRAME: 
 @SPI_ROLE_GLASS_PANE: 
 @SPI_ROLE_HTML_CONTAINER: 
 @SPI_ROLE_ICON: 
+ SPI_ROLE_IMAGE: 
 @SPI_ROLE_INTERNAL_FRAME: 
 @SPI_ROLE_LABEL: 
 @SPI_ROLE_LAYERED_PANE: 
@@ -355,25 +363,31 @@
 @SPI_ROLE_PROGRESS_BAR: 
 @SPI_ROLE_PUSH_BUTTON: 
 @SPI_ROLE_RADIO_BUTTON: 
+ SPI_ROLE_RADIO_MENU_ITEM: 
 @SPI_ROLE_ROOT_PANE: 
 @SPI_ROLE_ROW_HEADER: 
 @SPI_ROLE_SCROLL_BAR: 
 @SPI_ROLE_SCROLL_PANE: 
 @SPI_ROLE_SEPARATOR: 
 @SPI_ROLE_SLIDER: 
+ SPI_ROLE_SPIN_BUTTON: 
 @SPI_ROLE_SPLIT_PANE: 
+ SPI_ROLE_STATUS_BAR: 
 @SPI_ROLE_TABLE: 
 @SPI_ROLE_TABLE_CELL: 
 @SPI_ROLE_TABLE_COLUMN_HEADER: 
 @SPI_ROLE_TABLE_ROW_HEADER: 
+ SPI_ROLE_TEAROFF_MENU_ITEM: 
 @SPI_ROLE_TEXT: 
 @SPI_ROLE_TOGGLE_BUTTON: 
 @SPI_ROLE_TOOL_BAR: 
 @SPI_ROLE_TOOL_TIP: 
 @SPI_ROLE_TREE: 
+ SPI_ROLE_TREE_TABLE: 
 @SPI_ROLE_UNKNOWN: 
 @SPI_ROLE_VIEWPORT: 
 @SPI_ROLE_WINDOW: 
+ SPI_ROLE_EXTENDED: 
 @SPI_ROLE_LAST_DEFINED: 
 
 <!-- ##### FUNCTION AccessibleRole_getName ##### -->
Index: idl/Accessibility_Role.idl
===================================================================
RCS file: /cvs/gnome/at-spi/idl/Accessibility_Role.idl,v
retrieving revision 1.5
diff -u -r1.5 Accessibility_Role.idl
--- idl/Accessibility_Role.idl	2001/12/12 16:46:17	1.5
+++ idl/Accessibility_Role.idl	2001/12/12 21:39:50
@@ -44,6 +44,8 @@
    * indicator for the current state.
    */
   ROLE_CHECK_BOX,
+  /* A menu item that behaves like a check box (see ROLE_CHECK_BOX) */
+  ROLE_CHECK_MENU_ITEM,
   /* A specialized dialog that lets the user choose a color. */
   ROLE_COLOR_CHOOSER,
   /* The header for a column of data */
@@ -59,6 +61,11 @@
    * internal frames.
    */
   ROLE_DESKTOP_FRAME,
+  /* 
+   * An object that allows a value to be changed via rotating a visual element,
+   * or which displays a value via such a rotating element. 
+   */
+  ROLE_DIAL,
   /* A top level window with title bar and a border */
   ROLE_DIALOG,
   /*
@@ -199,6 +206,8 @@
   ROLE_TABLE_ROW_HEADER,
   /* Object allows menu to be removed from menubar and shown in its own window. */
   ROLE_TEAROFF_MENU_ITEM,
+  /* An object that emulates a terminal */
+  ROLE_TERMINAL,
   /* An object that presents text to the user */
   ROLE_TEXT,
   /*
@@ -216,6 +225,8 @@
   ROLE_TOOL_TIP,
   /* An object used to repsent hierarchical information to the user. */
   ROLE_TREE,
+  /* An object that presents both tabular and hierarchical info to the user */
+  ROLE_TREE_TABLE,
   /*
    * The object contains some Accessible information, but its role is
    * not known.
Index: libspi/accessible.c
===================================================================
RCS file: /cvs/gnome/at-spi/libspi/accessible.c,v
retrieving revision 1.29
diff -u -r1.29 accessible.c
--- libspi/accessible.c	2001/12/12 00:28:52	1.29
+++ libspi/accessible.c	2001/12/12 21:39:51
@@ -31,89 +31,114 @@
 /* Our parent Gtk object type  */
 #define PARENT_TYPE SPI_TYPE_BASE
 
+static gboolean spi_init_role_lookup_table (Accessibility_Role *role_table);
+static Accessibility_Role spi_role_from_atk_role (AtkRole role);
+
+static gboolean
+spi_init_role_lookup_table (Accessibility_Role *role_table)
+{
+  int i;
+  /* if it's not in the list below, dunno what it is */
+  for (i = 0; i < ATK_ROLE_LAST_DEFINED; ++i)
+    {
+      role_table [i] = Accessibility_ROLE_UNKNOWN;
+    }
+  
+  role_table [ATK_ROLE_INVALID] =          Accessibility_ROLE_INVALID;
+  role_table [ATK_ROLE_ACCEL_LABEL] =      Accessibility_ROLE_ACCELERATOR_LABEL;
+  role_table [ATK_ROLE_ALERT] =            Accessibility_ROLE_ALERT;
+  role_table [ATK_ROLE_ANIMATION] =        Accessibility_ROLE_ANIMATION; 
+  role_table [ATK_ROLE_ARROW] =            Accessibility_ROLE_ARROW; 
+  role_table [ATK_ROLE_CALENDAR] =         Accessibility_ROLE_CALENDAR; 
+  role_table [ATK_ROLE_CANVAS] =           Accessibility_ROLE_CANVAS;
+  role_table [ATK_ROLE_CHECK_BOX] =        Accessibility_ROLE_CHECK_BOX;
+  role_table [ATK_ROLE_CHECK_MENU_ITEM] =  Accessibility_ROLE_CHECK_MENU_ITEM;
+  role_table [ATK_ROLE_COLOR_CHOOSER] =    Accessibility_ROLE_COLOR_CHOOSER;
+  role_table [ATK_ROLE_COLUMN_HEADER] =    Accessibility_ROLE_COLUMN_HEADER;
+  role_table [ATK_ROLE_COMBO_BOX] =        Accessibility_ROLE_COMBO_BOX;
+  role_table [ATK_ROLE_DATE_EDITOR] =      Accessibility_ROLE_DATE_EDITOR;
+  role_table [ATK_ROLE_DESKTOP_ICON] =     Accessibility_ROLE_DESKTOP_ICON;
+  role_table [ATK_ROLE_DESKTOP_FRAME] =    Accessibility_ROLE_DESKTOP_FRAME;
+  role_table [ATK_ROLE_DIAL] =             Accessibility_ROLE_DIAL;
+  role_table [ATK_ROLE_DIALOG] =           Accessibility_ROLE_DIALOG;
+  role_table [ATK_ROLE_DIRECTORY_PANE] =   Accessibility_ROLE_DIRECTORY_PANE;
+  role_table [ATK_ROLE_FILE_CHOOSER] =     Accessibility_ROLE_FILE_CHOOSER;
+  role_table [ATK_ROLE_FILLER] =           Accessibility_ROLE_FILLER;
+  role_table [ATK_ROLE_FONT_CHOOSER] =     Accessibility_ROLE_FONT_CHOOSER;
+  role_table [ATK_ROLE_FRAME] =            Accessibility_ROLE_FRAME;
+  role_table [ATK_ROLE_GLASS_PANE] =       Accessibility_ROLE_GLASS_PANE;
+  role_table [ATK_ROLE_HTML_CONTAINER] =   Accessibility_ROLE_HTML_CONTAINER;
+  role_table [ATK_ROLE_ICON] =             Accessibility_ROLE_ICON;
+  role_table [ATK_ROLE_IMAGE] =            Accessibility_ROLE_IMAGE; 
+  role_table [ATK_ROLE_INTERNAL_FRAME] =   Accessibility_ROLE_INTERNAL_FRAME; 
+  role_table [ATK_ROLE_LABEL] =            Accessibility_ROLE_LABEL;
+  role_table [ATK_ROLE_LAYERED_PANE] =     Accessibility_ROLE_LAYERED_PANE;
+  role_table [ATK_ROLE_LIST] =             Accessibility_ROLE_LIST;
+  role_table [ATK_ROLE_LIST_ITEM] =        Accessibility_ROLE_LIST_ITEM;
+  role_table [ATK_ROLE_MENU] =             Accessibility_ROLE_MENU;
+  role_table [ATK_ROLE_MENU_BAR] =         Accessibility_ROLE_MENU_BAR;
+  role_table [ATK_ROLE_MENU_ITEM] =        Accessibility_ROLE_MENU_ITEM;
+  role_table [ATK_ROLE_OPTION_PANE] =      Accessibility_ROLE_OPTION_PANE;
+  role_table [ATK_ROLE_PAGE_TAB] =         Accessibility_ROLE_PAGE_TAB;
+  role_table [ATK_ROLE_PAGE_TAB_LIST] =    Accessibility_ROLE_PAGE_TAB_LIST; 
+  role_table [ATK_ROLE_PANEL] =            Accessibility_ROLE_PANEL;
+  role_table [ATK_ROLE_PASSWORD_TEXT] =    Accessibility_ROLE_PASSWORD_TEXT;
+  role_table [ATK_ROLE_POPUP_MENU] =       Accessibility_ROLE_POPUP_MENU;
+  role_table [ATK_ROLE_PROGRESS_BAR] =     Accessibility_ROLE_PROGRESS_BAR;
+  role_table [ATK_ROLE_PUSH_BUTTON] =      Accessibility_ROLE_PUSH_BUTTON;
+  role_table [ATK_ROLE_RADIO_BUTTON] =     Accessibility_ROLE_RADIO_BUTTON;
+  role_table [ATK_ROLE_RADIO_MENU_ITEM] =  Accessibility_ROLE_RADIO_MENU_ITEM;
+  role_table [ATK_ROLE_ROOT_PANE] =        Accessibility_ROLE_ROOT_PANE;
+  role_table [ATK_ROLE_ROW_HEADER] =       Accessibility_ROLE_ROW_HEADER;
+  role_table [ATK_ROLE_SCROLL_BAR] =       Accessibility_ROLE_SCROLL_BAR;
+  role_table [ATK_ROLE_SCROLL_PANE] =      Accessibility_ROLE_SCROLL_PANE;
+  role_table [ATK_ROLE_SEPARATOR] =        Accessibility_ROLE_SEPARATOR;
+  role_table [ATK_ROLE_SLIDER] =           Accessibility_ROLE_SLIDER;
+  role_table [ATK_ROLE_SPLIT_PANE] =       Accessibility_ROLE_SPLIT_PANE;
+  role_table [ATK_ROLE_SPIN_BUTTON] =      Accessibility_ROLE_SPIN_BUTTON;
+  role_table [ATK_ROLE_STATUSBAR] =        Accessibility_ROLE_STATUS_BAR;
+  role_table [ATK_ROLE_TABLE] =            Accessibility_ROLE_TABLE;
+  role_table [ATK_ROLE_TABLE_CELL] =       Accessibility_ROLE_TABLE_CELL;
+  role_table [ATK_ROLE_TABLE_COLUMN_HEADER] =
+	                                   Accessibility_ROLE_COLUMN_HEADER;
+  role_table [ATK_ROLE_TABLE_ROW_HEADER] = Accessibility_ROLE_ROW_HEADER;
+  role_table [ATK_ROLE_TEAR_OFF_MENU_ITEM] =
+	                                   Accessibility_ROLE_TEAROFF_MENU_ITEM;
+  role_table [ATK_ROLE_TERMINAL] =         Accessibility_ROLE_TERMINAL;
+  role_table [ATK_ROLE_TEXT] =             Accessibility_ROLE_TEXT;
+  role_table [ATK_ROLE_TOGGLE_BUTTON] =    Accessibility_ROLE_TOGGLE_BUTTON;
+  role_table [ATK_ROLE_TOOL_BAR] =         Accessibility_ROLE_TOOL_BAR;
+  role_table [ATK_ROLE_TOOL_TIP] =         Accessibility_ROLE_TOOL_TIP;
+  role_table [ATK_ROLE_TREE] =             Accessibility_ROLE_TREE;
+  role_table [ATK_ROLE_TREE_TABLE] =       Accessibility_ROLE_TREE_TABLE;
+  role_table [ATK_ROLE_UNKNOWN] =          Accessibility_ROLE_UNKNOWN;
+  role_table [ATK_ROLE_VIEWPORT] =         Accessibility_ROLE_VIEWPORT;
+  role_table [ATK_ROLE_WINDOW] =           Accessibility_ROLE_WINDOW;
+  role_table [ATK_ROLE_LAST_DEFINED] =     Accessibility_ROLE_EXTENDED;
+  
+  return TRUE;
+}
+
 static Accessibility_Role
 spi_role_from_atk_role (AtkRole role)
 {
+  static gboolean is_initialized = FALSE;
+  static Accessibility_Role spi_role_table [ATK_ROLE_LAST_DEFINED];
   Accessibility_Role spi_role;
+
+  if (!is_initialized)
+   {
+     is_initialized = spi_init_role_lookup_table (spi_role_table);	   
+   }
 
-  /* TODO: finish and/or make efficient! */
-  switch (role)
-  {
-    case ATK_ROLE_INVALID:
-      spi_role = Accessibility_ROLE_INVALID;
-      break;
-    case ATK_ROLE_ACCEL_LABEL:
-    case ATK_ROLE_ALERT:
-    case ATK_ROLE_ANIMATION: 
-    case ATK_ROLE_ARROW: 
-    case ATK_ROLE_CALENDAR: 
-    case ATK_ROLE_CANVAS:
-    case ATK_ROLE_CHECK_BOX:
-    case ATK_ROLE_CHECK_MENU_ITEM:
-    case ATK_ROLE_COLOR_CHOOSER:
-    case ATK_ROLE_COLUMN_HEADER:
-    case ATK_ROLE_COMBO_BOX:
-    case ATK_ROLE_DATE_EDITOR:
-    case ATK_ROLE_DESKTOP_ICON:
-    case ATK_ROLE_DESKTOP_FRAME:
-    case ATK_ROLE_DIAL:
-    case ATK_ROLE_DIALOG:
-    case ATK_ROLE_DIRECTORY_PANE:
-    case ATK_ROLE_DRAWING_AREA:
-    case ATK_ROLE_FILE_CHOOSER:
-    case ATK_ROLE_FILLER:
-    case ATK_ROLE_FONT_CHOOSER:
-    case ATK_ROLE_FRAME:
-    case ATK_ROLE_GLASS_PANE: 
-    case ATK_ROLE_HTML_CONTAINER: 
-    case ATK_ROLE_ICON: 
-    case ATK_ROLE_IMAGE:
-    case ATK_ROLE_INTERNAL_FRAME:
-    case ATK_ROLE_LABEL:
-    case ATK_ROLE_LAYERED_PANE:
-    case ATK_ROLE_LIST:
-    case ATK_ROLE_LIST_ITEM:
-    case ATK_ROLE_MENU:
-    case ATK_ROLE_MENU_BAR:
-    case ATK_ROLE_MENU_ITEM:
-    case ATK_ROLE_OPTION_PANE:
-    case ATK_ROLE_PAGE_TAB:
-    case ATK_ROLE_PAGE_TAB_LIST:
-    case ATK_ROLE_PANEL:
-    case ATK_ROLE_PASSWORD_TEXT:
-    case ATK_ROLE_POPUP_MENU:
-    case ATK_ROLE_PROGRESS_BAR:
-    case ATK_ROLE_PUSH_BUTTON:
-    case ATK_ROLE_RADIO_BUTTON:
-    case ATK_ROLE_RADIO_MENU_ITEM:
-    case ATK_ROLE_ROOT_PANE:
-    case ATK_ROLE_ROW_HEADER:
-    case ATK_ROLE_SCROLL_BAR:
-    case ATK_ROLE_SCROLL_PANE:
-    case ATK_ROLE_SEPARATOR:
-    case ATK_ROLE_SLIDER:
-    case ATK_ROLE_SPLIT_PANE:
-    case ATK_ROLE_SPIN_BUTTON:
-    case ATK_ROLE_STATUSBAR:
-    case ATK_ROLE_TABLE:
-    case ATK_ROLE_TABLE_CELL:
-    case ATK_ROLE_TABLE_COLUMN_HEADER:
-    case ATK_ROLE_TABLE_ROW_HEADER:
-    case ATK_ROLE_TEAR_OFF_MENU_ITEM:
-    case ATK_ROLE_TERMINAL:
-    case ATK_ROLE_TEXT:
-    case ATK_ROLE_TOGGLE_BUTTON:
-    case ATK_ROLE_TOOL_BAR:
-    case ATK_ROLE_TOOL_TIP:
-    case ATK_ROLE_TREE:
-    case ATK_ROLE_TREE_TABLE:
-    case ATK_ROLE_UNKNOWN:
-    case ATK_ROLE_VIEWPORT:
-    case ATK_ROLE_WINDOW:
-    case ATK_ROLE_LAST_DEFINED:
-    default:
+  if (role >= 0 && role < ATK_ROLE_LAST_DEFINED)
+    {
+      spi_role = spi_role_table [role];
+    }
+  else
+    {
       spi_role = Accessibility_ROLE_EXTENDED;	    
-  }
+    }
   return spi_role;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]