* AT-SPI - Assistive Technology Service Provider Interface
* (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
*
- * Copyright 2001 Sun Microsystems Inc.
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
{
gint i;
+ if (accessible_state_types || atk_state_types)
+ return FALSE;
+ if (!accessible_state_types)
+ accessible_state_types = g_new (Accessibility_StateType, ATK_STATE_LAST_DEFINED);
+ if (!atk_state_types)
+ atk_state_types = g_new (AtkStateType, Accessibility_STATE_LAST_DEFINED);
g_return_val_if_fail (accessible_state_types, FALSE);
g_return_val_if_fail (atk_state_types, FALSE);
- accessible_state_types = g_new (Accessibility_StateType, ATK_STATE_LAST_DEFINED);
- atk_state_types = g_new (AtkStateType, ATK_STATE_LAST_DEFINED);
-
- for (i = 0; i < ATK_STATE_LAST_DEFINED; i++)
+ for (i = 0; i < Accessibility_STATE_LAST_DEFINED; i++)
{
atk_state_types[i] = ATK_STATE_INVALID;
- accessible_state_types[i] = Accessibility_STATE_INVALID;
+ }
+
+ for (i=0; i < ATK_STATE_LAST_DEFINED; i++)
+ {
+ accessible_state_types[i] = Accessibility_STATE_INVALID;
}
accessible_state_types[ATK_STATE_ACTIVE] = Accessibility_STATE_ACTIVE;
atk_state_types[Accessibility_STATE_VERTICAL] = ATK_STATE_VERTICAL;
accessible_state_types[ATK_STATE_VISIBLE] = Accessibility_STATE_VISIBLE;
atk_state_types[Accessibility_STATE_VISIBLE] = ATK_STATE_VISIBLE;
+ accessible_state_types[ATK_STATE_MANAGES_DESCENDANTS] = Accessibility_STATE_MANAGES_DESCENDANTS;
+ atk_state_types[Accessibility_STATE_MANAGES_DESCENDANTS] = ATK_STATE_MANAGES_DESCENDANTS;
+ accessible_state_types[ATK_STATE_INDETERMINATE] = Accessibility_STATE_INDETERMINATE;
+ atk_state_types[Accessibility_STATE_INDETERMINATE] = ATK_STATE_INDETERMINATE;
return TRUE;
}
+static inline AtkState
+state_spi_to_atk (Accessibility_StateType state)
+{
+ guint idx = state;
+ if (idx < Accessibility_STATE_LAST_DEFINED)
+ return atk_state_types [idx];
+ else
+ return ATK_STATE_INVALID;
+}
+AtkState
+spi_atk_state_from_spi_state (Accessibility_StateType state)
+{
+ spi_init_state_type_tables ();
+ return state_spi_to_atk (state);
+}
static AtkStateSet *
atk_state_set_from_servant (PortableServer_Servant servant)
return ATK_STATE_SET(base->gobj);
}
+AtkStateSet *
+spi_state_set_cache_from_sequence (const Accessibility_StateSeq *seq)
+{
+ int i;
+ AtkStateSet *set;
+ AtkStateType *states;
+ spi_init_state_type_tables ();
+
+ states = g_newa (AtkStateType, seq->_length);
+ for (i = 0; i < seq->_length; i++)
+ states [i] = state_spi_to_atk (seq->_buffer [i]);
+
+ set = atk_state_set_new ();
+ atk_state_set_add_states (set, states, seq->_length);
+
+ return set;
+}
static AtkStateSet *
atk_state_set_from_accessibility_state_set (Accessibility_StateSet set, CORBA_Environment *ev)
{
- AtkStateType *states, *tmp;
AtkStateSet *rv;
- gint i;
Accessibility_StateSeq *seq;
seq = Accessibility_StateSet_getStates (set, ev);
- states = tmp = g_new (AtkStateType, seq->_length);
- for (i = 0; i < seq->_length; i++)
- *tmp++ = atk_state_types[seq->_buffer[i]];
- rv = atk_state_set_new ();
- atk_state_set_add_states (rv, states, seq->_length);
+ rv = spi_state_set_cache_from_sequence (seq);
CORBA_free (seq);
- g_free (states);
+
return rv;
}
-
SpiStateSet *
spi_state_set_new (AtkStateSet *obj)
{
}
-
static CORBA_boolean
impl_contains (PortableServer_Servant servant,
const Accessibility_StateType state,
AtkStateSet *set = atk_state_set_from_servant (servant);
g_return_val_if_fail (set, FALSE);
- return (CORBA_boolean)
- atk_state_set_contains_state (set, atk_state_types[state]);
+ return atk_state_set_contains_state (set, state_spi_to_atk (state));
}
-
static void
-impl_add(PortableServer_Servant servant,
- const Accessibility_StateType state,
- CORBA_Environment * ev)
+impl_add (PortableServer_Servant servant,
+ const Accessibility_StateType state,
+ CORBA_Environment * ev)
{
AtkStateSet *set = atk_state_set_from_servant (servant);
g_return_if_fail (set);
- atk_state_set_add_state (set, atk_state_types[state]);
+ atk_state_set_add_state (set, state_spi_to_atk (state));
}
-
static void
impl_remove (PortableServer_Servant servant,
const Accessibility_StateType state,
AtkStateSet *set = atk_state_set_from_servant (servant);
g_return_if_fail (set);
- atk_state_set_remove_state (set, atk_state_types[state]);
+ atk_state_set_remove_state (set, state_spi_to_atk (state));
}
-
static CORBA_boolean
impl_equals (PortableServer_Servant servant,
const Accessibility_StateSet stateSet,
g_object_unref (G_OBJECT(set2));
if (return_set)
{
- rv = (CORBA_boolean)
- atk_state_set_is_empty (return_set);
+ rv = atk_state_set_is_empty (return_set);
g_object_unref (G_OBJECT(return_set));
}
else
}
-
static Accessibility_StateSet
impl_compare (PortableServer_Servant servant,
const Accessibility_StateSet compareState,
}
-
static CORBA_boolean
impl_isEmpty (PortableServer_Servant servant,
CORBA_Environment * ev)
AtkStateSet *set = atk_state_set_from_servant (servant);
g_return_val_if_fail (set, TRUE);
- return (CORBA_boolean)
- atk_state_set_is_empty (set);
+ return atk_state_set_is_empty (set);
}
-
static Accessibility_StateSeq *
impl_getStates (PortableServer_Servant servant,
CORBA_Environment * ev)
states = g_slist_append (states, (gpointer) Accessibility_STATE_VERTICAL);
if (atk_state_set_contains_state (set, ATK_STATE_VISIBLE))
states = g_slist_append (states, (gpointer) Accessibility_STATE_VISIBLE);
+ if (atk_state_set_contains_state (set, ATK_STATE_MANAGES_DESCENDANTS))
+ states = g_slist_append (states, (gpointer) Accessibility_STATE_MANAGES_DESCENDANTS);
+ if (atk_state_set_contains_state (set, ATK_STATE_INDETERMINATE))
+ states = g_slist_append (states, (gpointer) Accessibility_STATE_INDETERMINATE);
rv = Accessibility_StateSeq__alloc ();
rv->_length = rv->_maximum = g_slist_length (states);
}
-
static void
spi_state_set_class_init (SpiStateSetClass *klass)
{
POA_Accessibility_StateSet__epv *epv = &klass->epv;
+ spi_init_state_type_tables ();
epv->contains = impl_contains;
epv->add = impl_add;
epv->remove = impl_remove;
BONOBO_TYPE_FUNC_FULL (SpiStateSet,
Accessibility_StateSet,
SPI_TYPE_BASE,
- spi_state_set);
+ spi_state_set)