1 #include "atspi-private.h"
3 static void atspi_state_set_class_init (AtspiStateSetClass *klass);
5 G_DEFINE_TYPE (AtspiStateSet, atspi_state_set, G_TYPE_OBJECT)
7 static const char *state_names [] =
40 "manages-descendants",
46 "supports-autocompletion",
54 atspi_state_set_init (AtspiStateSet *set)
60 atspi_state_set_class_init (AtspiStateSetClass* klass)
65 atspi_state_set_new (AtspiAccessible *accessible, gint64 states)
69 set = g_object_new (ATSPI_TYPE_STATE_SET, NULL);
70 g_return_val_if_fail (set != NULL, NULL);
72 set->accessible = accessible;
77 void atspi_state_set_set_by_name (AtspiStateSet *set, const gchar *name, gboolean enabled)
81 if (!(set->accessible->cached_properties & ATSPI_CACHE_STATES))
84 /* TODO: This could perhaps be optimized */
85 for (i = 0; state_names [i]; i++)
87 if (!strcmp (state_names [i], name))
90 set->states |= (1 << i);
92 set->states &= ~(1 << i);
96 g_warning ("at-spi: Attempt to set unknown state '%s'", name);
100 refresh_states (AtspiStateSet *set)
103 dbus_uint32_t *states;
105 if ((set->accessible->cached_properties & ATSPI_CACHE_STATES))
108 if (!_atspi_dbus_call (set->accessible, atspi_interface_accessible, "GetState", NULL, "=>au", &state_array))
111 states = (dbus_uint32_t *) state_array->data;
113 set->states = ((gint64)states [1]) << 32;
114 set->states += states [0];
115 g_array_free (state_array, TRUE);
119 * atspi_state_set_contains:
120 * @set: a pointer to the #AtspiStateSet object on which to operate.
121 * @state: an #AtspiStateType for which the specified #AtspiStateSet
124 * Determine whether a given #AtspiStateSet includes a given state; that is,
125 * whether @state is true for the stateset in question.
127 * Returns: #TRUE if @state is true/included in the given #AtspiStateSet,
132 atspi_state_set_contains (AtspiStateSet *set,
133 AtspiStateType state)
135 refresh_states (set);
136 return (set->states & (1 << state)) ? TRUE : FALSE;