[g-a-devel]patch to at-spi just submitted.



Attached.  Please note that this patch changes API for cspi:

AccessibleValue_* (all methods now use double)

Accessible_getRole
Accessible_getRoleName (new)

AccessibleRole_getName is deprecated (at least temporarily).  Please
note that fixes to Accessible_getRole, to bring the returned values into
line with the enum in spi-roletypes.h, are not complete.

-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
? docs/reference/cspi/tmpl/at-spi-cspi-unused.sgml
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/at-spi/ChangeLog,v
retrieving revision 1.116
diff -u -r1.116 ChangeLog
--- ChangeLog	2001/12/11 19:06:14	1.116
+++ ChangeLog	2001/12/12 00:25:39
@@ -1,7 +1,40 @@
-2001-12-11  Bill Haneman <bill haneman sun com>
+2001-12-12  Bill Haneman <bill haneman sun com>
 
+	* idl/Accessibility_Value.idl:
+	Revert use of union back to CORBA_double, since the double type is
+	more efficient and can contain the other types without loss of
+	precision.
+
+	* idl/Accessibility_Accessible.idl:
+	Added method Accessibility:Accessible:getRoleName, to complement
+	Accessibility:Accessible:getRole.
+
+	* cspi/spi_accessible.c:
+	* cspi/spi.h:
+	Added C binding for above, Accessible_getRoleName (), and changed
+	signature of Accessible_getRole () to return an AccessibleRole.
+
+	* cspi/spi-roletypes.h:
+	Changed AccessibleRole_getName to return a char * instead of a
+	const char *.  This method is now at least temporarily deprecated 
+	in favor of asking Accessibles for their RoleNames directly.
+
+	* libspi/value.c:
+	Revert to match Accessibility_Value.idl;
+
+	* cspi/spi_value.c:
+	* cspi/spi.h:
+	Change signature of AccessibleValue methods to use double rather
+	than float.
+
+	* cspi/spi.h:
+	* cspi/spi_accessible.c:
+	Changed Accessible_getRole to return an AccessibleRole enum rather
+	than a UTF-8 string.  The UTF-8 string can still be obtained via
+	AccessibleRole_getName ().
+	
 	* test/test-simple.c:
-	Add test_action.
+	Add test_action.  Small fixup to match API change to Accessible_getRole.
 
 	* libspi/action.c:
 	Bugfix for get_action_from_servant ().
Index: cspi/spi-roletypes.h
===================================================================
RCS file: /cvs/gnome/at-spi/cspi/spi-roletypes.h,v
retrieving revision 1.8
diff -u -r1.8 spi-roletypes.h
--- cspi/spi-roletypes.h	2001/12/11 14:55:27	1.8
+++ cspi/spi-roletypes.h	2001/12/12 00:25:39
@@ -146,7 +146,7 @@
   SPI_ROLE_LAST_DEFINED
 } AccessibleRole;
 
-const char* AccessibleRole_getName (AccessibleRole role);
+char* AccessibleRole_getName (AccessibleRole role);
 
 #ifdef  __cplusplus
 }
Index: cspi/spi.h
===================================================================
RCS file: /cvs/gnome/at-spi/cspi/spi.h,v
retrieving revision 1.38
diff -u -r1.38 spi.h
--- cspi/spi.h	2001/12/11 14:55:27	1.38
+++ cspi/spi.h	2001/12/12 00:25:40
@@ -197,7 +197,8 @@
 						  long int    childIndex);
 long                 Accessible_getIndexInParent (Accessible *obj);
 AccessibleRelation **Accessible_getRelationSet   (Accessible *obj);
-const char *         Accessible_getRole          (Accessible *obj);
+AccessibleRole       Accessible_getRole          (Accessible *obj);
+char *               Accessible_getRoleName      (Accessible *obj);
 AccessibleStateSet * Accessible_getStateSet      (Accessible *obj);
 
 /* Interface query methods */
