Add AT-SPI mapping for ATK_RELATION_NODE_PARENT_OF
[platform/core/uifw/at-spi2-atk.git] / cspi / spi-action.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001, 2002 Sun Microsystems Inc.,
6  * Copyright 2001, 2002 Ximian, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 #include <cspi/spi-private.h>
25
26 /**
27  * AccessibleAction_ref:
28  * @obj: a pointer to the #AccessibleAction on which to operate.
29  *
30  * Increment the reference count for an #AccessibleAction.
31  **/
32 void
33 AccessibleAction_ref (AccessibleAction *obj)
34 {
35   cspi_object_ref (obj);
36 }
37
38 /**
39  * AccessibleAction_unref:
40  * @obj: a pointer to the #AccessibleAction on which to operate.
41  *
42  * Decrement the reference count for an #AccessibleAction.
43  **/
44 void
45 AccessibleAction_unref (AccessibleAction *obj)
46 {
47   cspi_object_unref (obj);
48 }
49
50 /**
51  * AccessibleAction_getNActions:
52  * @obj: a pointer to the #AccessibleAction to query.
53  *
54  * Get the number of actions invokable on an #AccessibleAction implementor.
55  *
56  * Returns: a #long integer indicatin the number of invokable actions.
57  **/
58 long
59 AccessibleAction_getNActions (AccessibleAction *obj)
60 {
61   dbus_int32_t retval;
62
63   cspi_return_val_if_fail (obj != NULL, -1);
64
65   cspi_dbus_get_property (obj, spi_interface_action, "nActions", NULL, "i", &retval);
66
67   cspi_return_val_if_ev ("getNActions", -1);
68
69   return retval;
70 }
71
72 /**
73  * AccessibleAction_getDescription:
74  * @obj: a pointer to the #AccessibleAction implementor to query.
75  * @i: a long integer indicating which action to query.
76  *
77  * Get the description of '@i-th' action invokable on an
78  *      object implementing #AccessibleAction.
79  *
80  * Returns: a UTF-8 string describing the '@i-th' invokable action.
81  **/
82 char *
83 AccessibleAction_getDescription (AccessibleAction *obj,
84                                  long int          i)
85 {
86   dbus_int32_t d_i = i;
87   char *retval;
88   cspi_return_val_if_fail (obj != NULL, NULL);
89
90   cspi_dbus_call (obj, spi_interface_action, "getDescription", NULL, "i=>s", d_i, &retval);
91
92   cspi_return_val_if_ev ("getDescription", NULL);
93
94   return retval;
95 }
96
97 /**
98  * AccessibleAction_getKeyBinding:
99  * @obj: a pointer to the #AccessibleAction implementor to query.
100  * @i: a long integer indicating which action to query.
101  *
102  * Get the keybindings for the @i-th action invokable on an
103  *      object implementing #AccessibleAction, if any are defined.
104  *      The keybindings string format is as follows:
105  *        there are multiple parts to a keybinding string (typically 3).
106  *        They are delimited with ";".  The first is the action's
107  *        keybinding which is usable if the object implementing the action
108  *        is currently posted to the screen, e.g. if a menu is posted 
109  *        then these keybindings for the corresponding menu-items are
110  *        available.  The second keybinding substring is the full key sequence
111  *        necessary to post the action's widget and activate it, e.g. for
112  *        a menu item such as "File->Open" it would both post the menu and
113  *        activate the item.  Thus the second keybinding string is available
114  *        during the lifetime of the containing toplevel window as a whole,
115  *        whereas the first keybinding string only works while the object
116  *        implementing AtkAction is posted.  The third (and optional)
117  *        keybinding string is the "keyboard shortcut" which invokes the 
118  *        action without posting any menus. 
119  *        Meta-keys are indicated by the conventional strings
120  *        "<Control>", "<Alt>", "<Shift>", "<Mod2>",
121  *        etc. (we use the same string as gtk_accelerator_name() in 
122  *        gtk+-2.X.
123  *
124  * Returns: a UTF-8 string which can be parsed to determine the @i-th
125  *       invokable action's keybindings.
126  **/
127 char *
128 AccessibleAction_getKeyBinding (AccessibleAction *obj,
129                                 long int          i)
130 {
131   dbus_int32_t d_i = i;
132   char *retval;
133   cspi_return_val_if_fail (obj != NULL, NULL);
134
135   cspi_dbus_call (obj, spi_interface_action, "getKeyBinding", NULL, "i=>s", d_i, &retval);
136
137   cspi_return_val_if_ev ("getKeyBinding", NULL);
138
139   return retval;
140 }
141
142 /**
143  * AccessibleAction_getName:
144  * @obj: a pointer to the #AccessibleAction implementor to query.
145  * @i: a long integer indicating which action to query.
146  *
147  * Get the name of the '@i-th' action invokable on an
148  *      object implementing #AccessibleAction.
149  *
150  * Returns: the 'event type' name of the action, as a UTF-8 string.
151  **/
152 char *
153 AccessibleAction_getName (AccessibleAction *obj,
154                           long int          i)
155 {
156   dbus_int32_t d_i = i;
157   char *retval;
158   cspi_return_val_if_fail (obj != NULL, NULL);
159
160   cspi_dbus_call (obj, spi_interface_action, "getName", NULL, "i=>s", d_i, &retval);
161
162   cspi_return_val_if_ev ("getName", NULL);
163
164   return retval;
165 }
166
167 /**
168  * AccessibleAction_doAction:
169  * @obj: a pointer to the #AccessibleAction to query.
170  * @i: an integer specifying which action to invoke.
171  *
172  * Invoke the action indicated by #index.
173  *
174  * Returns: #TRUE if the action is successfully invoked, otherwise #FALSE.
175  **/
176 SPIBoolean
177 AccessibleAction_doAction (AccessibleAction *obj,
178                            long int i)
179 {
180   dbus_int32_t d_i = i;
181   dbus_bool_t retval;
182
183   cspi_return_val_if_fail (obj != NULL, FALSE);
184
185   cspi_dbus_call (obj, spi_interface_action, "doAction", NULL, "i=>b", d_i, &retval);
186
187   cspi_return_val_if_ev ("doAction", FALSE);
188
189   return retval;
190 }