* Boston, MA 02111-1307, USA.
*/
-#include "atkstate.h"
+#include "config.h"
+
+#include "atk.h"
#include <string.h>
+/**
+ * SECTION:atkstate
+ * @Short_description: An AtkState describes a single state of an object.
+ * @Title:AtkState
+ *
+ * An AtkState describes a single state of an object. The full set of states
+ * that apply to an object at a given time are contained in its #AtkStateSet.
+ * See also #atk_object_ref_state_set and #atk_object_notify_state_change.
+ */
+
static guint last_type = ATK_STATE_LAST_DEFINED;
#define NUM_POSSIBLE_STATES (sizeof(AtkState)*8)
-static gchar* state_names[NUM_POSSIBLE_STATES] = {
- "invalid",
- "active",
- "armed",
- "busy",
- "checked",
- "defunct",
- "editable",
- "enabled",
- "expandable",
- "expanded",
- "focusable",
- "focused",
- "horizontal",
- "iconified",
- "modal",
- "multi-line",
- "multiselectable",
- "opaque",
- "pressed",
- "resizeable",
- "selectable",
- "selected",
- "sensitive",
- "showing",
- "single-line",
- "stale",
- "transient",
- "vertical",
- "visible"
-};
+static gchar* state_names[NUM_POSSIBLE_STATES];
/**
* atk_state_type_register:
*
* Returns: the string describing the AtkStateType
*/
-G_CONST_RETURN gchar*
+const gchar*
atk_state_type_get_name (AtkStateType type)
{
- gint n;
+ GTypeClass *type_class;
+ GEnumValue *value;
+ const gchar *name = NULL;
+
+ type_class = g_type_class_ref (ATK_TYPE_STATE_TYPE);
+ g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), NULL);
- if (type < last_type)
+ value = g_enum_get_value (G_ENUM_CLASS (type_class), type);
+
+ if (value)
+ {
+ name = value->value_nick;
+ }
+ else
{
- n = type;
- if (n >= 0)
- return state_names[n];
+ if (type <= last_type)
+ {
+ if (type >= 0)
+ name = state_names[type];
+ }
}
- return NULL;
+ g_type_class_unref (type_class);
+
+ return name;
}
/**
AtkStateType
atk_state_type_for_name (const gchar *name)
{
- gint i;
+ GTypeClass *type_class;
+ GEnumValue *value;
+ AtkStateType type = ATK_STATE_INVALID;
+
+ g_return_val_if_fail (name, ATK_STATE_INVALID);
- g_return_val_if_fail (name != NULL, 0);
- g_return_val_if_fail (strlen (name) > 0, 0);
+ type_class = g_type_class_ref (ATK_TYPE_STATE_TYPE);
+ g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), ATK_STATE_INVALID);
- for (i = 0; i < last_type; i++)
+ value = g_enum_get_value_by_nick (G_ENUM_CLASS (type_class), name);
+
+ if (value)
+ {
+ type = value->value;
+ }
+ else
{
- if (state_names[i] == NULL)
- continue;
- if (!strcmp(name, state_names[i]))
- return i;
+ gint i;
+
+ for (i = ATK_STATE_LAST_DEFINED + 1; i <= last_type; i++)
+ {
+ if (state_names[i] == NULL)
+ continue;
+ if (!strcmp(name, state_names[i]))
+ {
+ type = i;
+ break;
+ }
+ }
}
- return 0;
+ return type;
}