Added better gtk-doc comments.
[platform/upstream/atk.git] / atk / atkstate.c
1 /* ATK -  Accessibility Toolkit
2  * Copyright 2001 Sun Microsystems Inc.
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 #include "atkstate.h"
21
22 #define NUM_POSSIBLE_STATES               (sizeof(AtkState)*8)
23
24 static gchar* state_names[NUM_POSSIBLE_STATES] = {
25  "invalid",
26  "active",
27  "armed",
28  "busy",
29  "checked",
30  "collapsed",
31  "defunct",
32  "editable",
33  "expandable",
34  "expanded",
35  "focusable",
36  "focused",
37  "horizontal",
38  "iconified",
39  "modal",
40  "multi-line",
41  "multiselect,ble",
42  "opaque",
43  "pressed",
44  "resizeable",
45  "selectable",
46  "selected",
47  "sensitive",
48  "showing",
49  "single-line",
50  "transient",
51  "vertical",
52  "visible"
53 };
54
55 /**
56  * atk_state_type_register:
57  * @name: a character string describing the new state.
58  *
59  * Returns: a #AtkState value for the new state.
60  **/
61 AtkStateType
62 atk_state_type_register (const gchar *name)
63 {
64   static guint type = ATK_STATE_LAST_DEFINED;
65   if (type < NUM_POSSIBLE_STATES)
66   {
67     state_names[++type] = g_strdup (name); 
68     return (type);
69   }
70   return ATK_STATE_INVALID; /* caller needs to check */
71 }
72
73 /**
74  * atk_state_type_get_name:
75  * @type: The #AtkStateType whose name is required
76  *
77  * Returns: the string describing the state
78  */
79 G_CONST_RETURN gchar*
80 atk_state_type_get_name (AtkStateType state)
81 {
82   gint n;
83
84   if (state == 0)
85     return NULL;
86
87   for (n=0; n<NUM_POSSIBLE_STATES; n++)
88   {
89     if (state == n) 
90       return state_names[n];
91   }
92
93   return NULL;
94 }
95
96 /**
97  * atk_state_type_for_name:
98  * @name:
99  *
100  * Returns:
101  */
102 AtkStateType
103 atk_state_type_for_name (const gchar *name)
104 {
105   gint i;
106
107   g_return_val_if_fail (name != NULL, 0);
108   g_return_val_if_fail (strlen (name) > 0, 0);
109
110   for (i = 0; i < NUM_POSSIBLE_STATES; i++)
111   {
112     if (state_names[i] == NULL)
113       continue; 
114     if (!strcmp(name, state_names[i])) 
115       return i;
116   }
117   return 0;
118 }