@@ -688,11 +689,11 @@
 
 void       AccessibleValue_ref             (AccessibleValue *obj);
 void       AccessibleValue_unref           (AccessibleValue *obj);
-float      AccessibleValue_getMinimumValue (AccessibleValue *obj);
-float      AccessibleValue_getCurrentValue (AccessibleValue *obj);
-float      AccessibleValue_getMaximumValue (AccessibleValue *obj);
+double     AccessibleValue_getMinimumValue (AccessibleValue *obj);
+double     AccessibleValue_getCurrentValue (AccessibleValue *obj);
+double     AccessibleValue_getMaximumValue (AccessibleValue *obj);
 SPIBoolean AccessibleValue_setCurrentValue (AccessibleValue *obj,
-					    float            newValue);
+					    double           newValue);
 
 /* Misc methods */
 void SPI_freeString (char *s);
Index: cspi/spi_accessible.c
===================================================================
RCS file: /cvs/gnome/at-spi/cspi/spi_accessible.c,v
retrieving revision 1.24
diff -u -r1.24 spi_accessible.c
--- cspi/spi_accessible.c	2001/12/11 14:55:28	1.24
+++ cspi/spi_accessible.c	2001/12/12 00:25:41
@@ -82,24 +82,21 @@
  * @role: an #AccessibleRole object to query.
  *
  * Get a localizeable string that indicates the name of an #AccessibleRole.
+ * Currently broken, do not use.
  *
  * Returns: a localizable string name for an #AccessibleRole enumerated type.
  **/
-const char *
+char *
 AccessibleRole_getName (AccessibleRole role)
 {
   if (role < MAX_ROLES)
     {
-      return role_names [(int) role];
+      return g_strdup (role_names [(int) role]);
     }
   else
     {
-      return "";
+      return g_strdup ("");
     }
-  /*
-   * TODO: replace with implementation linked to ATK, which
-   *  now supports Role/Name mapping
-   */
 }
 
 /**
@@ -321,21 +318,48 @@
  * @obj: a pointer to the #Accessible object on which to operate.
  *
  * Get the UI role of an #Accessible object.
+ * A UTF-8 string describing this role can be obtained via Accessible_getRoleName ().
  *
- * Returns: a UTF-8 string indicating the UI role of the #Accessible object.
+ * Returns: the #AccessibleRole of the object.
  *
  **/
-const char *
+AccessibleRole
 Accessible_getRole (Accessible *obj)
 {
-  const char *retval;
+  AccessibleRole retval;
 
-  cspi_return_val_if_fail (obj != NULL, NULL);
+  cspi_return_val_if_fail (obj != NULL, SPI_ROLE_INVALID);
+
+  retval = 
+    Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ());
+
+  cspi_return_val_if_ev ("getRole", SPI_ROLE_INVALID); 
+
+  return retval;
+}
+
+/**
+ * Accessible_getRoleName:
+ * @obj: a pointer to the #Accessible object on which to operate.
+ *
+ * Get a UTF-8 string describing the role this object plays in the UI.
+ * This method will return useful values for roles that fall outside the
+ * enumeration used in Accessible_getRole ().
+ *
+ * Returns: a UTF-8 string specifying the role of this #Accessible object.
+ *
+ **/
+char *
+Accessible_getRoleName (Accessible *obj)
+{
+  char *retval;
+
+  cspi_return_val_if_fail (obj != NULL, CORBA_string_dup ("invalid"));
 
-  retval = AccessibleRole_getName (
-    Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ()));
+  retval = 
+    Accessibility_Accessible_getRoleName (CSPI_OBJREF (obj), cspi_ev ());
 
-  cspi_return_val_if_ev ("getRole", NULL); 
+  cspi_return_val_if_ev ("getRoleName", CORBA_string_dup ("invalid")); 
 
   return retval;
 }
Index: cspi/spi_value.c
===================================================================
RCS file: /cvs/gnome/at-spi/cspi/spi_value.c,v
retrieving revision 1.13
diff -u -r1.13 spi_value.c
--- cspi/spi_value.c	2001/12/11 13:58:41	1.13
+++ cspi/spi_value.c	2001/12/12 00:25:41
@@ -1,62 +1,5 @@
 #include <cspi/spi-private.h>
 
