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_bridge_focus_tracker (AtkObject *object);
81 static void spi_atk_bridge_register_application (Accessibility_Registry registry);
82 static gboolean spi_atk_bridge_property_event_listener (GSignalInvocationHint *signal_hint,
84 const GValue *param_values,
87 spi_atk_bridge_window_event_listener (GSignalInvocationHint *signal_hint,
89 const GValue *param_values,
92 spi_atk_bridge_state_event_listener (GSignalInvocationHint *signal_hint,
94 const GValue *param_values,
96 static gboolean spi_atk_bridge_signal_listener (GSignalInvocationHint *signal_hint,
98 const GValue *param_values,
100 static gint spi_atk_bridge_key_listener (AtkKeyEventStruct *event,
102 static void spi_atk_tidy_windows (void);
103 static void deregister_application (BonoboObject *app);
104 static void reinit_register_vars (void);
106 /* For automatic libgnome init */
107 extern void gnome_accessibility_module_init (void);
108 extern void gnome_accessibility_module_shutdown (void);
110 static int atk_bridge_initialized = FALSE;
111 static guint atk_bridge_focus_tracker_id = 0;
112 static guint atk_bridge_key_event_listener_id = 0;
113 static GArray *listener_ids = NULL;
116 * These exported symbols are hooked by gnome-program
117 * to provide automatic module initialization and shutdown.
119 extern void gnome_accessibility_module_init (void);
120 extern void gnome_accessibility_module_shutdown (void);
123 spi_atk_bridge_init_event_type_consts ()
125 static gboolean done = FALSE;
130 atk_signal_children_changed = g_signal_lookup ("children_changed",
132 atk_signal_text_changed = g_signal_lookup ("text_changed",
134 atk_signal_active_descendant_changed =
135 g_signal_lookup ("active_descendant_changed",
137 atk_signal_link_selected = g_signal_lookup ("link_selected",
139 atk_signal_text_selection_changed = g_signal_lookup ("text_selection_changed",
145 atk_bridge_init (gint *argc, gchar **argv[])
147 const char *debug_env_string = g_getenv ("AT_SPI_DEBUG");
149 if (atk_bridge_initialized)
153 atk_bridge_initialized = TRUE;
155 if (debug_env_string)
156 _dbg = (int) g_ascii_strtod (debug_env_string, NULL);
158 if (!bonobo_init (argc, argv ? *argv : NULL))
160 g_error ("Could not initialize Bonobo");
164 * We only want to enable the bridge for top level
165 * applications, we detect bonobo components by seeing
166 * if they were activated with the intention of extracting
167 * an impl. by IID - very solid.
169 if (bonobo_activation_iid_get ())
171 DBG (1, g_message ("Found Bonobo component\n"));
172 g_signal_connect (atk_get_root (),
173 "children-changed::add",
174 (GCallback) spi_atk_bridge_toplevel_added,
176 g_signal_connect (atk_get_root (),
177 "children-changed::remove",
178 (GCallback) spi_atk_bridge_toplevel_removed,
183 spi_atk_bridge_do_registration ();
185 spi_atk_register_event_listeners ();
186 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 ();
233 spi_atk_bridge_toplevel_removed (AtkObject *object,
237 BonoboObject *app = (BonoboObject *) this_app;
242 deregister_application (app);
243 reinit_register_vars ();
247 g_warning ("More toplevels removed than added\n");
253 spi_atk_bridge_register_application (Accessibility_Registry registry)
255 Accessibility_Registry_registerApplication (spi_atk_bridge_get_registry (),
256 BONOBO_OBJREF (this_app),
260 static Accessibility_Registry
261 spi_atk_bridge_get_registry (void)
263 CORBA_Environment ev;
265 if (registry_died || (registry == CORBA_OBJECT_NIL)) {
266 CORBA_exception_init (&ev);
268 DBG (1, g_warning ("registry died! restarting..."));
269 registry = bonobo_activation_activate_from_id (
270 "OAFIID:Accessibility_Registry:1.0", 0, NULL, &ev);
272 if (ev._major != CORBA_NO_EXCEPTION)
274 g_error ("Accessibility app error: exception during "
275 "registry activation from id: %s\n",
276 CORBA_exception_id (&ev));
277 CORBA_exception_free (&ev);
280 if (registry_died && registry) {
281 registry_died = FALSE;
282 spi_atk_bridge_register_application (registry);
288 static Accessibility_DeviceEventController
289 spi_atk_bridget_get_dec (void)
291 CORBA_Environment ev;
293 if (device_event_controller != CORBA_OBJECT_NIL)
295 if (ORBit_small_get_connection_status (device_event_controller)
296 == ORBIT_CONNECTION_CONNECTED)
297 return device_event_controller;
300 CORBA_exception_init (&ev);
302 device_event_controller =
303 Accessibility_Registry_getDeviceEventController (
304 spi_atk_bridge_get_registry (), &ev);
308 g_warning (_("failure: no device event controller found.\n"));
309 registry_died = TRUE;
310 device_event_controller = CORBA_OBJECT_NIL;
313 return device_event_controller;
317 gtk_module_init (gint *argc, gchar **argv[])
319 return atk_bridge_init (argc, argv);
323 add_signal_listener (const char *signal_name)
327 id = atk_add_global_event_listener (
328 spi_atk_bridge_signal_listener, signal_name);
330 g_array_append_val (listener_ids, id);
334 spi_atk_register_event_listeners (void)
337 * kludge to make sure the Atk interface types are registered, otherwise
338 * the AtkText signal handlers below won't get registered
341 GObject *ao = g_object_new (ATK_TYPE_OBJECT, NULL);
342 AtkObject *bo = atk_no_op_object_new (ao);
345 if (atk_listeners_registered) return;
347 atk_listeners_registered = TRUE;
349 /* Register for focus event notifications, and register app with central registry */
351 listener_ids = g_array_sized_new (FALSE, TRUE, sizeof (guint), 16);
353 atk_bridge_focus_tracker_id = atk_add_focus_tracker (spi_atk_bridge_focus_tracker);
355 id = atk_add_global_event_listener (spi_atk_bridge_property_event_listener,
356 "Gtk:AtkObject:property-change");
357 g_array_append_val (listener_ids, id);
358 id = atk_add_global_event_listener (spi_atk_bridge_window_event_listener,
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,
377 "window:deactivate");
378 g_array_append_val (listener_ids, id);
379 id = atk_add_global_event_listener (spi_atk_bridge_state_event_listener,
380 "Gtk:AtkObject:state-change");
381 g_array_append_val (listener_ids, id);
383 add_signal_listener ("Gtk:AtkObject:children-changed");
384 add_signal_listener ("Gtk:AtkObject:visible-data-changed");
385 add_signal_listener ("Gtk:AtkObject:active-descendant-changed");
386 add_signal_listener ("Gtk:AtkSelection:selection-changed");
387 add_signal_listener ("Gtk:AtkText:text-selection-changed");
388 add_signal_listener ("Gtk:AtkText:text-changed");
389 add_signal_listener ("Gtk:AtkText:text-caret-moved");
390 add_signal_listener ("Gtk:AtkTable:row-inserted");
391 add_signal_listener ("Gtk:AtkTable:row-reordered");
392 add_signal_listener ("Gtk:AtkTable:row-deleted");
393 add_signal_listener ("Gtk:AtkTable:column-inserted");
394 add_signal_listener ("Gtk:AtkTable:column-reordered");
395 add_signal_listener ("Gtk:AtkTable:column-deleted");
396 add_signal_listener ("Gtk:AtkTable:model-changed");
397 add_signal_listener ("Gtk:AtkHypertext:link-selected");
399 * May add the following listeners to implement preemptive key listening for GTK+
401 * atk_add_global_event_listener (spi_atk_bridge_widgetkey_listener, "Gtk:GtkWidget:key-press-event");
402 * atk_add_global_event_listener (spi_atk_bridge_widgetkey_listener, "Gtk:GtkWidget:key-release-event");
404 atk_bridge_key_event_listener_id = atk_add_key_event_listener (
405 spi_atk_bridge_key_listener, NULL);
407 g_object_unref (G_OBJECT (bo));
412 deregister_application (BonoboObject *app)
414 Accessibility_Registry registry = spi_atk_bridge_get_registry ();
415 Accessibility_Registry_deregisterApplication (registry, BONOBO_OBJREF (app), &ev);
417 device_event_controller = bonobo_object_release_unref (device_event_controller, &ev);
418 registry = bonobo_object_release_unref (registry, &ev);
420 app = bonobo_object_unref (app);
424 spi_atk_bridge_exit_func (void)
426 BonoboObject *app = (BonoboObject *) this_app;
428 DBG (1, g_message ("exiting bridge\n"));
437 * Check whether we still have windows which have not been deleted.
439 spi_atk_tidy_windows ();
441 * FIXME: this may be incorrect for apps that do their own bonobo
442 * shutdown, until we can explicitly shutdown to get the ordering
445 if (!bonobo_is_initialized ())
447 DBG (1, g_warning ("Re-initializing bonobo\n"));
448 g_assert (bonobo_init (0, NULL));
449 g_assert (bonobo_activate ());
452 deregister_application (app);
454 DBG (1, g_message ("bridge exit func complete.\n"));
456 if (g_getenv ("AT_BRIDGE_SHUTDOWN"))
458 g_assert (!bonobo_debug_shutdown ());
463 gnome_accessibility_module_init (void)
465 atk_bridge_init (NULL, NULL);
467 g_print("Atk Accessibilty bridge initialized\n");
471 gnome_accessibility_module_shutdown (void)
473 BonoboObject *app = (BonoboObject *) this_app;
475 GArray *ids = listener_ids;
477 if (!atk_bridge_initialized)
481 atk_bridge_initialized = FALSE;
484 g_print("Atk Accessibilty bridge shutdown\n");
487 atk_remove_focus_tracker (atk_bridge_focus_tracker_id);
489 for (i = 0; ids && i < ids->len; i++)
491 atk_remove_global_event_listener (g_array_index (ids, guint, i));
494 atk_remove_key_event_listener (atk_bridge_key_event_listener_id);
496 deregister_application (app);
500 spi_atk_bridge_focus_tracker (AtkObject *object)
502 SpiAccessible *source;
503 Accessibility_Event e;
505 source = spi_accessible_new (object);
508 e.source = BONOBO_OBJREF (source);
511 spi_init_any_nil (&e.any_data);
513 CORBA_exception_init (&ev);
514 Accessibility_Registry_notifyEvent (spi_atk_bridge_get_registry (), &e, &ev);
516 registry_died = TRUE;
518 bonobo_object_unref (source);
520 CORBA_exception_free (&ev);
524 spi_atk_emit_eventv (const GObject *gobject,
528 const char *format, ...)
531 Accessibility_Event e;
532 SpiAccessible *source;
534 #ifdef SPI_BRIDGE_DEBUG
538 va_start (args, format);
540 if (ATK_IS_IMPLEMENTOR (gobject))
542 aobject = atk_implementor_ref_accessible (ATK_IMPLEMENTOR (gobject));
543 source = spi_accessible_new (aobject);
544 g_object_unref (G_OBJECT (aobject));
546 else if (ATK_IS_OBJECT (gobject))
548 aobject = ATK_OBJECT (gobject);
549 source = spi_accessible_new (aobject);
555 DBG (0, g_warning ("received property-change event from non-AtkImplementor"));
560 e.type = g_strdup_vprintf (format, args);
561 e.source = BONOBO_OBJREF (source);
564 if (any) e.any_data = *any;
565 else spi_init_any_nil (&e.any_data);
567 #ifdef SPI_BRIDGE_DEBUG
568 s = Accessibility_Accessible__get_name (BONOBO_OBJREF (source), &ev);
569 g_warning ("Emitting event '%s' (%lu, %lu) on %s",
570 e.type, e.detail1, e.detail2, s);
573 CORBA_exception_init (&ev);
574 Accessibility_Registry_notifyEvent (spi_atk_bridge_get_registry (),
576 #ifdef SPI_BRIDGE_DEBUG
577 if (ev._major != CORBA_NO_EXCEPTION)
578 g_warning ("error emitting event %s, (%d) %s",
581 CORBA_exception_id(&ev));
583 if (BONOBO_EX (&ev)) registry_died = TRUE;
584 Accessibility_Accessible_unref (e.source, &ev);
586 CORBA_exception_free (&ev);
596 spi_atk_bridge_property_event_listener (GSignalInvocationHint *signal_hint,
597 guint n_param_values,
598 const GValue *param_values,
601 AtkPropertyValues *values;
603 const gchar *prop_name;
605 const gchar *sp = NULL;
607 SpiAccessible *s_ao = NULL;
611 #ifdef SPI_BRIDGE_DEBUG
612 GSignalQuery signal_query;
616 g_signal_query (signal_hint->signal_id, &signal_query);
617 name = signal_query.signal_name;
619 s2 = g_type_name (G_OBJECT_TYPE (g_value_get_object (param_values + 0)));
620 s = atk_object_get_name (ATK_OBJECT (g_value_get_object (param_values + 0)));
621 values = (AtkPropertyValues*) g_value_get_pointer (param_values + 1);
622 DBG (2, g_message ("Received (property) signal %s:%s:%s from object %s (gail %s)\n",
623 g_type_name (signal_query.itype), name, values->property_name, s, s2));
627 gobject = g_value_get_object (param_values + 0);
628 values = (AtkPropertyValues*) g_value_get_pointer (param_values + 1);
630 prop_name = values->property_name;
631 if (strcmp (prop_name, "accessible-name") == 0)
633 sp = atk_object_get_name (ATK_OBJECT (gobject));
634 spi_init_any_string (&any, (gchar **)&sp);
636 else if (strcmp (prop_name, "accessible-description") == 0)
638 sp = atk_object_get_description (ATK_OBJECT (gobject));
639 spi_init_any_string (&any, (gchar **)&sp);
641 else if (strcmp (prop_name, "accessible-parent") == 0)
643 ao = atk_object_get_parent (ATK_OBJECT (gobject));
646 s_ao = spi_accessible_new (ao);
647 c_obj = BONOBO_OBJREF (s_ao);
648 spi_init_any_object (&any, &c_obj);
652 spi_init_any_nil (&any);
655 else if (strcmp (prop_name, "accessible-table-summary") == 0)
657 ao = atk_table_get_summary (ATK_TABLE (gobject));
660 s_ao = spi_accessible_new (ao);
661 c_obj = BONOBO_OBJREF (s_ao);
662 spi_init_any_object (&any, &c_obj);
666 spi_init_any_nil (&any);
669 else if (strcmp (prop_name, "accessible-table-column-header") == 0)
671 i = g_value_get_int (&(values->new_value));
672 ao = atk_table_get_column_header (ATK_TABLE (gobject), i);
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-row-header") == 0)
686 i = g_value_get_int (&(values->new_value));
687 ao = atk_table_get_row_header (ATK_TABLE (gobject), i);
690 s_ao = spi_accessible_new (ao);
691 c_obj = BONOBO_OBJREF (s_ao);
692 spi_init_any_object (&any, &c_obj);
696 spi_init_any_nil (&any);
699 else if (strcmp (prop_name, "accessible-table-row-description") == 0)
701 i = g_value_get_int (&(values->new_value));
702 sp = atk_table_get_row_description (ATK_TABLE (gobject), i);
703 spi_init_any_string (&any, (gchar **)&sp);
705 else if (strcmp (prop_name, "accessible-table-column-description") == 0)
707 i = g_value_get_int (&(values->new_value));
708 sp = atk_table_get_column_description (ATK_TABLE (gobject), i);
709 spi_init_any_string (&any, (gchar **)&sp);
711 else if (strcmp (prop_name, "accessible-table-caption-object") == 0)
713 ao = atk_table_get_caption (ATK_TABLE (gobject));
714 sp = atk_object_get_name (ao);
715 spi_init_any_string (&any, (gchar **)&sp);
719 spi_init_any_nil (&any);
722 spi_atk_emit_eventv (gobject, 0, 0, &any,
723 "object:property-change:%s", prop_name);
730 spi_atk_bridge_state_event_listener (GSignalInvocationHint *signal_hint,
731 guint n_param_values,
732 const GValue *param_values,
736 gchar *property_name;
738 unsigned long detail1;
739 #ifdef SPI_BRIDGE_DEBUG
740 GSignalQuery signal_query;
743 g_signal_query (signal_hint->signal_id, &signal_query);
744 name = signal_query.signal_name;
745 fprintf (stderr, "Received (state) signal %s:%s\n",
746 g_type_name (signal_query.itype), name);
749 gobject = g_value_get_object (param_values + 0);
750 property_name = g_strdup (g_value_get_string (param_values + 1));
751 detail1 = (g_value_get_boolean (param_values + 2))
753 type = g_strdup_printf ("object:state-changed:%s", property_name);
754 spi_atk_emit_eventv (gobject,
759 g_free (property_name);
765 spi_init_keystroke_from_atk_key_event (Accessibility_DeviceEvent *keystroke,
766 AtkKeyEventStruct *event)
771 g_print ("event %c (%d)\n", (int) event->keyval, (int) event->keycode);
777 g_print (_("WARNING: NULL key event reported."));
780 keystroke->id = (CORBA_long) event->keyval;
781 keystroke->hw_code = (CORBA_short) event->keycode;
782 keystroke->timestamp = (CORBA_unsigned_long) event->timestamp;
783 keystroke->modifiers = (CORBA_unsigned_short) (event->state & 0xFFFF);
788 keystroke->event_string = CORBA_string_dup (event->string);
789 c = g_utf8_get_char_validated (event->string, -1);
790 if (c > 0 && g_unichar_isprint (c))
791 keystroke->is_text = CORBA_TRUE;
793 keystroke->is_text = CORBA_FALSE;
797 keystroke->event_string = CORBA_string_dup ("");
798 keystroke->is_text = CORBA_FALSE;
802 case (ATK_KEY_EVENT_PRESS):
803 keystroke->type = Accessibility_KEY_PRESSED_EVENT;
805 case (ATK_KEY_EVENT_RELEASE):
806 keystroke->type = Accessibility_KEY_RELEASED_EVENT;
813 g_print ("key_event type %d; val=%d code=%d modifiers=%x name=%s is_text=%d, time=%lx\n",
814 (int) keystroke->type, (int) keystroke->id, (int) keystroke->hw_code,
815 (int) keystroke->modifiers,
816 keystroke->event_string, (int) keystroke->is_text, (unsigned long) keystroke->timestamp);
821 spi_atk_bridge_key_listener (AtkKeyEventStruct *event, gpointer data)
823 CORBA_boolean result;
824 Accessibility_DeviceEvent key_event;
826 CORBA_exception_init (&ev);
828 spi_init_keystroke_from_atk_key_event (&key_event, event);
830 result = Accessibility_DeviceEventController_notifyListenersSync (
831 spi_atk_bridget_get_dec (), &key_event, &ev);
833 CORBA_exception_free (&ev);
839 spi_atk_bridge_signal_listener (GSignalInvocationHint *signal_hint,
840 guint n_param_values,
841 const GValue *param_values,
845 GSignalQuery signal_query;
853 gint detail1 = 0, detail2 = 0;
854 SpiAccessible *s_ao = NULL;
855 #ifdef SPI_BRIDGE_DEBUG
859 g_signal_query (signal_hint->signal_id, &signal_query);
861 name = signal_query.signal_name;
862 if (signal_hint->detail)
863 detail = g_quark_to_string (signal_hint->detail);
867 #ifdef SPI_BRIDGE_DEBUG
868 s2 = g_type_name (G_OBJECT_TYPE (g_value_get_object (param_values + 0)));
869 s = atk_object_get_name (ATK_OBJECT (g_value_get_object (param_values + 0)));
870 fprintf (stderr, "Received signal %s:%s detail: %s from object %s (gail %s)\n",
871 g_type_name (signal_query.itype), name,
872 detail ? detail : "<NULL>", s ? s : "<NULL>" , s2);
875 gobject = g_value_get_object (param_values + 0);
877 if (signal_query.signal_id == atk_signal_active_descendant_changed)
879 gpointer child = g_value_get_pointer (param_values + 1);
881 g_return_val_if_fail (ATK_IS_OBJECT (child), TRUE);
883 ao = ATK_OBJECT (child);
885 detail1 = atk_object_get_index_in_parent (ao);
886 s_ao = spi_accessible_new (ao);
887 c_obj = BONOBO_OBJREF (s_ao);
888 spi_init_any_object (&any, &c_obj);
890 else if (signal_query.signal_id == atk_signal_link_selected)
892 if (G_VALUE_TYPE (param_values + 1) == G_TYPE_INT)
893 detail1 = g_value_get_int (param_values + 1);
894 spi_init_any_nil (&any);
896 else if ((signal_query.signal_id == atk_signal_children_changed) && gobject)
898 ao = atk_object_ref_accessible_child (ATK_OBJECT (gobject),
902 s_ao = spi_accessible_new (ao);
903 c_obj = BONOBO_OBJREF (s_ao);
904 spi_init_any_object (&any, &c_obj);
909 spi_init_any_nil (&any);
914 if (n_param_values >= 2)
916 if (G_VALUE_TYPE (param_values + 1) == G_TYPE_INT)
917 detail1 = g_value_get_int (param_values + 1);
918 if (n_param_values >= 3)
920 if (G_VALUE_TYPE (param_values + 2) == G_TYPE_INT)
921 detail2 = g_value_get_int (param_values + 2);
925 if (signal_query.signal_id == atk_signal_text_changed)
927 sp = atk_text_get_text (ATK_TEXT (gobject),
930 spi_init_any_string (&any, &sp);
932 else if (signal_query.signal_id == atk_signal_text_selection_changed)
934 text = ATK_TEXT (gobject);
936 /* Return NULL as the selected string */
937 spi_init_any_nil (&any);
941 spi_init_any_nil (&any);
946 spi_atk_emit_eventv (gobject, detail1, detail2, &any,
947 "object:%s:%s", name, detail);
949 spi_atk_emit_eventv (gobject, detail1, detail2, &any,
959 spi_atk_bridge_window_event_listener (GSignalInvocationHint *signal_hint,
960 guint n_param_values,
961 const GValue *param_values,
965 GSignalQuery signal_query;
967 const gchar *name, *s;
968 #ifdef SPI_BRIDGE_DEBUG
972 g_signal_query (signal_hint->signal_id, &signal_query);
974 name = signal_query.signal_name;
976 #ifdef SPI_BRIDGE_DEBUG
977 s2 = g_type_name (G_OBJECT_TYPE (g_value_get_object (param_values + 0)));
978 s = atk_object_get_name (ATK_OBJECT (g_value_get_object (param_values + 0)));
979 fprintf (stderr, "Received signal %s:%s from object %s (gail %s)\n",
980 g_type_name (signal_query.itype), name, s ? s : "<NULL>" , s2);
983 gobject = g_value_get_object (param_values + 0);
985 s = atk_object_get_name (ATK_OBJECT (gobject));
986 spi_init_any_string (&any, (char **) &s);
988 spi_atk_emit_eventv (gobject, 0, 0, &any,
994 spi_atk_tidy_windows (void)
1000 root = atk_get_root ();
1001 n_children = atk_object_get_n_accessible_children (root);
1002 for (i = 0; i < n_children; i++)
1005 AtkStateSet *stateset;
1009 child = atk_object_ref_accessible_child (root, i);
1010 stateset = atk_object_ref_state_set (child);
1012 name = atk_object_get_name (child);
1013 spi_init_any_string (&any, (char**) &name);
1014 if (atk_state_set_contains_state (stateset, ATK_STATE_ACTIVE))
1016 spi_atk_emit_eventv (G_OBJECT (child), 0, 0, &any, "window:deactivate");
1020 spi_atk_emit_eventv (G_OBJECT (child), 0, 0, &any, "window:destroy");
1021 g_object_unref (child);
1026 reinit_register_vars (void)
1028 registry = CORBA_OBJECT_NIL;
1029 device_event_controller = CORBA_OBJECT_NIL;