[at-spi2-core] Reinstate atspi_role_get_name



commit b89a09fd8733292bc59134574281f80a309fbaac
Author: Mike Gorse <mgorse suse com>
Date:   Wed May 22 15:38:15 2013 -0500

    Reinstate atspi_role_get_name
    
    Atspi_role_get_name is used (by Orca, for instance) and was
    inadvertently removed with the enum refactor.

 atspi/atspi-accessible.c |   22 ++++++----------------
 atspi/atspi-misc.c       |   33 +++++++++++++++++++++++++++++++++
 atspi/atspi-misc.h       |    1 +
 3 files changed, 40 insertions(+), 16 deletions(-)
---
diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c
index 322ebac..0fff4fb 100644
--- a/atspi/atspi-accessible.c
+++ b/atspi/atspi-accessible.c
@@ -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);
 
diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c
index efd2ba6..0e65fd5 100644
--- a/atspi/atspi-misc.c
+++ b/atspi/atspi-misc.c
@@ -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;
+}
diff --git a/atspi/atspi-misc.h b/atspi/atspi-misc.h
index c63ef80..f8df0a9 100644
--- a/atspi/atspi-misc.h
+++ b/atspi/atspi-misc.h
@@ -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_ */


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