-static void
-svalue_set_from_float (Accessibility_SValue *sval, float newValue)
-{
-  switch (sval->_d)
-    {
-      case Accessibility_SHORTVAL:
-        sval->_u.val_short = CLAMP (newValue, G_MINSHORT, G_MAXSHORT);
-        break;
-      case Accessibility_USHORTVAL:	    
-        sval->_u.val_ushort = CLAMP (newValue, 0, G_MAXUSHORT);
-        break;
-      case Accessibility_LONGVAL:	    
-        sval->_u.val_long = CLAMP (newValue, G_MINLONG, G_MAXLONG);
-        break;
-      case Accessibility_ULONGVAL:	    
-        sval->_u.val_ulong = CLAMP (newValue, 0, G_MAXULONG);
-        break;
-      case Accessibility_FLOATVAL:	    
-        sval->_u.val_float = newValue;
-        break;
-      case Accessibility_DOUBLEVAL:	    
-        sval->_u.val_double = newValue;
-        break;
-    }
-}
-
-
-static float
-svalue_to_float (Accessibility_SValue *sval)
-{
-  float retval = 0.0;
-  switch (sval->_d)
-    {
-      case Accessibility_SHORTVAL:
-        retval = sval->_u.val_short;
-        break;
-      case Accessibility_USHORTVAL:	    
-        retval = sval->_u.val_ushort;
-        break;
-      case Accessibility_LONGVAL:	    
-        retval = sval->_u.val_long;
-        break;
-      case Accessibility_ULONGVAL:	    
-        retval = sval->_u.val_ulong;
-        break;
-      case Accessibility_FLOATVAL:	    
-        retval = sval->_u.val_float;
-        break;
-      case Accessibility_DOUBLEVAL:	    
-        retval = sval->_u.val_double;
-        break;
-    }
-
-  return retval;
-}
-
-
 /**
  * AccessibleValue_ref:
  * @obj: a pointer to the #AccessibleValue implementor on which to operate.
@@ -90,19 +33,19 @@
  * Returns: the minimum allowed value for this object.
  *
  **/
-float
+double
 AccessibleValue_getMinimumValue (AccessibleValue *obj)
 {
-  Accessibility_SValue sval;
+  double retval;
 
   cspi_return_val_if_fail (obj != NULL, 0.0);
 
-  sval = 
+  retval = 
     Accessibility_Value__get_minimumValue (CSPI_OBJREF (obj), cspi_ev ());
   
   cspi_return_val_if_ev ("getMinimumValue", 0.0);
 
-  return svalue_to_float (&sval);
+  return retval;
 }
 
 /**
@@ -113,19 +56,19 @@
  *
  * Returns: the current value for this object.
  **/
-float
+double
 AccessibleValue_getCurrentValue (AccessibleValue *obj)
 {
-  Accessibility_SValue sval;
+  double retval;
 
   cspi_return_val_if_fail (obj != NULL, 0.0);
 
-  sval =
+  retval =
     Accessibility_Value__get_currentValue (CSPI_OBJREF (obj), cspi_ev ());
 
   cspi_return_val_if_ev ("getCurrentValue", 0.0);
 
-  return svalue_to_float (&sval);
+  return retval;
 }
 
 /**
@@ -136,19 +79,18 @@
  *
  * Returns: the maximum allowed value for this object.
  **/
