2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001 Sun Microsystems Inc.
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.
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.
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.
24 * application.c: implements Application.idl
28 #include <bonobo/Bonobo.h>
29 #include <atk/atkutil.h>
32 * This pulls the CORBA definitions for the "Accessibility::Accessible" server
34 #include <libspi/Accessibility.h>
37 * This pulls the definition for the BonoboObject (GObject Type)
39 #include "application.h"
42 * Our parent Gtk object type
44 #define PARENT_TYPE ACCESSIBLE_TYPE
47 * A pointer to our parent object class
49 static AccessibleClass *application_parent_class;
51 Accessibility_EventListener the_toolkit_listener;
54 * Implemented GObject::finalize
57 accessible_application_finalize (GObject *object)
59 /* TODO: any necessary cleanup */
60 Accessible *accessible = ACCESSIBLE (object);
62 g_object_unref (accessible->atko);
63 accessible->atko = NULL;
65 /* TODO: chain to parent class instead */
69 impl_accessibility_application_get_toolkit_name (PortableServer_Servant servant,
70 CORBA_Environment *ev)
73 Application *application = APPLICATION (bonobo_object_from_servant (servant));
74 retval = CORBA_string_dup (atk_get_toolkit_name ());
79 impl_accessibility_application_get_version (PortableServer_Servant servant,
80 CORBA_Environment *ev)
83 Application *application = APPLICATION (bonobo_object_from_servant (servant));
84 retval = CORBA_string_dup (atk_get_toolkit_version ());
89 impl_accessibility_application_get_id (PortableServer_Servant servant,
90 CORBA_Environment *ev)
93 Application *application = APPLICATION (bonobo_object_from_servant (servant));
94 retval = CORBA_string_dup (application->id);
99 impl_accessibility_application_set_id (PortableServer_Servant servant,
100 const CORBA_char *id,
101 CORBA_Environment *ev)
103 Application *application = APPLICATION (bonobo_object_from_servant (servant));
104 application->id = id;
107 #define APP_STATIC_BUFF_SZ 64
110 application_toolkit_listener (GSignalInvocationHint *signal_hint,
111 guint n_param_values,
112 const GValue *param_values,
115 Accessibility_Event *e = g_new0(Accessibility_Event, 1);
118 CORBA_Environment ev;
119 GSignalQuery signal_query;
121 char sbuf[APP_STATIC_BUFF_SZ];
123 g_signal_query (signal_hint->signal_id, &signal_query);
124 name = signal_query.signal_name;
125 fprintf (stderr, "Received signal %s:%s\n", g_type_name (signal_query.itype), name);
127 /* TODO: move GTK dependency out of app.c into bridge */
128 snprintf(sbuf, APP_STATIC_BUFF_SZ, "Gtk:%s:%s", g_type_name (signal_query.itype), name);
131 gobject = g_value_get_object (param_values + 0);
132 /* notify the actual listeners */
133 if (ATK_IS_IMPLEMENTOR (gobject))
135 aobject = atk_implementor_ref_accessible (ATK_IMPLEMENTOR (gobject));
136 e->type = CORBA_string_dup (sbuf);
137 e->source = bonobo_object_corba_objref (bonobo_object (accessible_new (aobject)));
140 Accessibility_EventListener_notifyEvent (the_toolkit_listener, e, &ev);
141 g_object_unref (aobject);
147 impl_accessibility_application_register_toolkit_event_listener (PortableServer_Servant servant,
148 Accessibility_EventListener listener,
149 const CORBA_char *event_name,
150 CORBA_Environment *ev)
154 atk_add_global_event_listener (application_toolkit_listener, event_name);
155 the_toolkit_listener = CORBA_Object_duplicate (listener, ev);
157 fprintf (stderr, "registered %d for toolkit events named: %s\n",
164 application_class_init (ApplicationClass *klass)
166 GObjectClass * object_class = (GObjectClass *) klass;
167 POA_Accessibility_Application__epv *epv = &klass->epv;
169 application_parent_class = g_type_class_ref (ACCESSIBLE_TYPE);
171 object_class->finalize = accessible_application_finalize;
173 epv->_get_toolkitName = impl_accessibility_application_get_toolkit_name;
174 epv->_get_version = impl_accessibility_application_get_version;
175 epv->_get_id = impl_accessibility_application_get_id;
176 epv->_set_id = impl_accessibility_application_set_id;
177 epv->registerToolkitEventListener = impl_accessibility_application_register_toolkit_event_listener;
181 application_init (Application *application)
183 ACCESSIBLE (application)->atko = g_object_new (atk_object_get_type(), NULL);
187 application_get_type (void)
189 static GType type = 0;
192 static const GTypeInfo tinfo = {
193 sizeof (ApplicationClass),
194 (GBaseInitFunc) NULL,
195 (GBaseFinalizeFunc) NULL,
196 (GClassInitFunc) application_class_init,
197 (GClassFinalizeFunc) NULL,
198 NULL, /* class data */
199 sizeof (Application),
201 (GInstanceInitFunc) application_init,
202 NULL /* value table */
205 * Bonobo_type_unique auto-generates a load of
206 * CORBA structures for us. All derived types must
207 * use bonobo_type_unique.
209 type = bonobo_type_unique (
211 POA_Accessibility_Application__init,
213 G_STRUCT_OFFSET (ApplicationClass, epv),
222 application_new (AtkObject *app_root)
224 Application *retval =
225 APPLICATION (g_object_new (application_get_type (), NULL));
226 ACCESSIBLE (retval)->atko = app_root;