Install enum header, and try to get role name from enum
authorMike Gorse <mgorse@novell.com>
Wed, 25 May 2011 18:00:24 +0000 (13:00 -0500)
committerMike Gorse <mgorse@novell.com>
Wed, 25 May 2011 18:00:24 +0000 (13:00 -0500)
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
atspi/atspi-accessible.c
atspi/atspi.h

index 4d38ee4..2855185 100644 (file)
@@ -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 \
index f1f0788..f8f72c0 100644 (file)
@@ -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);
 
index 7915760..7f66d2a 100644 (file)
@@ -50,4 +50,6 @@
 #include "atspi-value.h"
 
 #include "atspi-gmain.h"
+
+#include "atspi-enum-types.h"
 #endif