1 /* ATK - Accessibility Toolkit
2 * Copyright 2001 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
24 static guint last_type
= ATK_STATE_LAST_DEFINED
;
26 #define NUM_POSSIBLE_STATES (sizeof(AtkState)*8)
28 static gchar
* state_names
[NUM_POSSIBLE_STATES
] = {
61 * atk_state_type_register:
62 * @name: a character string describing the new state.
64 * Register a new object state.
66 * Returns: an #AtkState value for the new state.
69 atk_state_type_register (const gchar
*name
)
71 g_return_val_if_fail (name
, ATK_STATE_INVALID
);
73 if (last_type
< NUM_POSSIBLE_STATES
-1)
75 state_names
[++last_type
] = g_strdup (name
);
78 return ATK_STATE_INVALID
; /* caller needs to check */
82 * atk_state_type_get_name:
83 * @type: The #AtkStateType whose name is required
85 * Gets the description string describing the #AtkStateType @type.
87 * Returns: the string describing the AtkStateType
90 atk_state_type_get_name (AtkStateType type
)
98 return state_names
[n
];
105 * atk_state_type_for_name:
106 * @name: a character string state name
108 * Gets the #AtkStateType corresponding to the description string @name.
110 * Returns: an #AtkStateType corresponding to @name
113 atk_state_type_for_name (const gchar
*name
)
117 g_return_val_if_fail (name
!= NULL
, 0);
118 g_return_val_if_fail (strlen (name
) > 0, 0);
120 for (i
= 0; i
< last_type
; i
++)
122 if (state_names
[i
] == NULL
)
124 if (!strcmp(name
, state_names
[i
]))