Updated role enumeration in Accessibility_Role.idl.
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_accessible.c
index ca366c1..6f5ff36 100644 (file)
@@ -4,12 +4,17 @@
 static const char *role_names [] =
 {
   "<invalid>",
+  "accelerator label",
   "alert",
+  "animation",
+  "arrow",
+  "calendar",
   "canvas",
   "check box",
   "color chooser",
   "column header",
   "combo box",
+  "date editor",
   "desktop icon",
   "desktop frame",
   "dialog",
@@ -17,10 +22,12 @@ static const char *role_names [] =
   "file chooser",
   "filler",
   "focus traversable",
+  "font chooser",
   "frame",
   "glass pane",
   "HTML container",
   "icon",
+  "image",
   "internal frame",
   "label",
   "layered pane",
@@ -38,17 +45,21 @@ static const char *role_names [] =
   "progress bar",
   "pushbutton",
   "radiobutton",
+  "radio menu item",
   "root pane",
   "row header",
   "scrollbar",
   "scrollpane",
   "separator",
   "slider",
+  "spin button",
   "split pane",
+  "status bar",
   "table",
   "table cell",
   "table column header",
   "table row header",
+  "tearoff menu item",
   "text",
   "toggle button",
   "toolbar",
@@ -58,48 +69,36 @@ static const char *role_names [] =
   "viewport",
   "window",
 
-  /* These have no equivalent AccessibleRole enum values */
-  "accelerator label",
-  "animation",
-  "arrow",
-  "calendar",
-  "menu item",
-  "date editor",
-  "dial",
-  "drawing area",
-  "font chooser",
-  "image",
-  "radio menu item",
-  "tearoff menu item",
-  "spin button",
-  "status bar",
 };
 
 #define MAX_ROLES (sizeof (role_names) / sizeof (char *))
 
+static AccessibleRole
+cspi_role_from_spi_role (Accessibility_Role role)
+{
+  return role; /* FIXME: need to compare, equivalence not guaranteed */
+}
+
 /**
  * AccessibleRole_getName:
  * @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
-   */
 }
 
 /**
@@ -107,9 +106,6 @@ AccessibleRole_getName (AccessibleRole role)
  * @obj: a pointer to the #Accessible object on which to operate.
  *
  * Increment the reference count for an #Accessible object.
- *
- * Returns: (no return code implemented yet).
- *
  **/
 void
 Accessible_ref (Accessible *obj)
@@ -122,7 +118,6 @@ Accessible_ref (Accessible *obj)
  * @obj: a pointer to the #Accessible object on which to operate.
  *
  * Decrement the reference count for an #Accessible object.
- *
  **/
 void
 Accessible_unref (Accessible *obj)
@@ -325,21 +320,48 @@ Accessible_getRelationSet (Accessible *obj)
  * @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 ());
 
-  retval = AccessibleRole_getName (
-    Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ()));
+  cspi_return_val_if_ev ("getRole", SPI_ROLE_INVALID); 
 
-  cspi_return_val_if_ev ("getRole", NULL); 
+  return cspi_role_from_spi_role (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 = 
+    Accessibility_Accessible_getRoleName (CSPI_OBJREF (obj), cspi_ev ());
+
+  cspi_return_val_if_ev ("getRoleName", CORBA_string_dup ("invalid")); 
 
   return retval;
 }
@@ -703,7 +725,7 @@ Accessible_getValue (Accessible *obj)
  *          by @obj, or NULL otherwise.
  *
  **/
-GenericInterface *
+AccessibleUnknown *
 Accessible_queryInterface (Accessible *obj,
                           const char *interface_name)
 {
@@ -740,7 +762,6 @@ Accessible_queryInterface (Accessible *obj,
  *
  * Increment the reference count for an #AccessibleRelation object.
  *
- * Returns: (no return code implemented yet).
  **/
 void
 AccessibleRelation_ref (AccessibleRelation *obj)
@@ -754,7 +775,6 @@ AccessibleRelation_ref (AccessibleRelation *obj)
  *
  * Decrement the reference count for an #AccessibleRelation object.
  *
- * Returns: (no return code implemented yet).
  **/
 void
 AccessibleRelation_unref (AccessibleRelation *obj)
@@ -823,8 +843,6 @@ AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
  *
  * Increment the reference count for an #AccessibleStateSet object.
  *
- * Returns: (no return code implemented yet).
- *
  **/
 void
 AccessibleStateSet_ref (AccessibleStateSet *obj)
@@ -838,8 +856,6 @@ AccessibleStateSet_ref (AccessibleStateSet *obj)
  *
  * Decrement the reference count for an #AccessibleStateSet object.
  *
- * Returns: (no return code implemented yet).
- *
  **/
 void
 AccessibleStateSet_unref (AccessibleStateSet *obj)