Reinstate atspi_role_get_name
authorMike Gorse <mgorse@suse.com>
Wed, 22 May 2013 20:38:15 +0000 (15:38 -0500)
committerMike Gorse <mgorse@suse.com>
Wed, 22 May 2013 20:38:15 +0000 (15:38 -0500)
Atspi_role_get_name is used (by Orca, for instance) and was
inadvertently removed with the enum refactor.

atspi/atspi-accessible.c
atspi/atspi-misc.c
atspi/atspi-misc.h

index 322ebac..0fff4fb 100644 (file)
@@ -488,24 +488,14 @@ atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
 gchar *
 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
 {
-  AtspiRole role = atspi_accessible_get_role (obj, error);
-  char *retval = NULL;
-  GTypeClass *type_class;
-  GEnumValue *value;
-  const gchar *name = NULL;
-
-  type_class = g_type_class_ref (ATSPI_TYPE_ROLE);
-  g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), NULL);
-
-  value = g_enum_get_value (G_ENUM_CLASS (type_class), role);
+  gchar *retval = NULL;
+  AtspiRole role;
 
-  if (value)
-    {
-      retval = g_strdup (value->value_nick);
-    }
+  g_return_val_if_fail (obj != NULL, NULL);
 
-  if (retval)
-    return _atspi_name_compat (g_strdup (retval));
+  role = atspi_accessible_get_role (obj, error);
+  if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
+    return atspi_role_get_name (role);
 
   _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
 
index efd2ba6..0e65fd5 100644 (file)
@@ -1640,3 +1640,36 @@ _atspi_name_compat (gchar *name)
   }
   return name;
 }
+
+/**
+ * atspi_role_get_name:
+ * @role: an #AtspiRole object to query.
+ *
+ * Gets a localizable string that indicates the name of an #AtspiRole.
+ * <em>DEPRECATED.</em>
+ *
+ * Returns: a localizable string name for an #AtspiRole enumerated type.
+ **/
+gchar *
+atspi_role_get_name (AtspiRole role)
+{
+  gchar *retval = NULL;
+  GTypeClass *type_class;
+  GEnumValue *value;
+  const gchar *name = NULL;
+
+  type_class = g_type_class_ref (ATSPI_TYPE_ROLE);
+  g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), NULL);
+
+  value = g_enum_get_value (G_ENUM_CLASS (type_class), role);
+
+  if (value)
+    {
+      retval = g_strdup (value->value_nick);
+    }
+
+  if (retval)
+    return _atspi_name_compat (g_strdup (retval));
+
+  return NULL;
+}
index c63ef80..f8df0a9 100644 (file)
@@ -42,6 +42,7 @@ atspi_get_a11y_bus ();
 void
 atspi_set_timeout (gint val, gint startup_time);
 
+gchar * atspi_role_get_name (AtspiRole role);
 G_END_DECLS
 
 #endif /* _ATSPI_MISC_H_ */