From 9ddf777a096440afe521c094544942e85e3ee838 Mon Sep 17 00:00:00 2001 From: Mike Gorse Date: Wed, 25 May 2011 13:00:24 -0500 Subject: [PATCH] Install enum header, and try to get role name from enum Have atspi_accessible_get_role_name try to use the internal string associated with the accessible's role rather than calling GetRoleName. This avoids making a DBus call when the role is cached. Also, atspi.h now includes atspi-enum-types.h, and the latter is now installed. --- atspi/Makefile.am | 1 + atspi/atspi-accessible.c | 17 +++++++++++++++++ atspi/atspi.h | 2 ++ 3 files changed, 20 insertions(+) diff --git a/atspi/Makefile.am b/atspi/Makefile.am index 4d38ee4..2855185 100644 --- a/atspi/Makefile.am +++ b/atspi/Makefile.am @@ -27,6 +27,7 @@ libatspiinclude_HEADERS = \ atspi-device-listener-private.h \ atspi-document.h \ atspi-editabletext.h \ + atspi-enum-types.h \ atspi-event-listener.h \ atspi-event-listener-private.h \ atspi-gmain.c \ diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c index f1f0788..f8f72c0 100644 --- a/atspi/atspi-accessible.c +++ b/atspi/atspi-accessible.c @@ -576,7 +576,24 @@ 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); + + if (value) + { + retval = value->value_nick; + } + + if (retval) + return g_strdup (retval); g_return_val_if_fail (obj != NULL, NULL); diff --git a/atspi/atspi.h b/atspi/atspi.h index 7915760..7f66d2a 100644 --- a/atspi/atspi.h +++ b/atspi/atspi.h @@ -50,4 +50,6 @@ #include "atspi-value.h" #include "atspi-gmain.h" + +#include "atspi-enum-types.h" #endif -- 2.7.4