-float
+double
 AccessibleValue_getMaximumValue (AccessibleValue *obj)
 {
-  Accessibility_SValue sval;
-
+  double retval;	
   cspi_return_val_if_fail (obj != NULL, 0.0);
 
-  sval =
+  retval =
     Accessibility_Value__get_maximumValue (CSPI_OBJREF (obj), cspi_ev ());
 
   cspi_return_val_if_ev ("getMaximumValue", 0.0);
 
-  return svalue_to_float (&sval);
+  return retval;
 }
 
 /**
@@ -163,19 +105,12 @@
  **/
 SPIBoolean
 AccessibleValue_setCurrentValue (AccessibleValue *obj,
-                                 float newValue)
+                                 double newValue)
 {
-  Accessibility_SValue sval;	
   cspi_return_val_if_fail (obj != NULL, FALSE);
 
-  /* erk, this is ugly */
-  sval = Accessibility_Value__get_currentValue (
-    CSPI_OBJREF (obj), cspi_ev ());
-
-  svalue_set_from_float (&sval, newValue);
-  
   Accessibility_Value__set_currentValue (
-    CSPI_OBJREF (obj), &sval, cspi_ev ());
+    CSPI_OBJREF (obj), newValue, cspi_ev ());
 
   cspi_return_val_if_ev ("setCurrentValue", FALSE);
 
Index: docs/reference/cspi/tmpl/spi_registry.sgml
===================================================================
RCS file: /cvs/gnome/at-spi/docs/reference/cspi/tmpl/spi_registry.sgml,v
retrieving revision 1.3
diff -u -r1.3 spi_registry.sgml
--- docs/reference/cspi/tmpl/spi_registry.sgml	2001/12/07 16:43:08	1.3
+++ docs/reference/cspi/tmpl/spi_registry.sgml	2001/12/12 00:25:41
@@ -139,6 +139,7 @@
 @modmask: 
 @eventmask: 
 @sync_type: 
+ Returns: 
 
 
 <!-- ##### FUNCTION deregisterAccessibleKeystrokeListener ##### -->
@@ -148,6 +149,7 @@
 
 @listener: 
 @modmask: 
+ Returns: 
 
 
 <!-- ##### FUNCTION AccessibleKeystrokeListener_removeCallback ##### -->
@@ -178,6 +180,7 @@
 
 @keyval: 
 @synth_type: 
+ Returns: 
 
 
 <!-- ##### FUNCTION generateMouseEvent ##### -->
@@ -188,5 +191,6 @@
 @x: 
 @y: 
 @name: 
+ Returns: 
 
 
Index: idl/Accessibility_Accessible.idl
===================================================================
RCS file: /cvs/gnome/at-spi/idl/Accessibility_Accessible.idl,v
retrieving revision 1.11
diff -u -r1.11 Accessibility_Accessible.idl
--- idl/Accessibility_Accessible.idl	2001/12/11 16:56:15	1.11
+++ idl/Accessibility_Accessible.idl	2001/12/12 00:25:41
@@ -110,6 +110,14 @@
     Role		getRole ();
 
     /**
+     * getRoleName:
+     * Get a string indicating the type of UI role played by this object.
+     *
+     * Returns: a UTF-8 string indicating the type of UI role played by this object.
+     **/
+    string		getRoleName ();
+
+    /**
      * getState:
      *
      * Get the current state of the object as a @StateSet.
Index: idl/Accessibility_Role.idl
===================================================================
RCS file: /cvs/gnome/at-spi/idl/Accessibility_Role.idl,v
retrieving revision 1.3
diff -u -r1.3 Accessibility_Role.idl
--- idl/Accessibility_Role.idl	2001/07/27 10:18:57	1.3
+++ idl/Accessibility_Role.idl	2001/12/12 00:25:42
@@ -200,6 +200,11 @@
   ROLE_VIEWPORT,
   /* A top level window with no title or border */
   ROLE_WINDOW,
+  /* 
+   * means that the role for this item is known, but not included in the 
+   * core enumeration 
+   */
+  ROLE_EXTENDED,
   /* not a valid role, used for finding end of enumeration. */
   ROLE_LAST_DEFINED
   };
