Started fixing IDL docs.
[platform/core/uifw/at-spi2-atk.git] / libspi / 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 Sun Microsystems Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 /* component.c : bonobo wrapper for accessible component implementation */
24
25 #include <config.h>
26 #include <stdio.h>
27 #include <libspi/action.h>
28
29 /*
30  * Static function declarations
31  */
32
33 static void
34 spi_action_class_init (SpiActionClass *klass);
35 static void
36 spi_action_init (SpiAction *action);
37 static void
38 spi_action_finalize (GObject *obj);
39 static CORBA_long
40 impl__get_nActions(PortableServer_Servant servant,
41                  CORBA_Environment * ev);
42 static CORBA_string
43 impl_getDescription (PortableServer_Servant servant,
44                      const CORBA_long index,
45                      CORBA_Environment * ev);
46 static CORBA_boolean 
47 impl_doAction (PortableServer_Servant servant,
48                const CORBA_long index, CORBA_Environment * ev);
49 static CORBA_string
50 impl_getName (PortableServer_Servant servant,
51               const CORBA_long index,
52               CORBA_Environment * ev);
53 static CORBA_string
54 impl_getKeyBinding (PortableServer_Servant servant,
55                     const CORBA_long index,
56                     CORBA_Environment * ev);
57
58 static GObjectClass *parent_class;
59
60 BONOBO_TYPE_FUNC_FULL (SpiAction,
61                        Accessibility_Action,
62                        BONOBO_TYPE_OBJECT,
63                        spi_action);
64
65 static void
66 spi_action_class_init (SpiActionClass *klass)
67 {
68   GObjectClass * object_class = (GObjectClass *) klass;
69   POA_Accessibility_Action__epv *epv = &klass->epv;
70   parent_class = g_type_class_peek_parent (klass);
71
72   object_class->finalize = spi_action_finalize;
73
74
75   /* Initialize epv table */
76
77   epv->_get_nActions = impl__get_nActions;
78   epv->doAction = impl_doAction;
79   epv->getDescription = impl_getDescription;
80   epv->getName = impl_getName;
81   epv->getKeyBinding = impl_getKeyBinding;
82 }
83
84 static void
85 spi_action_init (SpiAction *action)
86 {
87 }
88
89 static void
90 spi_action_finalize (GObject *obj)
91 {
92   SpiAction *action = SPI_ACTION (obj);
93   g_object_unref (action->atko);
94   action->atko = NULL;
95   parent_class->finalize (obj);
96 }
97
98 SpiAction *
99 spi_action_interface_new (AtkObject *obj)
100 {
101   SpiAction *new_action = g_object_new (SPI_ACTION_TYPE, NULL);
102   new_action->atko = obj;
103   g_object_ref (obj);
104   return new_action;
105 }
106
107 static CORBA_long
108 impl__get_nActions(PortableServer_Servant servant,
109             CORBA_Environment * ev)
110 {
111   SpiAction *action = SPI_ACTION (bonobo_object_from_servant(servant));
112   return (CORBA_long) atk_action_get_n_actions (ATK_ACTION(action->atko));
113 }
114
115 static CORBA_boolean
116 impl_doAction (PortableServer_Servant servant,
117                const CORBA_long index, CORBA_Environment * ev)
118 {
119   SpiAction *action = SPI_ACTION (bonobo_object_from_servant (servant));
120   return (CORBA_boolean) atk_action_do_action (ATK_ACTION(action->atko), (gint) index);
121 }
122
123
124 static CORBA_string
125 impl_getDescription (PortableServer_Servant servant,
126                 const CORBA_long index,
127                 CORBA_Environment * ev)
128 {
129   SpiAction *action = SPI_ACTION (bonobo_object_from_servant(servant));
130   const gchar *rv;
131   
132   rv = atk_action_get_description (ATK_ACTION(action->atko), (gint) index);
133   if (rv)
134     return CORBA_string_dup (rv);
135   else
136     return CORBA_string_dup ("");
137 }
138
139
140 static CORBA_string
141 impl_getName (PortableServer_Servant servant,
142                 const CORBA_long index,
143                 CORBA_Environment * ev)
144 {
145   SpiAction *action = SPI_ACTION (bonobo_object_from_servant(servant));
146   const gchar *rv;
147   
148   rv = atk_action_get_name (ATK_ACTION(action->atko), (gint) index);
149   if (rv)
150     return CORBA_string_dup (rv);
151   else
152     return CORBA_string_dup ("");
153 }
154
155 static CORBA_string
156 impl_getKeyBinding (PortableServer_Servant servant,
157                     const CORBA_long index,
158                     CORBA_Environment * ev)
159 {
160   SpiAction *action = SPI_ACTION (bonobo_object_from_servant(servant));
161   const gchar *rv;
162   
163   rv = atk_action_get_keybinding (ATK_ACTION(action->atko), (gint) index);
164   if (rv)
165     return CORBA_string_dup (rv);
166   else
167     return CORBA_string_dup ("");
168 }