2009-06-11 Mark Doffman <mark.doffman@codethink.co.uk>
[platform/core/uifw/at-spi2-atk.git] / spi-common / spi-stateset.c
index 56eded2..4acf203 100644 (file)
@@ -26,6 +26,7 @@
 #include <config.h>
 #include <stdio.h>
 #include "spi-stateset.h"
+#include "bitarray.h"
 
 
 static Accessibility_StateType *accessible_state_types = NULL;
@@ -168,8 +169,31 @@ spi_state_set_cache_from_sequence (const GArray *seq)
   set = atk_state_set_new ();
   atk_state_set_add_states (set, states, seq->len);
 
-  g_free (states);
   g_array_free (seq, TRUE);
   return set;
 }
 
+void
+spi_atk_state_to_dbus_array (AtkObject * object, dbus_uint32_t * array)
+{
+  AtkStateSet *set = atk_object_ref_state_set (object);
+  int i;
+
+  array[0] = 0;
+  array[1] = 0;
+  if (!set)
+    return;
+  spi_init_state_type_tables ();
+
+  g_assert (ATK_STATE_LAST_DEFINED <= 64);
+  for (i = 0; i < ATK_STATE_LAST_DEFINED; i++)
+    {
+      if (atk_state_set_contains_state (set, i))
+       {
+         int a = accessible_state_types[i];
+         g_assert (a < 64);
+         BITARRAY_SET (array, a);
+       }
+    }
+  g_object_unref (set);
+}