Index: idl/Accessibility_Value.idl
===================================================================
RCS file: /cvs/gnome/at-spi/idl/Accessibility_Value.idl,v
retrieving revision 1.4
diff -u -r1.4 Accessibility_Value.idl
--- idl/Accessibility_Value.idl	2001/12/11 13:58:43	1.4
+++ idl/Accessibility_Value.idl	2001/12/12 00:25:42
@@ -22,28 +22,10 @@
 
 module Accessibility {
 
-  enum ValueType {
-	  SHORTVAL, 
-	  USHORTVAL,
-	  LONGVAL,
-	  ULONGVAL,
-	  FLOATVAL,
-	  DOUBLEVAL
-  };
-
-  union SValue switch (ValueType) {
-	  case Accessibility::SHORTVAL:  short val_short;
-	  case Accessibility::USHORTVAL: unsigned short val_ushort;
-	  case Accessibility::LONGVAL:   long val_long;
-	  case Accessibility::ULONGVAL:  unsigned long val_ulong;
-	  case Accessibility::FLOATVAL:  float val_float;
-	  case Accessibility::DOUBLEVAL: double val_double;
-  };
-
   interface Value : Bonobo::Unknown {
-    readonly attribute SValue minimumValue;
-    readonly attribute SValue maximumValue;
-    readonly attribute SValue minimumIncrement;
-    attribute SValue currentValue;
+    readonly attribute double minimumValue;
+    readonly attribute double maximumValue;
+    readonly attribute double minimumIncrement;
+    attribute double currentValue;
   };
 };
Index: libspi/accessible.c
===================================================================
RCS file: /cvs/gnome/at-spi/libspi/accessible.c,v
retrieving revision 1.28
diff -u -r1.28 accessible.c
--- libspi/accessible.c	2001/12/09 23:08:11	1.28
+++ libspi/accessible.c	2001/12/12 00:25:42
@@ -31,6 +31,92 @@
 /* Our parent Gtk object type  */
 #define PARENT_TYPE SPI_TYPE_BASE
 
+static Accessibility_Role
+spi_role_from_atk_role (AtkRole role)
+{
+  Accessibility_Role spi_role;
+
+  /* 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:
+      spi_role = Accessibility_ROLE_EXTENDED;	    
+  }
+  return spi_role;
+}
+
 static AtkObject *
 get_accessible_from_servant (PortableServer_Servant servant)
 {
@@ -256,11 +342,29 @@
   g_return_val_if_fail (object != NULL, 0);
 
   role = atk_object_get_role (object);
-  retval = role; /* FIXME: relies on ability to cast these back and forth */
+  retval = spi_role_from_atk_role (role);
 
   return retval;
 }
 
+/*
+ * CORBA Accessibility::Accessible::getRole method implementation
+ */
+static CORBA_char *
+impl_accessibility_accessible_get_role_name (PortableServer_Servant servant,
+					     CORBA_Environment     *ev)
+{
+  AtkRole            role;
+  Accessibility_Role retval;
+  AtkObject         *object = get_accessible_from_servant (servant);
+
+  g_return_val_if_fail (object != NULL, 0);
+
+  role = atk_object_get_role (object);
+
+  return CORBA_string_dup (atk_role_get_name (role));
+}
+
 static void
 spi_accessible_class_init (SpiAccessibleClass *klass)
 {
@@ -279,6 +383,7 @@
         epv->getRelationSet = impl_accessibility_accessible_get_relation_set;
         epv->getState = impl_accessibility_accessible_get_state;
         epv->getRole = impl_accessibility_accessible_get_role;
+        epv->getRoleName = impl_accessibility_accessible_get_role_name;
 }
 
 static void
Index: libspi/value.c
===================================================================
RCS file: /cvs/gnome/at-spi/libspi/value.c,v
retrieving revision 1.11
diff -u -r1.11 value.c
--- libspi/value.c	2001/12/11 13:58:46	1.11
+++ libspi/value.c	2001/12/12 00:25:43
@@ -29,25 +29,27 @@
 
 /* Static function declarations */
 
-static Accessibility_SValue
-gvalue_to_svalue (GValue *gvalue);
+static double
+get_double_from_gvalue (GValue *gvalue);
 static void
