summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gorse <mgorse@suse.com>2013-05-22 15:38:15 -0500
committerMike Gorse <mgorse@suse.com>2013-05-22 15:38:15 -0500
commitb89a09fd8733292bc59134574281f80a309fbaac (patch)
tree025447e8a43fa92ba63abfc28f13ba18bc37e571
parent5b9c1723c5661b9d573b56af3673b488bf2136d7 (diff)
downloadat-spi2-core-b89a09fd8733292bc59134574281f80a309fbaac.tar.gz
Reinstate atspi_role_get_name
Atspi_role_get_name is used (by Orca, for instance) and was inadvertently removed with the enum refactor.
-rw-r--r--atspi/atspi-accessible.c22
-rw-r--r--atspi/atspi-misc.c33
-rw-r--r--atspi/atspi-misc.h1
3 files changed, 40 insertions, 16 deletions
diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c
index 322ebac1..0fff4fb2 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 efd2ba65..0e65fd5d 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 c63ef80b..f8df0a99 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_ */