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"
37 #include <bonobo-activation/bonobo-activation-register.h>
39 #undef SPI_BRIDGE_DEBUG
41 #define DBG(a,b) if(_dbg>=(a))b
44 static CORBA_Environment ev;
45 static Accessibility_Registry registry = CORBA_OBJECT_NIL;
46 static Accessibility_DeviceEventController device_event_controller = CORBA_OBJECT_NIL;
47 static SpiApplication *this_app = NULL;
48 static gboolean registry_died = FALSE;
49 static gboolean atk_listeners_registered = FALSE;
50 static gint toplevels = 0;
52 static guint atk_signal_text_changed;
53 static guint atk_signal_children_changed;
54 static guint atk_signal_active_descendant_changed;
55 static guint atk_signal_text_selection_changed;
58 static guint atk_signal_row_reordered;
59 static guint atk_signal_row_inserted;
60 static guint atk_signal_row_deleted;
61 static guint atk_signal_column_reordered;
62 static guint atk_signal_column_inserted;
63 static guint atk_signal_column_deleted;
66 static guint atk_signal_link_selected;
68 static Accessibility_Registry spi_atk_bridge_get_registry (void);
69 static void spi_atk_bridge_do_registration (void);
70 static void spi_atk_bridge_toplevel_added (AtkObject *object,
73 static void spi_atk_bridge_toplevel_removed (AtkObject *object,
77 static void spi_atk_bridge_exit_func (void);
78 static void spi_atk_register_event_listeners (void);
79 static void spi_atk_bridge_focus_tracker (AtkObject *object);
80 static void spi_atk_bridge_register_application (Accessibility_Registry registry);
81 static gboolean spi_atk_bridge_property_event_listener (GSignalInvocationHint *signal_hint,
83 const GValue *param_values,
86 spi_atk_bridge_window_event_listener (GSignalInvocationHint *signal_hint,
88 const GValue *param_values,
91 spi_atk_bridge_state_event_listener (GSignalInvocationHint *signal_hint,
93 const GValue *param_values,
95 static gboolean spi_atk_bridge_signal_listener (GSignalInvocationHint *signal_hint,
97 const GValue *param_values,
99 static gint spi_atk_bridge_key_listener (AtkKeyEventStruct *event,
101 static void spi_atk_tidy_windows (void);
102 static void deregister_application (BonoboObject *app);
103 static void reinit_register_vars (void);
105 /* For automatic libgnome init */
106 extern void gnome_accessibility_module_init (void);
107 extern void gnome_accessibility_module_shutdown (void);
109 static int atk_bridge_initialized = FALSE;
110 static guint atk_bridge_focus_tracker_id = 0;
111 static guint atk_bridge_key_event_listener_id = 0;
112 static GArray *listener_ids = NULL;
115 * These exported symbols are hooked by gnome-program
116 * to provide automatic module initialization and shutdown.
118 extern void gnome_accessibility_module_init (void);
119 extern void gnome_accessibility_module_shutdown (void);
122 spi_atk_bridge_init_event_type_consts ()
124 static gboolean done = FALSE;
129 atk_signal_children_changed = g_signal_lookup ("children_changed",
131 atk_signal_text_changed = g_signal_lookup ("text_changed",
133 atk_signal_active_descendant_changed =
134 g_signal_lookup ("active_descendant_changed",
136 atk_signal_link_selected = g_signal_lookup ("link_selected",
138 atk_signal_text_selection_changed = g_signal_lookup ("text_selection_changed",
144 atk_bridge_init (gint *argc, gchar **argv[])
146 const char *debug_env_string = g_getenv ("AT_SPI_DEBUG");
148 if (atk_bridge_initialized)
152 atk_bridge_initialized = TRUE;
154 if (debug_env_string)
155 _dbg = (int) g_ascii_strtod (debug_env_string, NULL);
157 if (!bonobo_init (argc, argv ? *argv : NULL))
159 g_error ("Could not initialize Bonobo");
162 /* Create the accessible application server object */
163 this_app = spi_application_new (atk_get_root ());
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 ();
186 spi_atk_register_event_listeners ();
187 spi_atk_bridge_init_event_type_consts ();
194 spi_atk_bridge_do_registration (void)
196 CORBA_Environment ev;
198 CORBA_exception_init(&ev);
200 if (spi_atk_bridge_get_registry () == CORBA_OBJECT_NIL)
202 g_error ("Could not locate registry");
207 /* Create the accessible application server object */
208 if (this_app == NULL)
209 this_app = spi_application_new (atk_get_root ());
211 DBG (1, g_message ("About to register application\n"));
213 spi_atk_bridge_register_application (spi_atk_bridge_get_registry ());
215 g_atexit (spi_atk_bridge_exit_func);
217 DBG (1, g_message ("Application registered & listening\n"));
222 spi_atk_bridge_toplevel_added (AtkObject *object,
228 spi_atk_bridge_do_registration ();
234 spi_atk_bridge_toplevel_removed (AtkObject *object,
238 BonoboObject *app = (BonoboObject *) this_app;
243 deregister_application (app);
244 reinit_register_vars ();
248 g_warning ("More toplevels removed than added\n");
254 spi_atk_bridge_register_application (Accessibility_Registry registry)
256 Accessibility_Registry_registerApplication (spi_atk_bridge_get_registry (),
257 BONOBO_OBJREF (this_app),
261 static Accessibility_Registry
262 spi_atk_bridge_get_registry (void)
264 CORBA_Environment ev;
266 if (registry_died || (registry == CORBA_OBJECT_NIL)) {
267 CORBA_exception_init (&ev);
269 DBG (1, g_warning ("registry died! restarting..."));
270 registry = bonobo_activation_activate_from_id (
271 "OAFIID:Accessibility_Registry:1.0", 0, NULL, &ev);
273 if (ev._major != CORBA_NO_EXCEPTION)
275 g_error ("Accessibility app error: exception during "
276 "registry activation from id: %s\n",
277 CORBA_exception_id (&ev));
278 CORBA_exception_free (&ev);
281 if (registry_died && registry) {
282 registry_died = FALSE;
283 spi_atk_bridge_register_application (registry);
289 static Accessibility_DeviceEventController
290 spi_atk_bridget_get_dec (void)
292 CORBA_Environment ev;
294 if (device_event_controller != CORBA_OBJECT_NIL)
296 if (ORBit_small_get_connection_status (device_event_controller)
297 == ORBIT_CONNECTION_CONNECTED)
298 return device_event_controller;
301 CORBA_exception_init (&ev);
303 device_event_controller =
304 Accessibility_Registry_getDeviceEventController (
305 spi_atk_bridge_get_registry (), &ev);
309 g_warning (_("failure: no device event controller found.\n"));
310 registry_died = TRUE;
311 device_event_controller = CORBA_OBJECT_NIL;
314 return device_event_controller;
318 gtk_module_init (gint *argc, gchar **argv[])
320 return atk_bridge_init (argc, argv);
324 add_signal_listener (const char *signal_name)
328 id = atk_add_global_event_listener (
329 spi_atk_bridge_signal_listener, signal_name);
331 g_array_append_val (listener_ids, id);
335 spi_atk_register_event_listeners (void)
338 * kludge to make sure the Atk interface types are registered, otherwise
339 * the AtkText signal handlers below won't get registered
342 GObject *ao = g_object_new (ATK_TYPE_OBJECT, NULL);
343 AtkObject *bo = atk_no_op_object_new (ao);
346 if (atk_listeners_registered) return;
348 atk_listeners_registered = TRUE;
350 /* Register for focus event notifications, and register app with central registry */
352 listener_ids = g_array_sized_new (FALSE, TRUE, sizeof (guint), 16);
354 atk_bridge_focus_tracker_id = atk_add_focus_tracker (spi_atk_bridge_focus_tracker);
356 id = atk_add_global_event_listener (spi_atk_bridge_property_event_listener,
357 "Gtk:AtkObject:property-change");
358 g_array_append_val (listener_ids, id);
359 id = atk_add_global_event_listener (spi_atk_bridge_window_event_listener,
361 g_array_append_val (listener_ids, id);
362 id = atk_add_global_event_listener (spi_atk_bridge_window_event_listener,
364 g_array_append_val (listener_ids, id);
365 id = atk_add_global_event_listener (spi_atk_bridge_window_event_listener,
367 g_array_append_val (listener_ids, id);
368 id = atk_add_global_event_listener (spi_atk_bridge_window_event_listener,
370 g_array_append_val (listener_ids, id);
371 id = atk_add_global_event_listener (spi_atk_bridge_window_event_listener,
373 g_array_append_val (listener_ids, id);
374 id = atk_add_global_event_listener (spi_atk_bridge_window_event_listener,
376 g_array_append_val (listener_ids, id);
377 id = atk_add_global_event_listener (spi_atk_bridge_window_event_listener,
378 "window:deactivate");
379 g_array_append_val (listener_ids, id);
380 id = atk_add_global_event_listener (spi_atk_bridge_state_event_listener,
381 "Gtk:AtkObject:state-change");
382 g_array_append_val (listener_ids, id);
384 add_signal_listener ("Gtk:AtkObject:children-changed");
385 add_signal_listener ("Gtk:AtkObject:visible-data-changed");
386 add_signal_listener ("Gtk:AtkObject:active-descendant-changed");
387 add_signal_listener ("Gtk:AtkSelection:selection-changed");
388 add_signal_listener ("Gtk:AtkText:text-selection-changed");
389 add_signal_listener ("Gtk:AtkText:text-changed");
390 add_signal_listener ("Gtk:AtkText:text-caret-moved");
391 add_signal_listener ("Gtk:AtkTable:row-inserted");
392 add_signal_listener ("Gtk:AtkTable:row-reordered");
393 add_signal_listener ("Gtk:AtkTable:row-deleted");
394 add_signal_listener ("Gtk:AtkTable:column-inserted");
395 add_signal_listener ("Gtk:AtkTable:column-reordered");
396 add_signal_listener ("Gtk:AtkTable:column-deleted");
397 add_signal_listener ("Gtk:AtkTable:model-changed");
398 add_signal_listener ("Gtk:AtkHypertext:link-selected");
400 * May add the following listeners to implement preemptive key listening for GTK+
402 * atk_add_global_event_listener (spi_atk_bridge_widgetkey_listener, "Gtk:GtkWidget:key-press-event");
403 * atk_add_global_event_listener (spi_atk_bridge_widgetkey_listener, "Gtk:GtkWidget:key-release-event");
405 atk_bridge_key_event_listener_id = atk_add_key_event_listener (
406 spi_atk_bridge_key_listener, NULL);
408 g_object_unref (G_OBJECT (bo));
413 deregister_application (BonoboObject *app)
415 Accessibility_Registry registry = spi_atk_bridge_get_registry ();
416 Accessibility_Registry_deregisterApplication (registry, BONOBO_OBJREF (app), &ev);
418 device_event_controller = bonobo_object_release_unref (device_event_controller, &ev);
419 registry = bonobo_object_release_unref (registry, &ev);
421 app = bonobo_object_unref (app);
425 spi_atk_bridge_exit_func (void)
427 BonoboObject *app = (BonoboObject *) this_app;
429 DBG (1, g_message ("exiting bridge\n"));
438 * Check whether we still have windows which have not been deleted.
440 spi_atk_tidy_windows ();
442 * FIXME: this may be incorrect for apps that do their own bonobo
443 * shutdown, until we can explicitly shutdown to get the ordering
446 if (!bonobo_is_initialized ())
448 DBG (1, g_warning ("Re-initializing bonobo\n"));
449 g_assert (bonobo_init (0, NULL));
450 g_assert (bonobo_activate ());
453 deregister_application (app);
455 DBG (1, g_message ("bridge exit func complete.\n"));
457 if (g_getenv ("AT_BRIDGE_SHUTDOWN"))
459 g_assert (!bonobo_debug_shutdown ());
464 gnome_accessibility_module_init (void)
466 atk_bridge_init (NULL, NULL);
468 if (g_getenv ("AT_BRIDGE_SHUTDOWN"))
470 g_print("Atk Accessibility bridge initialized\n");
475 gnome_accessibility_module_shutdown (void)
477 BonoboObject *app = (BonoboObject *) this_app;
479 GArray *ids = listener_ids;
481 if (!atk_bridge_initialized)
485 atk_bridge_initialized = FALSE;
488 if (g_getenv ("AT_BRIDGE_SHUTDOWN"))
490 g_print("Atk Accessibility bridge shutdown\n");
494 atk_remove_focus_tracker (atk_bridge_focus_tracker_id);
496 for (i = 0; ids && i < ids->len; i++)
498 atk_remove_global_event_listener (g_array_index (ids, guint, i));
501 atk_remove_key_event_listener (atk_bridge_key_event_listener_id);
503 deregister_application (app);
507 spi_atk_bridge_focus_tracker (AtkObject *object)
509 SpiAccessible *source;
510 Accessibility_Event e;
512 source = spi_accessible_new (object);
515 e.source = BONOBO_OBJREF (source);
518 spi_init_any_nil (&e.any_data);
520 CORBA_exception_init (&ev);
521 Accessibility_Registry_notifyEvent (spi_atk_bridge_get_registry (), &e, &ev);
523 registry_died = TRUE;
525 bonobo_object_unref (source);
527 CORBA_exception_free (&ev);
531 spi_atk_emit_eventv (const GObject *gobject,
535 const char *format, ...)
538 Accessibility_Event e;
539 SpiAccessible *source;
541 #ifdef SPI_BRIDGE_DEBUG
545 va_start (args, format);
547 if (ATK_IS_IMPLEMENTOR (gobject))
549 aobject = atk_implementor_ref_accessible (ATK_IMPLEMENTOR (gobject));
550 source = spi_accessible_new (aobject);
551 g_object_unref (G_OBJECT (aobject));
553 else if (ATK_IS_OBJECT (gobject))
555 aobject = ATK_OBJECT (gobject);
556 source = spi_accessible_new (aobject);
562 DBG (0, g_warning ("received property-change event from non-AtkImplementor"));
567 e.type = g_strdup_vprintf (format, args);
568 e.source = BONOBO_OBJREF (source);
571 if (any) e.any_data = *any;
572 else spi_init_any_nil (&e.any_data);
574 #ifdef SPI_BRIDGE_DEBUG
575 s = Accessibility_Accessible__get_name (BONOBO_OBJREF (source), &ev);
576 g_warning ("Emitting event '%s' (%lu, %lu) on %s",
577 e.type, e.detail1, e.detail2, s);
580 CORBA_exception_init (&ev);
581 Accessibility_Registry_notifyEvent (spi_atk_bridge_get_registry (),
583 #ifdef SPI_BRIDGE_DEBUG
584 if (ev._major != CORBA_NO_EXCEPTION)
585 g_warning ("error emitting event %s, (%d) %s",
588 CORBA_exception_id(&ev));
590 if (BONOBO_EX (&ev)) registry_died = TRUE;
591 Accessibility_Accessible_unref (e.source, &ev);
593 CORBA_exception_free (&ev);
603 spi_atk_bridge_property_event_listener (GSignalInvocationHint *signal_hint,
604 guint n_param_values,
605 const GValue *param_values,
608 AtkPropertyValues *values;
610 const gchar *prop_name;
612 const gchar *sp = NULL;
614 SpiAccessible *s_ao = NULL;
618 #ifdef SPI_BRIDGE_DEBUG
619 GSignalQuery signal_query;
623 g_signal_query (signal_hint->signal_id, &signal_query);
624 name = signal_query.signal_name;
626 s2 = g_type_name (G_OBJECT_TYPE (g_value_get_object (param_values + 0)));
627 s = atk_object_get_name (ATK_OBJECT (g_value_get_object (param_values + 0)));
628 values = (AtkPropertyValues*) g_value_get_pointer (param_values + 1);
629 DBG (2, g_message ("Received (property) signal %s:%s:%s from object %s (gail %s)\n",
630 g_type_name (signal_query.itype), name, values->property_name, s, s2));
634 gobject = g_value_get_object (param_values + 0);
635 values = (AtkPropertyValues*) g_value_get_pointer (param_values + 1);
637 prop_name = values->property_name;
638 if (strcmp (prop_name, "accessible-name") == 0)
640 sp = atk_object_get_name (ATK_OBJECT (gobject));
641 spi_init_any_string (&any, (gchar **)&sp);
643 else if (strcmp (prop_name, "accessible-description") == 0)
645 sp = atk_object_get_description (ATK_OBJECT (gobject));
646 spi_init_any_string (&any, (gchar **)&sp);
648 else if (strcmp (prop_name, "accessible-parent") == 0)
650 ao = atk_object_get_parent (ATK_OBJECT (gobject));
653 s_ao = spi_accessible_new (ao);
654 c_obj = BONOBO_OBJREF (s_ao);
655 spi_init_any_object (&any, &c_obj);
659 spi_init_any_nil (&any);
662 else if (strcmp (prop_name, "accessible-table-summary") == 0)
664 ao = atk_table_get_summary (ATK_TABLE (gobject));
667 s_ao = spi_accessible_new (ao);
668 c_obj = BONOBO_OBJREF (s_ao);
669 spi_init_any_object (&any, &c_obj);
673 spi_init_any_nil (&any);
676 else if (strcmp (prop_name, "accessible-table-column-header") == 0)
678 i = g_value_get_int (&(values->new_value));
679 ao = atk_table_get_column_header (ATK_TABLE (gobject), i);
682 s_ao = spi_accessible_new (ao);
683 c_obj = BONOBO_OBJREF (s_ao);
684 spi_init_any_object (&any, &c_obj);
688 spi_init_any_nil (&any);
691 else if (strcmp (prop_name, "accessible-table-row-header") == 0)
693 i = g_value_get_int (&(values->new_value));
694 ao = atk_table_get_row_header (ATK_TABLE (gobject), i);
697 s_ao = spi_accessible_new (ao);
698 c_obj = BONOBO_OBJREF (s_ao);
699 spi_init_any_object (&any, &c_obj);
703 spi_init_any_nil (&any);
706 else if (strcmp (prop_name, "accessible-table-row-description") == 0)
708 i = g_value_get_int (&(values->new_value));
709 sp = atk_table_get_row_description (ATK_TABLE (gobject), i);
710 spi_init_any_string (&any, (gchar **)&sp);
712 else if (strcmp (prop_name, "accessible-table-column-description") == 0)
714 i = g_value_get_int (&(values->new_value));
715 sp = atk_table_get_column_description (ATK_TABLE (gobject), i);
716 spi_init_any_string (&any, (gchar **)&sp);
718 else if (strcmp (prop_name, "accessible-table-caption-object") == 0)
720 ao = atk_table_get_caption (ATK_TABLE (gobject));
721 sp = atk_object_get_name (ao);
722 spi_init_any_string (&any, (gchar **)&sp);
726 spi_init_any_nil (&any);
729 spi_atk_emit_eventv (gobject, 0, 0, &any,
730 "object:property-change:%s", prop_name);
737 spi_atk_bridge_state_event_listener (GSignalInvocationHint *signal_hint,
738 guint n_param_values,
739 const GValue *param_values,
743 gchar *property_name;
745 unsigned long detail1;
746 #ifdef SPI_BRIDGE_DEBUG
747 GSignalQuery signal_query;
750 g_signal_query (signal_hint->signal_id, &signal_query);
751 name = signal_query.signal_name;
752 fprintf (stderr, "Received (state) signal %s:%s\n",
753 g_type_name (signal_query.itype), name);
756 gobject = g_value_get_object (param_values + 0);
757 property_name = g_strdup (g_value_get_string (param_values + 1));
758 detail1 = (g_value_get_boolean (param_values + 2))
760 type = g_strdup_printf ("object:state-changed:%s", property_name);
761 spi_atk_emit_eventv (gobject,
766 g_free (property_name);
772 spi_init_keystroke_from_atk_key_event (Accessibility_DeviceEvent *keystroke,
773 AtkKeyEventStruct *event)
778 g_print ("event %c (%d)\n", (int) event->keyval, (int) event->keycode);
784 g_print (_("WARNING: NULL key event reported."));
787 keystroke->id = (CORBA_long) event->keyval;
788 keystroke->hw_code = (CORBA_short) event->keycode;
789 keystroke->timestamp = (CORBA_unsigned_long) event->timestamp;
790 keystroke->modifiers = (CORBA_unsigned_short) (event->state & 0xFFFF);
795 keystroke->event_string = CORBA_string_dup (event->string);
796 c = g_utf8_get_char_validated (event->string, -1);
797 if (c > 0 && g_unichar_isprint (c))
798 keystroke->is_text = CORBA_TRUE;
800 keystroke->is_text = CORBA_FALSE;
804 keystroke->event_string = CORBA_string_dup ("");
805 keystroke->is_text = CORBA_FALSE;
809 case (ATK_KEY_EVENT_PRESS):
810 keystroke->type = Accessibility_KEY_PRESSED_EVENT;
812 case (ATK_KEY_EVENT_RELEASE):
813 keystroke->type = Accessibility_KEY_RELEASED_EVENT;
820 g_print ("key_event type %d; val=%d code=%d modifiers=%x name=%s is_text=%d, time=%lx\n",
821 (int) keystroke->type, (int) keystroke->id, (int) keystroke->hw_code,
822 (int) keystroke->modifiers,
823 keystroke->event_string, (int) keystroke->is_text, (unsigned long) keystroke->timestamp);
828 spi_atk_bridge_key_listener (AtkKeyEventStruct *event, gpointer data)
830 CORBA_boolean result;
831 Accessibility_DeviceEvent key_event;
833 CORBA_exception_init (&ev);
835 spi_init_keystroke_from_atk_key_event (&key_event, event);
837 result = Accessibility_DeviceEventController_notifyListenersSync (
838 spi_atk_bridget_get_dec (), &key_event, &ev);
840 if (BONOBO_EX(&ev)) {
842 CORBA_exception_free (&ev);
849 spi_atk_bridge_signal_listener (GSignalInvocationHint *signal_hint,
850 guint n_param_values,
851 const GValue *param_values,
855 GSignalQuery signal_query;
863 gint detail1 = 0, detail2 = 0;
864 SpiAccessible *s_ao = NULL;
865 #ifdef SPI_BRIDGE_DEBUG
869 g_signal_query (signal_hint->signal_id, &signal_query);
871 name = signal_query.signal_name;
872 if (signal_hint->detail)
873 detail = g_quark_to_string (signal_hint->detail);
877 #ifdef SPI_BRIDGE_DEBUG
878 s2 = g_type_name (G_OBJECT_TYPE (g_value_get_object (param_values + 0)));
879 s = atk_object_get_name (ATK_OBJECT (g_value_get_object (param_values + 0)));
880 fprintf (stderr, "Received signal %s:%s detail: %s from object %s (gail %s)\n",
881 g_type_name (signal_query.itype), name,
882 detail ? detail : "<NULL>", s ? s : "<NULL>" , s2);
885 gobject = g_value_get_object (param_values + 0);
887 if (signal_query.signal_id == atk_signal_active_descendant_changed)
889 gpointer child = g_value_get_pointer (param_values + 1);
891 g_return_val_if_fail (ATK_IS_OBJECT (child), TRUE);
893 ao = ATK_OBJECT (child);
895 detail1 = atk_object_get_index_in_parent (ao);
896 s_ao = spi_accessible_new (ao);
897 c_obj = BONOBO_OBJREF (s_ao);
898 spi_init_any_object (&any, &c_obj);
900 else if (signal_query.signal_id == atk_signal_link_selected)
902 if (G_VALUE_TYPE (param_values + 1) == G_TYPE_INT)
903 detail1 = g_value_get_int (param_values + 1);
904 spi_init_any_nil (&any);
906 else if ((signal_query.signal_id == atk_signal_children_changed) && gobject)
908 ao = atk_object_ref_accessible_child (ATK_OBJECT (gobject),
912 s_ao = spi_accessible_new (ao);
913 c_obj = BONOBO_OBJREF (s_ao);
914 spi_init_any_object (&any, &c_obj);
919 spi_init_any_nil (&any);
924 if (n_param_values >= 2)
926 if (G_VALUE_TYPE (param_values + 1) == G_TYPE_INT)
927 detail1 = g_value_get_int (param_values + 1);
928 if (n_param_values >= 3)
930 if (G_VALUE_TYPE (param_values + 2) == G_TYPE_INT)
931 detail2 = g_value_get_int (param_values + 2);
935 if (signal_query.signal_id == atk_signal_text_changed)
937 sp = atk_text_get_text (ATK_TEXT (gobject),
940 spi_init_any_string (&any, &sp);
942 else if (signal_query.signal_id == atk_signal_text_selection_changed)
944 text = ATK_TEXT (gobject);
946 /* Return NULL as the selected string */
947 spi_init_any_nil (&any);
951 spi_init_any_nil (&any);
956 spi_atk_emit_eventv (gobject, detail1, detail2, &any,
957 "object:%s:%s", name, detail);
959 spi_atk_emit_eventv (gobject, detail1, detail2, &any,
969 spi_atk_bridge_window_event_listener (GSignalInvocationHint *signal_hint,
970 guint n_param_values,
971 const GValue *param_values,
975 GSignalQuery signal_query;
977 const gchar *name, *s;
978 #ifdef SPI_BRIDGE_DEBUG
982 g_signal_query (signal_hint->signal_id, &signal_query);
984 name = signal_query.signal_name;
986 #ifdef SPI_BRIDGE_DEBUG
987 s2 = g_type_name (G_OBJECT_TYPE (g_value_get_object (param_values + 0)));
988 s = atk_object_get_name (ATK_OBJECT (g_value_get_object (param_values + 0)));
989 fprintf (stderr, "Received signal %s:%s from object %s (gail %s)\n",
990 g_type_name (signal_query.itype), name, s ? s : "<NULL>" , s2);
993 gobject = g_value_get_object (param_values + 0);
995 s = atk_object_get_name (ATK_OBJECT (gobject));
996 spi_init_any_string (&any, (char **) &s);
998 spi_atk_emit_eventv (gobject, 0, 0, &any,
1004 spi_atk_tidy_windows (void)
1010 root = atk_get_root ();
1011 n_children = atk_object_get_n_accessible_children (root);
1012 for (i = 0; i < n_children; i++)
1015 AtkStateSet *stateset;
1019 child = atk_object_ref_accessible_child (root, i);
1020 stateset = atk_object_ref_state_set (child);
1022 name = atk_object_get_name (child);
1023 spi_init_any_string (&any, (char**) &name);
1024 if (atk_state_set_contains_state (stateset, ATK_STATE_ACTIVE))
1026 spi_atk_emit_eventv (G_OBJECT (child), 0, 0, &any, "window:deactivate");
1028 g_object_unref (stateset);
1030 spi_atk_emit_eventv (G_OBJECT (child), 0, 0, &any, "window:destroy");
1031 g_object_unref (child);
1036 reinit_register_vars (void)
1038 registry = CORBA_OBJECT_NIL;
1039 device_event_controller = CORBA_OBJECT_NIL;