+gvalue_set_from_double (GValue *gvalue, double value);
+static void
 spi_value_class_init (SpiValueClass *klass);
 static void
 spi_value_init (SpiValue *value);
-static Accessibility_SValue
+static double
 impl__get_minimumValue (PortableServer_Servant _servant,
 			CORBA_Environment *    ev);
-static Accessibility_SValue
+static double
 impl__get_maximumValue (PortableServer_Servant _servant,
 			CORBA_Environment *    ev);
-static Accessibility_SValue
+static double
 impl__get_currentValue (PortableServer_Servant _servant,
 			CORBA_Environment *    ev);
 static void 
-impl__set_currentValue (PortableServer_Servant       _servant,
-			const Accessibility_SValue * value,
-			CORBA_Environment *          ev);
+impl__set_currentValue (PortableServer_Servant _servant,
+			const CORBA_double     value,
+			CORBA_Environment *    ev);
 
 
 BONOBO_TYPE_FUNC_FULL (SpiValue,
@@ -100,142 +102,149 @@
   return ATK_VALUE (object->atko);
 }
 
-static Accessibility_SValue
-gvalue_to_svalue (GValue *gvalue)
+static double
+get_double_from_gvalue (GValue *gvalue)
 {
-  Accessibility_SValue sval;
-  if (G_VALUE_HOLDS_DOUBLE (gvalue))
-  {
-      sval._d = Accessibility_DOUBLEVAL;
-      sval._u.val_double = g_value_get_double (gvalue);
-  }
-  else if (G_VALUE_HOLDS_FLOAT (gvalue))
-  {
-      sval._d = Accessibility_FLOATVAL;
-      sval._u.val_float = g_value_get_float (gvalue);
-  }
-  else if (G_VALUE_HOLDS_ULONG (gvalue))
-  {
-      sval._d = Accessibility_ULONGVAL;
-      sval._u.val_ulong = g_value_get_ulong (gvalue); 
-  }
-  else if (G_VALUE_HOLDS_LONG (gvalue))
-  {
-      sval._d = Accessibility_LONGVAL;
-      sval._u.val_long = g_value_get_long (gvalue);
-  }
-  else if (G_VALUE_HOLDS_UINT (gvalue))
-  {
-      sval._d = Accessibility_USHORTVAL;
-      sval._u.val_ushort = CLAMP (g_value_get_uint (gvalue), 0, G_MAXUSHORT);
-  }
-  else if (G_VALUE_HOLDS_INT (gvalue))
-  {
-      sval._d = Accessibility_SHORTVAL;
-      sval._u.val_short = CLAMP (g_value_get_int (gvalue), G_MINSHORT, G_MAXSHORT);
-  }
+  double	retval = 0;
+  if (G_TYPE_IS_FUNDAMENTAL (G_VALUE_TYPE (gvalue)))
+    {
+      switch (gvalue->g_type)
+        {
+	  case G_TYPE_DOUBLE:
+            retval = g_value_get_double (gvalue);
+	    break;
+	  case G_TYPE_FLOAT:
+            retval = g_value_get_float (gvalue);
+	    break;
+	  case G_TYPE_ULONG:
+            retval = g_value_get_ulong (gvalue);
+	    break;
+	  case G_TYPE_LONG:
+            retval = g_value_get_long (gvalue);
+	    break;
+	  case G_TYPE_UINT:
+            retval = g_value_get_uint (gvalue);
+	    break;
+	  case G_TYPE_INT:
+            retval = g_value_get_int (gvalue);
+	    break;
+	  case G_TYPE_UCHAR:
+            retval = g_value_get_uchar (gvalue);
+	    break;
+	  case G_TYPE_CHAR:
+            retval = g_value_get_char (gvalue);
+	    break;
+	  case G_TYPE_BOOLEAN:
+            retval = g_value_get_boolean (gvalue);
+	    break;
+        }
+    }
   else
-  {
-      sval._d = Accessibility_SHORTVAL;
-      sval._u.val_short = 0;
-  }
-  return sval;
-}
+    {
+      g_warning ("SpiValue requested from a non-fundamental type\n");	    
+    }
+  return retval;
+}  
 
 static void
