2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002, 2003 Sun Microsystems Inc.,
6 * Copyright 2001, 2002, 2003 Ximian, Inc.
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.
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.
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.
28 #include <libbonobo.h>
29 #include <orbit/orbit.h>
31 #include <atk/atkobject.h>
32 #include <atk/atknoopobject.h>
33 #include <libspi/Accessibility.h>
34 #include <libspi/spi-private.h>
35 #include "accessible.h"
36 #include "application.h"
38 #include <bonobo-activation/bonobo-activation-register.h>
40 #undef SPI_BRIDGE_DEBUG
42 #define DBG(a,b) if(_dbg>=(a))b
45 static CORBA_Environment ev;
46 static Accessibility_Registry registry = CORBA_OBJECT_NIL;
47 static Accessibility_DeviceEventController device_event_controller = CORBA_OBJECT_NIL;
48 static SpiApplication *this_app = NULL;
49 static gboolean registry_died = FALSE;
50 static gboolean atk_listeners_registered = FALSE;
51 static gint toplevels = 0;
53 static guint atk_signal_text_changed;
54 static guint atk_signal_children_changed;
55 static guint atk_signal_active_descendant_changed;
56 static guint atk_signal_text_selection_changed;
59 static guint atk_signal_row_reordered;
60 static guint atk_signal_row_inserted;
61 static guint atk_signal_row_deleted;
62 static guint atk_signal_column_reordered;
63 static guint atk_signal_column_inserted;
64 static guint atk_signal_column_deleted;
67 static guint atk_signal_link_selected;
69 static Accessibility_Registry spi_atk_bridge_get_registry (void);
70 static void spi_atk_bridge_do_registration (void);
71 static void spi_atk_bridge_toplevel_added (AtkObject *object,
74 static void spi_atk_bridge_toplevel_removed (AtkObject *object,
78 static void spi_atk_bridge_exit_func (void);
79 static void spi_atk_register_event_listeners (void);
80 static void spi_atk_deregister_event_listeners (void);
81 static void spi_atk_bridge_focus_tracker (AtkObject *object);
82 static void spi_atk_bridge_register_application (Accessibility_Registry registry);
83 static gboolean spi_atk_bridge_property_event_listener (GSignalInvocationHint *signal_hint,
85 const GValue *param_values,
88 spi_atk_bridge_window_event_listener (GSignalInvocationHint *signal_hint,
90 const GValue *param_values,
93 spi_atk_bridge_state_event_listener (GSignalInvocationHint *signal_hint,
95 const GValue *param_values,
97 static gboolean spi_atk_bridge_signal_listener (GSignalInvocationHint *signal_hint,
99 const GValue *param_values,
101 static gint spi_atk_bridge_key_listener (AtkKeyEventStruct *event,
103 static void spi_atk_tidy_windows (void);
104 static void deregister_application (BonoboObject *app);
105 static void reinit_register_vars (void);
107 /* For automatic libgnome init */
108 extern void gnome_accessibility_module_init (void);
109 extern void gnome_accessibility_module_shutdown (void);
111 static int atk_bridge_initialized = FALSE;
112 static guint atk_bridge_focus_tracker_id = 0;
113 static guint atk_bridge_key_event_listener_id = 0;
114 static GArray *listener_ids = NULL;
117 * These exported symbols are hooked by gnome-program
118 * to provide automatic module initialization and shutdown.
120 extern void gnome_accessibility_module_init (void);
121 extern void gnome_accessibility_module_shutdown (void);
124 spi_atk_bridge_init_event_type_consts ()
126 static gboolean done = FALSE;
131 atk_signal_children_changed = g_signal_lookup ("children_changed",
133 atk_signal_text_changed = g_signal_lookup ("text_changed",
135 atk_signal_active_descendant_changed =
136 g_signal_lookup ("active_descendant_changed",
138 atk_signal_link_selected = g_signal_lookup ("link_selected",
140 atk_signal_text_selection_changed = g_signal_lookup ("text_selection_changed",
146 atk_bridge_init (gint *argc, gchar **argv[])
148 const char *debug_env_string = g_getenv ("AT_SPI_DEBUG");
150 if (atk_bridge_initialized)
154 atk_bridge_initialized = TRUE;
156 if (debug_env_string)
157 _dbg = (int) g_ascii_strtod (debug_env_string, NULL);
159 if (!bonobo_init (argc, argv ? *argv : NULL))
161 g_error ("Could not initialize Bonobo");
165 * We only want to enable the bridge for top level
166 * applications, we detect bonobo components by seeing
167 * if they were activated with the intention of extracting
168 * an impl. by IID - very solid.
170 if (bonobo_activation_iid_get ())
172 DBG (1, g_message ("Found Bonobo component\n"));
173 g_signal_connect (atk_get_root (),
174 "children-changed::add",
175 (GCallback) spi_atk_bridge_toplevel_added,
177 g_signal_connect (atk_get_root (),
178 "children-changed::remove",
179 (GCallback) spi_atk_bridge_toplevel_removed,
184 spi_atk_bridge_do_registration ();
185 spi_atk_bridge_init_event_type_consts ();
193 spi_atk_bridge_do_registration (void)
195 CORBA_Environment ev;
197 CORBA_exception_init(&ev);
199 if (spi_atk_bridge_get_registry () == CORBA_OBJECT_NIL)
201 g_error ("Could not locate registry");
206 /* Create the accessible application server object */
208 this_app = spi_application_new (atk_get_root ());
210 DBG (1, g_message ("About to register application\n"));
212 spi_atk_bridge_register_application (spi_atk_bridge_get_registry ());
214 g_atexit (spi_atk_bridge_exit_func);
216 DBG (1, g_message ("Application registered & listening\n"));
221 spi_atk_bridge_toplevel_added (AtkObject *object,
227 spi_atk_bridge_do_registration ();
228 spi_atk_bridge_init_event_type_consts ();
234 spi_atk_bridge_toplevel_removed (AtkObject *object,
238 BonoboObject *app = (BonoboObject *) this_app;
243 deregister_application (app);
244 spi_atk_deregister_event_listeners ();
245 reinit_register_vars ();
249 g_warning ("More toplevels removed than added\n");
255 spi_atk_bridge_register_application (Accessibility_Registry registry)
257 Accessibility_Registry_registerApplication (spi_atk_bridge_get_registry (),
258 BONOBO_OBJREF (this_app),
260 spi_atk_register_event_listeners ();
263 static Accessibility_Registry
264 spi_atk_bridge_get_registry (void)
266 CORBA_Environment ev;
268 if (registry_died || (registry == CORBA_OBJECT_NIL)) {
269 CORBA_exception_init (&ev);
271 DBG (1, g_warning ("registry died! restarting..."));
272 registry = bonobo_activation_activate_from_id (
273 "OAFIID:Accessibility_Registry:1.0", 0, NULL, &ev);
275 if (ev._major != CORBA_NO_EXCEPTION)
277 g_error ("Accessibility app error: exception during "
278 "registry activation from id: %s\n",
279 CORBA_exception_id (&ev));
280 CORBA_exception_free (&ev);
283 if (registry_died && registry) {
284 registry_died = FALSE;
285 spi_atk_bridge_register_application (registry);
291 static Accessibility_DeviceEventController
292 spi_atk_bridget_get_dec (void)
294 CORBA_Environment ev;
296 if (device_event_controller != CORBA_OBJECT_NIL)
298 if (ORBit_small_get_connection_status (device_event_controller)
299 == ORBIT_CONNECTION_CONNECTED)
300 return device_event_controller;
303 CORBA_exception_init (&ev);
305 device_event_controller =
306 Accessibility_Registry_getDeviceEventController (
307 spi_atk_bridge_get_registry (), &ev);
311 g_warning (_("failure: no device event controller found.\n"));
312 registry_died = TRUE;
313 device_event_controller = CORBA_OBJECT_NIL;
316 return device_event_controller;
320 gtk_module_init (gint *argc, gchar **argv[])
322 return atk_bridge_init (argc, argv);
326 add_signal_listener (const char *signal_name)
330 id = atk_add_global_event_listener (
331 spi_atk_bridge_signal_listener, signal_name);
333 g_array_append_val (listener_ids, id);
337 spi_atk_register_event_listeners (void)
340 * kludge to make sure the Atk interface types are registered, otherwise
341 * the AtkText signal handlers below won't get registered
344 GObject *ao = g_object_new (ATK_TYPE_OBJECT, NULL);
345 AtkObject *bo = atk_no_op_object_new (ao);
348 if (atk_listeners_registered) return;
350 atk_listeners_registered = TRUE;
352 /* Register for focus event notifications, and register app with central registry */
354 listener_ids = g_array_sized_new (FALSE, TRUE, sizeof (guint), 16);
356 atk_bridge_focus_tracker_id = atk_add_focus_tracker (spi_atk_bridge_focus_tracker);
358 id = atk_add_global_event_listener (spi_atk_bridge_property_event_listener,
359 "Gtk:AtkObject:property-change");
360 g_array_append_val (listener_ids, id);
361 id = atk_add_global_event_listener (spi_atk_bridge_window_event_listener,
363 g_array_append_val (listener_ids, id);
364 id = atk_add_global_event_listener (spi_atk_bridge_window_event_listener,
366 g_array_append_val (listener_ids, id);
367 id = atk_add_global_event_listener (spi_atk_bridge_window_event_listener,
369 g_array_append_val (listener_ids, id);
370 id = atk_add_global_event_listener (spi_atk_bridge_window_event_listener,
372 g_array_append_val (listener_ids, id);
373 id = atk_add_global_event_listener (spi_atk_bridge_window_event_listener,
375 g_array_append_val (listener_ids, id);
376 id = atk_add_global_event_listener (spi_atk_bridge_window_event_listener,
378 g_array_append_val (listener_ids, id);
379 id = atk_add_global_event_listener (spi_atk_bridge_window_event_listener,
380 "window:deactivate");
381 g_array_append_val (listener_ids, id);
382 id = atk_add_global_event_listener (spi_atk_bridge_state_event_listener,
383 "Gtk:AtkObject:state-change");
384 g_array_append_val (listener_ids, id);
386 add_signal_listener ("Gtk:AtkObject:children-changed");
387 add_signal_listener ("Gtk:AtkObject:visible-data-changed");
388 add_signal_listener ("Gtk:AtkObject:active-descendant-changed");
389 add_signal_listener ("Gtk:AtkSelection:selection-changed");
390 add_signal_listener ("Gtk:AtkText:text-selection-changed");
391 add_signal_listener ("Gtk:AtkText:text-changed");
392 add_signal_listener ("Gtk:AtkText:text-caret-moved");
393 add_signal_listener ("Gtk:AtkTable:row-inserted");
394 add_signal_listener ("Gtk:AtkTable:row-reordered");
395 add_signal_listener ("Gtk:AtkTable:row-deleted");
396 add_signal_listener ("Gtk:AtkTable:column-inserted");
397 add_signal_listener ("Gtk:AtkTable:column-reordered");
398 add_signal_listener ("Gtk:AtkTable:column-deleted");
399 add_signal_listener ("Gtk:AtkTable:model-changed");
400 add_signal_listener ("Gtk:AtkHypertext:link-selected");
402 * May add the following listeners to implement preemptive key listening for GTK+
404 * atk_add_global_event_listener (spi_atk_bridge_widgetkey_listener, "Gtk:GtkWidget:key-press-event");
405 * atk_add_global_event_listener (spi_atk_bridge_widgetkey_listener, "Gtk:GtkWidget:key-release-event");
407 atk_bridge_key_event_listener_id = atk_add_key_event_listener (
408 spi_atk_bridge_key_listener, NULL);
410 g_object_unref (G_OBJECT (bo));
415 spi_atk_deregister_event_listeners (void)
420 if (!atk_listeners_registered)
423 atk_listeners_registered = FALSE;
425 for (i = 0; i < listener_ids->len; i++)
427 id = g_array_index (listener_ids, guint, i);
428 atk_remove_global_event_listener (id);
430 g_array_free (listener_ids, TRUE);
433 atk_remove_focus_tracker (atk_bridge_focus_tracker_id);
434 atk_bridge_focus_tracker_id = 0;
436 atk_remove_key_event_listener (atk_bridge_key_event_listener_id);
437 atk_bridge_key_event_listener_id = 0;
441 deregister_application (BonoboObject *app)
443 Accessibility_Registry registry = spi_atk_bridge_get_registry ();
444 Accessibility_Registry_deregisterApplication (registry, BONOBO_OBJREF (app), &ev);
446 device_event_controller = bonobo_object_release_unref (device_event_controller, &ev);
447 registry = bonobo_object_release_unref (registry, &ev);
449 app = bonobo_object_unref (app);
453 spi_atk_bridge_exit_func (void)
455 BonoboObject *app = (BonoboObject *) this_app;
457 DBG (1, g_message ("exiting bridge\n"));
466 * Check whether we still have windows which have not been deleted.
468 spi_atk_tidy_windows ();
470 * FIXME: this may be incorrect for apps that do their own bonobo
471 * shutdown, until we can explicitly shutdown to get the ordering
474 if (!bonobo_is_initialized ())
476 DBG (1, g_warning ("Re-initializing bonobo\n"));
477 g_assert (bonobo_init (0, NULL));
478 g_assert (bonobo_activate ());
481 deregister_application (app);
483 DBG (1, g_message ("bridge exit func complete.\n"));
485 if (g_getenv ("AT_BRIDGE_SHUTDOWN"))
487 g_assert (!bonobo_debug_shutdown ());
492 gnome_accessibility_module_init (void)
494 atk_bridge_init (NULL, NULL);
496 g_print("Atk Accessibilty bridge initialized\n");
500 gnome_accessibility_module_shutdown (void)
502 BonoboObject *app = (BonoboObject *) this_app;
504 GArray *ids = listener_ids;
506 if (!atk_bridge_initialized)
510 atk_bridge_initialized = FALSE;
513 g_print("Atk Accessibilty bridge shutdown\n");
516 atk_remove_focus_tracker (atk_bridge_focus_tracker_id);
518 for (i = 0; ids && i < ids->len; i++)
520 atk_remove_global_event_listener (g_array_index (ids, guint, i));
523 atk_remove_key_event_listener (atk_bridge_key_event_listener_id);
525 deregister_application (app);
529 spi_atk_bridge_focus_tracker (AtkObject *object)
531 SpiAccessible *source;
532 Accessibility_Event e;
534 source = spi_accessible_new (object);
537 e.source = BONOBO_OBJREF (source);
540 spi_init_any_nil (&e.any_data);
542 CORBA_exception_init (&ev);
543 Accessibility_Registry_notifyEvent (spi_atk_bridge_get_registry (), &e, &ev);
545 registry_died = TRUE;
547 bonobo_object_unref (source);
549 CORBA_exception_free (&ev);
553 spi_atk_emit_eventv (const GObject *gobject,
557 const char *format, ...)
560 Accessibility_Event e;
561 SpiAccessible *source;
563 #ifdef SPI_BRIDGE_DEBUG
567 va_start (args, format);
569 if (ATK_IS_IMPLEMENTOR (gobject))
571 aobject = atk_implementor_ref_accessible (ATK_IMPLEMENTOR (gobject));
572 source = spi_accessible_new (aobject);
573 g_object_unref (G_OBJECT (aobject));
575 else if (ATK_IS_OBJECT (gobject))
577 aobject = ATK_OBJECT (gobject);
578 source = spi_accessible_new (aobject);
584 DBG (0, g_warning ("received property-change event from non-AtkImplementor"));
589 e.type = g_strdup_vprintf (format, args);
590 e.source = BONOBO_OBJREF (source);
593 if (any) e.any_data = *any;
594 else spi_init_any_nil (&e.any_data);
596 #ifdef SPI_BRIDGE_DEBUG
597 s = Accessibility_Accessible__get_name (BONOBO_OBJREF (source), &ev);
598 g_warning ("Emitting event '%s' (%lu, %lu) on %s",
599 e.type, e.detail1, e.detail2, s);
602 CORBA_exception_init (&ev);
603 Accessibility_Registry_notifyEvent (spi_atk_bridge_get_registry (),
605 #ifdef SPI_BRIDGE_DEBUG
606 if (ev._major != CORBA_NO_EXCEPTION)
607 g_warning ("error emitting event %s, (%d) %s",
610 CORBA_exception_id(&ev));
612 if (BONOBO_EX (&ev)) registry_died = TRUE;
613 Accessibility_Accessible_unref (e.source, &ev);
615 CORBA_exception_free (&ev);
625 spi_atk_bridge_property_event_listener (GSignalInvocationHint *signal_hint,
626 guint n_param_values,
627 const GValue *param_values,
630 AtkPropertyValues *values;
632 const gchar *prop_name;
634 const gchar *sp = NULL;
636 SpiAccessible *s_ao = NULL;
640 #ifdef SPI_BRIDGE_DEBUG
641 GSignalQuery signal_query;
645 g_signal_query (signal_hint->signal_id, &signal_query);
646 name = signal_query.signal_name;
648 s2 = g_type_name (G_OBJECT_TYPE (g_value_get_object (param_values + 0)));
649 s = atk_object_get_name (ATK_OBJECT (g_value_get_object (param_values + 0)));
650 values = (AtkPropertyValues*) g_value_get_pointer (param_values + 1);
651 DBG (2, g_message ("Received (property) signal %s:%s:%s from object %s (gail %s)\n",
652 g_type_name (signal_query.itype), name, values->property_name, s, s2));
656 gobject = g_value_get_object (param_values + 0);
657 values = (AtkPropertyValues*) g_value_get_pointer (param_values + 1);
659 prop_name = values->property_name;
660 if (strcmp (prop_name, "accessible-name") == 0)
662 sp = atk_object_get_name (ATK_OBJECT (gobject));
663 spi_init_any_string (&any, (gchar **)&sp);
665 else if (strcmp (prop_name, "accessible-description") == 0)
667 sp = atk_object_get_description (ATK_OBJECT (gobject));
668 spi_init_any_string (&any, (gchar **)&sp);
670 else if (strcmp (prop_name, "accessible-parent") == 0)
672 ao = atk_object_get_parent (ATK_OBJECT (gobject));
675 s_ao = spi_accessible_new (ao);
676 c_obj = BONOBO_OBJREF (s_ao);
677 spi_init_any_object (&any, &c_obj);
681 spi_init_any_nil (&any);
684 else if (strcmp (prop_name, "accessible-table-summary") == 0)
686 ao = atk_table_get_summary (ATK_TABLE (gobject));
689 s_ao = spi_accessible_new (ao);
690 c_obj = BONOBO_OBJREF (s_ao);
691 spi_init_any_object (&any, &c_obj);
695 spi_init_any_nil (&any);
698 else if (strcmp (prop_name, "accessible-table-column-header") == 0)
700 i = g_value_get_int (&(values->new_value));
701 ao = atk_table_get_column_header (ATK_TABLE (gobject), i);
704 s_ao = spi_accessible_new (ao);
705 c_obj = BONOBO_OBJREF (s_ao);
706 spi_init_any_object (&any, &c_obj);
710 spi_init_any_nil (&any);
713 else if (strcmp (prop_name, "accessible-table-row-header") == 0)
715 i = g_value_get_int (&(values->new_value));
716 ao = atk_table_get_row_header (ATK_TABLE (gobject), i);
719 s_ao = spi_accessible_new (ao);
720 c_obj = BONOBO_OBJREF (s_ao);
721 spi_init_any_object (&any, &c_obj);
725 spi_init_any_nil (&any);
728 else if (strcmp (prop_name, "accessible-table-row-description") == 0)
730 i = g_value_get_int (&(values->new_value));
731 sp = atk_table_get_row_description (ATK_TABLE (gobject), i);
732 spi_init_any_string (&any, (gchar **)&sp);
734 else if (strcmp (prop_name, "accessible-table-column-description") == 0)
736 i = g_value_get_int (&(values->new_value));
737 sp = atk_table_get_column_description (ATK_TABLE (gobject), i);
738 spi_init_any_string (&any, (gchar **)&sp);
740 else if (strcmp (prop_name, "accessible-table-caption-object") == 0)
742 ao = atk_table_get_caption (ATK_TABLE (gobject));
743 sp = atk_object_get_name (ao);
744 spi_init_any_string (&any, (gchar **)&sp);
748 spi_init_any_nil (&any);
751 spi_atk_emit_eventv (gobject, 0, 0, &any,
752 "object:property-change:%s", prop_name);
759 spi_atk_bridge_state_event_listener (GSignalInvocationHint *signal_hint,
760 guint n_param_values,
761 const GValue *param_values,
765 gchar *property_name;
767 unsigned long detail1;
768 #ifdef SPI_BRIDGE_DEBUG
769 GSignalQuery signal_query;
772 g_signal_query (signal_hint->signal_id, &signal_query);
773 name = signal_query.signal_name;
774 fprintf (stderr, "Received (state) signal %s:%s\n",
775 g_type_name (signal_query.itype), name);
778 gobject = g_value_get_object (param_values + 0);
779 property_name = g_strdup (g_value_get_string (param_values + 1));
780 detail1 = (g_value_get_boolean (param_values + 2))
782 type = g_strdup_printf ("object:state-changed:%s", property_name);
783 spi_atk_emit_eventv (gobject,
788 g_free (property_name);
794 spi_init_keystroke_from_atk_key_event (Accessibility_DeviceEvent *keystroke,
795 AtkKeyEventStruct *event)
800 g_print ("event %c (%d)\n", (int) event->keyval, (int) event->keycode);
806 g_print (_("WARNING: NULL key event reported."));
809 keystroke->id = (CORBA_long) event->keyval;
810 keystroke->hw_code = (CORBA_short) event->keycode;
811 keystroke->timestamp = (CORBA_unsigned_long) event->timestamp;
812 keystroke->modifiers = (CORBA_unsigned_short) (event->state & 0xFFFF);
817 keystroke->event_string = CORBA_string_dup (event->string);
818 c = g_utf8_get_char_validated (event->string, -1);
819 if (c > 0 && g_unichar_isprint (c))
820 keystroke->is_text = CORBA_TRUE;
822 keystroke->is_text = CORBA_FALSE;
826 keystroke->event_string = CORBA_string_dup ("");
827 keystroke->is_text = CORBA_FALSE;
831 case (ATK_KEY_EVENT_PRESS):
832 keystroke->type = Accessibility_KEY_PRESSED_EVENT;
834 case (ATK_KEY_EVENT_RELEASE):
835 keystroke->type = Accessibility_KEY_RELEASED_EVENT;
842 g_print ("key_event type %d; val=%d code=%d modifiers=%x name=%s is_text=%d, time=%lx\n",
843 (int) keystroke->type, (int) keystroke->id, (int) keystroke->hw_code,
844 (int) keystroke->modifiers,
845 keystroke->event_string, (int) keystroke->is_text, (unsigned long) keystroke->timestamp);
850 spi_atk_bridge_key_listener (AtkKeyEventStruct *event, gpointer data)
852 CORBA_boolean result;
853 Accessibility_DeviceEvent key_event;
855 CORBA_exception_init (&ev);
857 spi_init_keystroke_from_atk_key_event (&key_event, event);
859 result = Accessibility_DeviceEventController_notifyListenersSync (
860 spi_atk_bridget_get_dec (), &key_event, &ev);
862 CORBA_exception_free (&ev);
868 spi_atk_bridge_signal_listener (GSignalInvocationHint *signal_hint,
869 guint n_param_values,
870 const GValue *param_values,
874 GSignalQuery signal_query;
882 gint detail1 = 0, detail2 = 0;
883 SpiAccessible *s_ao = NULL;
884 #ifdef SPI_BRIDGE_DEBUG
888 g_signal_query (signal_hint->signal_id, &signal_query);
890 name = signal_query.signal_name;
891 if (signal_hint->detail)
892 detail = g_quark_to_string (signal_hint->detail);
896 #ifdef SPI_BRIDGE_DEBUG
897 s2 = g_type_name (G_OBJECT_TYPE (g_value_get_object (param_values + 0)));
898 s = atk_object_get_name (ATK_OBJECT (g_value_get_object (param_values + 0)));
899 fprintf (stderr, "Received signal %s:%s detail: %s from object %s (gail %s)\n",
900 g_type_name (signal_query.itype), name,
901 detail ? detail : "<NULL>", s ? s : "<NULL>" , s2);
904 gobject = g_value_get_object (param_values + 0);
906 if (signal_query.signal_id == atk_signal_active_descendant_changed)
908 gpointer child = g_value_get_pointer (param_values + 1);
910 g_return_val_if_fail (ATK_IS_OBJECT (child), TRUE);
912 ao = ATK_OBJECT (child);
914 detail1 = atk_object_get_index_in_parent (ao);
915 s_ao = spi_accessible_new (ao);
916 c_obj = BONOBO_OBJREF (s_ao);
917 spi_init_any_object (&any, &c_obj);
919 else if (signal_query.signal_id == atk_signal_link_selected)
921 if (G_VALUE_TYPE (param_values + 1) == G_TYPE_INT)
922 detail1 = g_value_get_int (param_values + 1);
923 spi_init_any_nil (&any);
925 else if ((signal_query.signal_id == atk_signal_children_changed) && gobject)
927 ao = atk_object_ref_accessible_child (ATK_OBJECT (gobject),
931 s_ao = spi_accessible_new (ao);
932 c_obj = BONOBO_OBJREF (s_ao);
933 spi_init_any_object (&any, &c_obj);
938 spi_init_any_nil (&any);
943 if (n_param_values >= 2)
945 if (G_VALUE_TYPE (param_values + 1) == G_TYPE_INT)
946 detail1 = g_value_get_int (param_values + 1);
947 if (n_param_values >= 3)
949 if (G_VALUE_TYPE (param_values + 2) == G_TYPE_INT)
950 detail2 = g_value_get_int (param_values + 2);
954 if (signal_query.signal_id == atk_signal_text_changed)
956 sp = atk_text_get_text (ATK_TEXT (gobject),
959 spi_init_any_string (&any, &sp);
961 else if (signal_query.signal_id == atk_signal_text_selection_changed)
963 text = ATK_TEXT (gobject);
965 /* Return NULL as the selected string */
966 spi_init_any_nil (&any);
970 spi_init_any_nil (&any);
975 spi_atk_emit_eventv (gobject, detail1, detail2, &any,
976 "object:%s:%s", name, detail);
978 spi_atk_emit_eventv (gobject, detail1, detail2, &any,
988 spi_atk_bridge_window_event_listener (GSignalInvocationHint *signal_hint,
989 guint n_param_values,
990 const GValue *param_values,
994 GSignalQuery signal_query;
996 const gchar *name, *s;
997 #ifdef SPI_BRIDGE_DEBUG
1001 g_signal_query (signal_hint->signal_id, &signal_query);
1003 name = signal_query.signal_name;
1005 #ifdef SPI_BRIDGE_DEBUG
1006 s2 = g_type_name (G_OBJECT_TYPE (g_value_get_object (param_values + 0)));
1007 s = atk_object_get_name (ATK_OBJECT (g_value_get_object (param_values + 0)));
1008 fprintf (stderr, "Received signal %s:%s from object %s (gail %s)\n",
1009 g_type_name (signal_query.itype), name, s ? s : "<NULL>" , s2);
1012 gobject = g_value_get_object (param_values + 0);
1014 s = atk_object_get_name (ATK_OBJECT (gobject));
1015 spi_init_any_string (&any, (char **) &s);
1017 spi_atk_emit_eventv (gobject, 0, 0, &any,
1023 spi_atk_tidy_windows (void)
1029 root = atk_get_root ();
1030 n_children = atk_object_get_n_accessible_children (root);
1031 for (i = 0; i < n_children; i++)
1034 AtkStateSet *stateset;
1038 child = atk_object_ref_accessible_child (root, i);
1039 stateset = atk_object_ref_state_set (child);
1041 name = atk_object_get_name (child);
1042 spi_init_any_string (&any, (char**) &name);
1043 if (atk_state_set_contains_state (stateset, ATK_STATE_ACTIVE))
1045 spi_atk_emit_eventv (G_OBJECT (child), 0, 0, &any, "window:deactivate");
1049 spi_atk_emit_eventv (G_OBJECT (child), 0, 0, &any, "window:destroy");
1050 g_object_unref (child);
1055 reinit_register_vars (void)
1057 registry = CORBA_OBJECT_NIL;
1058 device_event_controller = CORBA_OBJECT_NIL;