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 | /* component.c : bonobo wrapper for accessible component implementation */ |
---|
25 | |
---|
26 | #include <config.h> |
---|
27 | #include <stdio.h> |
---|
28 | #include <libspi/action.h> |
---|
29 | #include <atk/atkaction.h> |
---|
30 | |
---|
31 | /* |
---|
32 | * Static function declarations |
---|
33 | */ |
---|
34 | |
---|
35 | static void |
---|
36 | spi_action_class_init (SpiActionClass *klass); |
---|
37 | static void |
---|
38 | spi_action_init (SpiAction *action); |
---|
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 | BONOBO_TYPE_FUNC_FULL (SpiAction, |
---|
59 | Accessibility_Action, |
---|
60 | SPI_TYPE_BASE, |
---|
61 | spi_action); |
---|
62 | |
---|
63 | static void |
---|
64 | spi_action_class_init (SpiActionClass *klass) |
---|
65 | { |
---|
66 | POA_Accessibility_Action__epv *epv = &klass->epv; |
---|
67 | |
---|
68 | /* Initialize epv table */ |
---|
69 | |
---|
70 | epv->_get_nActions = impl__get_nActions; |
---|
71 | epv->doAction = impl_doAction; |
---|
72 | epv->getDescription = impl_getDescription; |
---|
73 | epv->getName = impl_getName; |
---|
74 | epv->getKeyBinding = impl_getKeyBinding; |
---|
75 | } |
---|
76 | |
---|
77 | static void |
---|
78 | spi_action_init (SpiAction *action) |
---|
79 | { |
---|
80 | } |
---|
81 | |
---|
82 | SpiAction * |
---|
83 | spi_action_interface_new (AtkObject *obj) |
---|
84 | { |
---|
85 | SpiAction *new_action = g_object_new (SPI_ACTION_TYPE, NULL); |
---|
86 | |
---|
87 | spi_base_construct (SPI_BASE (new_action), G_OBJECT(obj)); |
---|
88 | |
---|
89 | return new_action; |
---|
90 | } |
---|
91 | |
---|
92 | static AtkAction * |
---|
93 | get_action_from_servant (PortableServer_Servant servant) |
---|
94 | { |
---|
95 | SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant)); |
---|
96 | g_return_val_if_fail (object != NULL, NULL); |
---|
97 | g_return_val_if_fail (ATK_IS_OBJECT(object->gobj), NULL); |
---|
98 | return ATK_ACTION (object->gobj); |
---|
99 | } |
---|
100 | |
---|
101 | static CORBA_long |
---|
102 | impl__get_nActions (PortableServer_Servant servant, |
---|
103 | CORBA_Environment *ev) |
---|
104 | { |
---|
105 | AtkAction *action = get_action_from_servant (servant); |
---|
106 | return atk_action_get_n_actions (action); |
---|
107 | } |
---|
108 | |
---|
109 | static CORBA_boolean |
---|
110 | impl_doAction (PortableServer_Servant servant, |
---|
111 | const CORBA_long index, CORBA_Environment * ev) |
---|
112 | { |
---|
113 | AtkAction *action = get_action_from_servant (servant); |
---|
114 | return atk_action_do_action (action, (gint) index); |
---|
115 | } |
---|
116 | |
---|
117 | static CORBA_string |
---|
118 | impl_getDescription (PortableServer_Servant servant, |
---|
119 | const CORBA_long index, |
---|
120 | CORBA_Environment * ev) |
---|
121 | { |
---|
122 | AtkAction *action = get_action_from_servant (servant); |
---|
123 | const gchar *rv; |
---|
124 | |
---|
125 | rv = atk_action_get_description (action, index); |
---|
126 | if (rv) |
---|
127 | return CORBA_string_dup (rv); |
---|
128 | else |
---|
129 | return CORBA_string_dup (""); |
---|
130 | } |
---|
131 | |
---|
132 | static CORBA_string |
---|
133 | impl_getName (PortableServer_Servant servant, |
---|
134 | const CORBA_long index, |
---|
135 | CORBA_Environment * ev) |
---|
136 | { |
---|
137 | AtkAction *action = get_action_from_servant (servant); |
---|
138 | const gchar *rv; |
---|
139 | |
---|
140 | rv = atk_action_get_name (action, index); |
---|
141 | if (rv) |
---|
142 | return CORBA_string_dup (rv); |
---|
143 | else |
---|
144 | return CORBA_string_dup (""); |
---|
145 | } |
---|
146 | |
---|
147 | static CORBA_string |
---|
148 | impl_getKeyBinding (PortableServer_Servant servant, |
---|
149 | const CORBA_long index, |
---|
150 | CORBA_Environment * ev) |
---|
151 | { |
---|
152 | AtkAction *action = get_action_from_servant (servant); |
---|
153 | const gchar *rv; |
---|
154 | |
---|
155 | rv = atk_action_get_keybinding (action, index); |
---|
156 | if (rv) |
---|
157 | return CORBA_string_dup (rv); |
---|
158 | else |
---|
159 | return CORBA_string_dup (""); |
---|
160 | } |
---|