-gvalue_set_from_svalue (GValue *gvalue, Accessibility_SValue *sval)
+gvalue_set_from_double (GValue *gvalue, double value)
 {
-  switch (sval->_d)
+  if (G_TYPE_IS_FUNDAMENTAL (G_VALUE_TYPE (gvalue)))
     {
-      case Accessibility_DOUBLEVAL:
-        g_value_init (gvalue, G_TYPE_DOUBLE);
-        g_value_set_double (gvalue, sval->_u.val_double);
-        break;
-      case Accessibility_FLOATVAL:
-        g_value_init (gvalue, G_TYPE_FLOAT);
-        g_value_set_float (gvalue, sval->_u.val_float);
-        break;
-      case Accessibility_ULONGVAL:
-        g_value_init (gvalue, G_TYPE_ULONG);
-        g_value_set_ulong (gvalue, sval->_u.val_ulong);
-        break;
-      case Accessibility_LONGVAL:
-        g_value_init (gvalue, G_TYPE_LONG);
-        g_value_set_long (gvalue, sval->_u.val_long);
-        break;
-      case Accessibility_USHORTVAL:
-        g_value_init (gvalue, G_TYPE_UINT);
-        g_value_set_uint (gvalue, sval->_u.val_ushort);
-        break;
-      case Accessibility_SHORTVAL:
-        g_value_init (gvalue, G_TYPE_INT);
-        g_value_set_int (gvalue, sval->_u.val_short);
-        break;
-      default:
-        g_value_init (gvalue, G_TYPE_INT);
-	g_value_set_int (gvalue, 0);
+      switch (gvalue->g_type)
+        {
+	  case G_TYPE_DOUBLE:
+            g_value_set_double (gvalue, value);
+	    break;
+	  case G_TYPE_FLOAT:
+            g_value_set_float (gvalue, value);
+	    break;
+	  case G_TYPE_ULONG:
+            g_value_set_ulong (gvalue, value);
+	    break;
+	  case G_TYPE_LONG:
+            g_value_set_long (gvalue, value);
+	    break;
+	  case G_TYPE_UINT:
+            g_value_set_uint (gvalue, value);
+	    break;
+	  case G_TYPE_INT:
+            g_value_set_int (gvalue, value);
+	    break;
+	  case G_TYPE_UCHAR:
+            g_value_set_uchar (gvalue, value);
+	    break;
+	  case G_TYPE_CHAR:
+            g_value_set_char (gvalue, value);
+	    break;
+	  case G_TYPE_BOOLEAN:
+            g_value_set_boolean (gvalue, ((fabs (value) > 0.5) ? 1 : 0));
+	    break;
+        }
     }
+  else
+    {
+      g_warning ("SpiValue change requested for a non-fundamental type\n");	    
+    }
 }
 
-static Accessibility_SValue
+static double
 impl__get_minimumValue (PortableServer_Servant servant,
 			CORBA_Environment     *ev)
 {
   GValue    gvalue = {0, };
   AtkValue *value = get_value_from_servant (servant);
 
-  g_return_val_if_fail (value != NULL, gvalue_to_svalue (&gvalue));
+  g_return_val_if_fail (value != NULL, 0.0);
 
-  g_value_init (&gvalue, G_TYPE_DOUBLE);
   atk_value_get_minimum_value (value, &gvalue);
 
-  return gvalue_to_svalue (&gvalue);
+  return get_double_from_gvalue (&gvalue);
 }
 
 
-static Accessibility_SValue
+static double
 impl__get_maximumValue (PortableServer_Servant servant,
 			CORBA_Environment     *ev)
 {
   GValue   gvalue = {0, };
   AtkValue *value = get_value_from_servant (servant);
 
-  g_return_val_if_fail (value != NULL, gvalue_to_svalue (&gvalue));
+  g_return_val_if_fail (value != NULL, 0.0);
 
-  g_value_init (&gvalue, G_TYPE_DOUBLE);
   atk_value_get_maximum_value (value, &gvalue);
 
-  return gvalue_to_svalue (&gvalue);
+  return get_double_from_gvalue (&gvalue);
 }
 
 
