Initial revision
[platform/upstream/atk.git] / atk / atkaction.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 "atkaction.h"
21
22 GType
23 atk_action_get_type ()
24 {
25   static GType type = 0;
26
27   if (!type) {
28     GTypeInfo tinfo =
29     {
30       sizeof (AtkActionIface),
31       NULL,
32       NULL,
33
34     };
35
36     type = g_type_register_static (G_TYPE_INTERFACE, "AtkAction", &tinfo, 0);
37   }
38
39   return type;
40 }
41
42 /**
43  * atk_action_do_action:
44  * @value: a GObject instance that implements AtkActionIface
45  * @return: void
46  **/
47 void
48 atk_action_do_action (AtkAction *obj,
49                       gint      i)
50 {
51   AtkActionIface *iface;
52
53   g_return_if_fail (obj != NULL);
54   g_return_if_fail (ATK_IS_ACTION (obj));
55
56   iface = ATK_ACTION_GET_IFACE (obj);
57
58   if (iface->do_action)
59     (iface->do_action) (obj, i);
60 }
61
62 /**
63  * atk_action_get_n_actions:
64  * @value: a GObject instance that implements AtkActionIface
65  * @return: a gint representing the number of actions , or 0
66  * if value does not implement this interface.
67  *
68  * WARNING: callers should not rely on %NULL or on a zero value for
69  * indication of whether GaccessibleActionValue is implemented, they should
70  * use type checking/interface checking macros or the
71  * atk_object_get_action_interface() convenience method.
72  **/
73 gint
74 atk_action_get_n_actions  (AtkAction *obj)
75 {
76   AtkActionIface *iface;
77
78   g_return_val_if_fail (obj != NULL, 0);
79   g_return_val_if_fail (ATK_IS_ACTION (obj), 0);
80
81   iface = ATK_ACTION_GET_IFACE (obj);
82
83   if (iface->get_n_actions)
84     return (iface->get_n_actions) (obj);
85   else
86     return 0;
87 }
88
89 /**
90  * atk_action_get_description:
91  * @value: a GObject instance that implements AtkActionIface
92  * @return: a #gchar representing the description, or %NULL
93  * if value does not implement this interface.
94  *
95  * WARNING: callers should not rely on %NULL or on a zero value for
96  * indication of whether GaccessibleValue is implemented, they should
97  * use type checking/interface checking macros or the
98  * atk_object_get_action_interface() convenience method.
99  **/
100 G_CONST_RETURN gchar*
101 atk_action_get_description (AtkAction *obj,
102                             gint      i)
103 {
104   AtkActionIface *iface;
105
106   g_return_val_if_fail (obj != NULL, NULL);
107   g_return_val_if_fail (ATK_IS_ACTION (obj), NULL);
108
109   iface = ATK_ACTION_GET_IFACE (obj);
110
111   if (iface->get_description)
112     return (iface->get_description) (obj, i);
113   else
114     return NULL;
115 }
116
117 /**
118  * atk_action_get_keybinding:
119  * @value: a GObject instance that implements AtkActionIface
120  * @return: a #gchar representing the keybinding, or %NULL
121  * if there is no keybinding for this action.
122  *
123  **/
124 G_CONST_RETURN gchar*
125 atk_action_get_keybinding (AtkAction *obj,
126                            gint      i)
127 {
128   AtkActionIface *iface;
129
130   g_return_val_if_fail (obj != NULL, NULL);
131   g_return_val_if_fail (ATK_IS_ACTION (obj), NULL);
132
133   iface = ATK_ACTION_GET_IFACE (obj);
134
135   if (iface->get_keybinding)
136     return (iface->get_keybinding) (obj, i);
137   else
138     return NULL;
139 }