-static Accessibility_SValue
+static double
 impl__get_currentValue (PortableServer_Servant servant,
 			CORBA_Environment     *ev)
 {
   GValue   gvalue = {0, };
   AtkValue *value = get_value_from_servant (servant);
 
-  g_return_val_if_fail (value != NULL, gvalue_to_svalue (&gvalue));
+  g_return_val_if_fail (value != NULL, 0.0);
 
-  g_value_init (&gvalue, G_TYPE_DOUBLE);
   atk_value_get_current_value (value, &gvalue);
 
-  return gvalue_to_svalue (&gvalue);
+  return get_double_from_gvalue (&gvalue);
 }
 
 
 static void 
 impl__set_currentValue (PortableServer_Servant servant,
-			const Accessibility_SValue *value,
+			const CORBA_double     value,
 			CORBA_Environment     *ev)
 {
-  GValue    gvalue = {0, };
+  GValue    gvalue = { 0, };
   AtkValue *avalue = get_value_from_servant (servant);
 
   g_return_if_fail (avalue != NULL);
 
-  gvalue_set_from_svalue (&gvalue, value);
+  atk_value_get_current_value (avalue, &gvalue);
+  gvalue_set_from_double (&gvalue, value);
 
   atk_value_set_current_value (avalue, &gvalue);
 }
Index: test/simple-at.c
===================================================================
RCS file: /cvs/gnome/at-spi/test/simple-at.c,v
retrieving revision 1.25
diff -u -r1.25 simple-at.c
--- test/simple-at.c	2001/12/11 17:41:00	1.25
+++ test/simple-at.c	2001/12/12 00:25:44
@@ -183,7 +183,9 @@
     {
       if (festival_chatty) 	    
         {
-          _festival_say (Accessible_getRole (obj), "voice_don_diphone", shutup_previous_speech);
+	  s = Accessible_getRoleName (obj);	
+          _festival_say (s, "voice_don_diphone", shutup_previous_speech);
+	  SPI_freeString (s);
         }
       fprintf (stderr, "getting Name\n");
       s = Accessible_getName (obj);
Index: test/test-simple.c
===================================================================
RCS file: /cvs/gnome/at-spi/test/test-simple.c,v
retrieving revision 1.12
diff -u -r1.12 test-simple.c
--- test/test-simple.c	2001/12/11 19:06:17	1.12
+++ test/test-simple.c	2001/12/12 00:25:44
@@ -455,10 +455,11 @@
 		     gboolean    has_parent,
 		     gboolean    recurse_down)
 {
-	Accessible *tmp;
-	char       *name, *descr;
-	const char *role;
-	GString    *item_str = g_string_new ("");
+	Accessible    *tmp;
+	char          *name, *descr;
+	AccessibleRole role;
+	char          *role_name;
+	GString       *item_str = g_string_new ("");
 
 	name = Accessible_getName (accessible);
 	g_assert (name != NULL);
@@ -467,7 +468,10 @@
 	g_assert (descr != NULL);
 
 	role = Accessible_getRole (accessible);
-	g_assert (role != NULL);
+	g_assert (role != SPI_ROLE_INVALID);
+	role_name = Accessible_getRoleName (accessible);
+	g_assert (role_name != NULL);
+	
 
 	if (print_tree) {
 		int i;
@@ -582,10 +586,11 @@
 
 	if (print_tree)
 		fprintf (stderr, " ] '%s' (%s) - %s: %s\n",
-			 name, descr, role, item_str->str);
+			 name, descr, role_name, item_str->str);
 
 	SPI_freeString (name);
 	SPI_freeString (descr);
+	SPI_freeString (role_name);
 	g_string_free (item_str, TRUE);
 
 	validate_tree (accessible, has_parent, recurse_down);


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