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 g_print("Atk Accessibilty bridge initialized\n");
472 gnome_accessibility_module_shutdown (void)
474 BonoboObject *app = (BonoboObject *) this_app;
476 GArray *ids = listener_ids;
478 if (!atk_bridge_initialized)
482 atk_bridge_initialized = FALSE;
485 g_print("Atk Accessibilty bridge shutdown\n");
488 atk_remove_focus_tracker (atk_bridge_focus_tracker_id);
490 for (i = 0; ids && i < ids->len; i++)
492 atk_remove_global_event_listener (g_array_index (ids, guint, i));
495 atk_remove_key_event_listener (atk_bridge_key_event_listener_id);
497 deregister_application (app);
501 spi_atk_bridge_focus_tracker (AtkObject *object)
503 SpiAccessible *source;
504 Accessibility_Event e;
506 source = spi_accessible_new (object);
509 e.source = BONOBO_OBJREF (source);
512 spi_init_any_nil (&e.any_data);
514 CORBA_exception_init (&ev);
515 Accessibility_Registry_notifyEvent (spi_atk_bridge_get_registry (), &e, &ev);
517 registry_died = TRUE;
519 bonobo_object_unref (source);
521 CORBA_exception_free (&ev);
525 spi_atk_emit_eventv (const GObject *gobject,
529 const char *format, ...)
532 Accessibility_Event e;
533 SpiAccessible *source;
535 #ifdef SPI_BRIDGE_DEBUG
539 va_start (args, format);
541 if (ATK_IS_IMPLEMENTOR (gobject))
543 aobject = atk_implementor_ref_accessible (ATK_IMPLEMENTOR (gobject));
544 source = spi_accessible_new (aobject);
545 g_object_unref (G_OBJECT (aobject));
547 else if (ATK_IS_OBJECT (gobject))
549 aobject = ATK_OBJECT (gobject);
550 source = spi_accessible_new (aobject);
556 DBG (0, g_warning ("received property-change event from non-AtkImplementor"));
561 e.type = g_strdup_vprintf (format, args);
562 e.source = BONOBO_OBJREF (source);
565 if (any) e.any_data = *any;
566 else spi_init_any_nil (&e.any_data);
568 #ifdef SPI_BRIDGE_DEBUG
569 s = Accessibility_Accessible__get_name (BONOBO_OBJREF (source), &ev);
570 g_warning ("Emitting event '%s' (%lu, %lu) on %s",
571 e.type, e.detail1, e.detail2, s);
574 CORBA_exception_init (&ev);
575 Accessibility_Registry_notifyEvent (spi_atk_bridge_get_registry (),
577 #ifdef SPI_BRIDGE_DEBUG
578 if (ev._major != CORBA_NO_EXCEPTION)
579 g_warning ("error emitting event %s, (%d) %s",
582 CORBA_exception_id(&ev));
584 if (BONOBO_EX (&ev)) registry_died = TRUE;
585 Accessibility_Accessible_unref (e.source, &ev);
587 CORBA_exception_free (&ev);
597 spi_atk_bridge_property_event_listener (GSignalInvocationHint *signal_hint,
598 guint n_param_values,
599 const GValue *param_values,
602 AtkPropertyValues *values;
604 const gchar *prop_name;
606 const gchar *sp = NULL;
608 SpiAccessible *s_ao = NULL;
612 #ifdef SPI_BRIDGE_DEBUG
613 GSignalQuery signal_query;
617 g_signal_query (signal_hint->signal_id, &signal_query);
618 name = signal_query.signal_name;
620 s2 = g_type_name (G_OBJECT_TYPE (g_value_get_object (param_values + 0)));
621 s = atk_object_get_name (ATK_OBJECT (g_value_get_object (param_values + 0)));
622 values = (AtkPropertyValues*) g_value_get_pointer (param_values + 1);
623 DBG (2, g_message ("Received (property) signal %s:%s:%s from object %s (gail %s)\n",
624 g_type_name (signal_query.itype), name, values->property_name, s, s2));
628 gobject = g_value_get_object (param_values + 0);
629 values = (AtkPropertyValues*) g_value_get_pointer (param_values + 1);
631 prop_name = values->property_name;
632 if (strcmp (prop_name, "accessible-name") == 0)
634 sp = atk_object_get_name (ATK_OBJECT (gobject));
635 spi_init_any_string (&any, (gchar **)&sp);
637 else if (strcmp (prop_name, "accessible-description") == 0)
639 sp = atk_object_get_description (ATK_OBJECT (gobject));
640 spi_init_any_string (&any, (gchar **)&sp);
642 else if (strcmp (prop_name, "accessible-parent") == 0)
644 ao = atk_object_get_parent (ATK_OBJECT (gobject));
647 s_ao = spi_accessible_new (ao);
648 c_obj = BONOBO_OBJREF (s_ao);
649 spi_init_any_object (&any, &c_obj);
653 spi_init_any_nil (&any);
656 else if (strcmp (prop_name, "accessible-table-summary") == 0)
658 ao = atk_table_get_summary (ATK_TABLE (gobject));
661 s_ao = spi_accessible_new (ao);
662 c_obj = BONOBO_OBJREF (s_ao);
663 spi_init_any_object (&any, &c_obj);
667 spi_init_any_nil (&any);
670 else if (strcmp (prop_name, "accessible-table-column-header") == 0)
672 i = g_value_get_int (&(values->new_value));
673 ao = atk_table_get_column_header (ATK_TABLE (gobject), i);
676 s_ao = spi_accessible_new (ao);
677 c_obj = BONOBO_OBJREF (s_ao);
678 spi_init_any_object (&any, &c_obj);
682 spi_init_any_nil (&any);
685 else if (strcmp (prop_name, "accessible-table-row-header") == 0)
687 i = g_value_get_int (&(values->new_value));
688 ao = atk_table_get_row_header (ATK_TABLE (gobject), i);
691 s_ao = spi_accessible_new (ao);
692 c_obj = BONOBO_OBJREF (s_ao);
693 spi_init_any_object (&any, &c_obj);
697 spi_init_any_nil (&any);
700 else if (strcmp (prop_name, "accessible-table-row-description") == 0)
702 i = g_value_get_int (&(values->new_value));
703 sp = atk_table_get_row_description (ATK_TABLE (gobject), i);
704 spi_init_any_string (&any, (gchar **)&sp);
706 else if (strcmp (prop_name, "accessible-table-column-description") == 0)
708 i = g_value_get_int (&(values->new_value));
709 sp = atk_table_get_column_description (ATK_TABLE (gobject), i);
710 spi_init_any_string (&any, (gchar **)&sp);
712 else if (strcmp (prop_name, "accessible-table-caption-object") == 0)
714 ao = atk_table_get_caption (ATK_TABLE (gobject));
715 sp = atk_object_get_name (ao);
716 spi_init_any_string (&any, (gchar **)&sp);
720 spi_init_any_nil (&any);
723 spi_atk_emit_eventv (gobject, 0, 0, &any,
724 "object:property-change:%s", prop_name);
731 spi_atk_bridge_state_event_listener (GSignalInvocationHint *signal_hint,
732 guint n_param_values,
733 const GValue *param_values,
737 gchar *property_name;
739 unsigned long detail1;
740 #ifdef SPI_BRIDGE_DEBUG
741 GSignalQuery signal_query;
744 g_signal_query (signal_hint->signal_id, &signal_query);
745 name = signal_query.signal_name;
746 fprintf (stderr, "Received (state) signal %s:%s\n",
747 g_type_name (signal_query.itype), name);
750 gobject = g_value_get_object (param_values + 0);
751 property_name = g_strdup (g_value_get_string (param_values + 1));
752 detail1 = (g_value_get_boolean (param_values + 2))
754 type = g_strdup_printf ("object:state-changed:%s", property_name);
755 spi_atk_emit_eventv (gobject,
760 g_free (property_name);
766 spi_init_keystroke_from_atk_key_event (Accessibility_DeviceEvent *keystroke,
767 AtkKeyEventStruct *event)
772 g_print ("event %c (%d)\n", (int) event->keyval, (int) event->keycode);
778 g_print (_("WARNING: NULL key event reported."));
781 keystroke->id = (CORBA_long) event->keyval;
782 keystroke->hw_code = (CORBA_short) event->keycode;
783 keystroke->timestamp = (CORBA_unsigned_long) event->timestamp;
784 keystroke->modifiers = (CORBA_unsigned_short) (event->state & 0xFFFF);
789 keystroke->event_string = CORBA_string_dup (event->string);
790 c = g_utf8_get_char_validated (event->string, -1);
791 if (c > 0 && g_unichar_isprint (c))
792 keystroke->is_text = CORBA_TRUE;
794 keystroke->is_text = CORBA_FALSE;
798 keystroke->event_string = CORBA_string_dup ("");
799 keystroke->is_text = CORBA_FALSE;
803 case (ATK_KEY_EVENT_PRESS):
804 keystroke->type = Accessibility_KEY_PRESSED_EVENT;
806 case (ATK_KEY_EVENT_RELEASE):
807 keystroke->type = Accessibility_KEY_RELEASED_EVENT;
814 g_print ("key_event type %d; val=%d code=%d modifiers=%x name=%s is_text=%d, time=%lx\n",
815 (int) keystroke->type, (int) keystroke->id, (int) keystroke->hw_code,
816 (int) keystroke->modifiers,
817 keystroke->event_string, (int) keystroke->is_text, (unsigned long) keystroke->timestamp);
822 spi_atk_bridge_key_listener (AtkKeyEventStruct *event, gpointer data)
824 CORBA_boolean result;
825 Accessibility_DeviceEvent key_event;
827 CORBA_exception_init (&ev);
829 spi_init_keystroke_from_atk_key_event (&key_event, event);
831 result = Accessibility_DeviceEventController_notifyListenersSync (
832 spi_atk_bridget_get_dec (), &key_event, &ev);
834 CORBA_exception_free (&ev);
840 spi_atk_bridge_signal_listener (GSignalInvocationHint *signal_hint,
841 guint n_param_values,
842 const GValue *param_values,
846 GSignalQuery signal_query;
854 gint detail1 = 0, detail2 = 0;
855 SpiAccessible *s_ao = NULL;
856 #ifdef SPI_BRIDGE_DEBUG
860 g_signal_query (signal_hint->signal_id, &signal_query);
862 name = signal_query.signal_name;
863 if (signal_hint->detail)
864 detail = g_quark_to_string (signal_hint->detail);
868 #ifdef SPI_BRIDGE_DEBUG
869 s2 = g_type_name (G_OBJECT_TYPE (g_value_get_object (param_values + 0)));
870 s = atk_object_get_name (ATK_OBJECT (g_value_get_object (param_values + 0)));
871 fprintf (stderr, "Received signal %s:%s detail: %s from object %s (gail %s)\n",
872 g_type_name (signal_query.itype), name,
873 detail ? detail : "<NULL>", s ? s : "<NULL>" , s2);
876 gobject = g_value_get_object (param_values + 0);
878 if (signal_query.signal_id == atk_signal_active_descendant_changed)
880 gpointer child = g_value_get_pointer (param_values + 1);
882 g_return_val_if_fail (ATK_IS_OBJECT (child), TRUE);
884 ao = ATK_OBJECT (child);
886 detail1 = atk_object_get_index_in_parent (ao);
887 s_ao = spi_accessible_new (ao);
888 c_obj = BONOBO_OBJREF (s_ao);
889 spi_init_any_object (&any, &c_obj);
891 else if (signal_query.signal_id == atk_signal_link_selected)
893 if (G_VALUE_TYPE (param_values + 1) == G_TYPE_INT)
894 detail1 = g_value_get_int (param_values + 1);
895 spi_init_any_nil (&any);
897 else if ((signal_query.signal_id == atk_signal_children_changed) && gobject)
899 ao = atk_object_ref_accessible_child (ATK_OBJECT (gobject),
903 s_ao = spi_accessible_new (ao);
904 c_obj = BONOBO_OBJREF (s_ao);
905 spi_init_any_object (&any, &c_obj);
910 spi_init_any_nil (&any);
915 if (n_param_values >= 2)
917 if (G_VALUE_TYPE (param_values + 1) == G_TYPE_INT)
918 detail1 = g_value_get_int (param_values + 1);
919 if (n_param_values >= 3)
921 if (G_VALUE_TYPE (param_values + 2) == G_TYPE_INT)
922 detail2 = g_value_get_int (param_values + 2);
926 if (signal_query.signal_id == atk_signal_text_changed)
928 sp = atk_text_get_text (ATK_TEXT (gobject),
931 spi_init_any_string (&any, &sp);
933 else if (signal_query.signal_id == atk_signal_text_selection_changed)
935 text = ATK_TEXT (gobject);
937 /* Return NULL as the selected string */
938 spi_init_any_nil (&any);
942 spi_init_any_nil (&any);
947 spi_atk_emit_eventv (gobject, detail1, detail2, &any,
948 "object:%s:%s", name, detail);
950 spi_atk_emit_eventv (gobject, detail1, detail2, &any,
960 spi_atk_bridge_window_event_listener (GSignalInvocationHint *signal_hint,
961 guint n_param_values,
962 const GValue *param_values,
966 GSignalQuery signal_query;
968 const gchar *name, *s;
969 #ifdef SPI_BRIDGE_DEBUG
973 g_signal_query (signal_hint->signal_id, &signal_query);
975 name = signal_query.signal_name;
977 #ifdef SPI_BRIDGE_DEBUG
978 s2 = g_type_name (G_OBJECT_TYPE (g_value_get_object (param_values + 0)));
979 s = atk_object_get_name (ATK_OBJECT (g_value_get_object (param_values + 0)));
980 fprintf (stderr, "Received signal %s:%s from object %s (gail %s)\n",
981 g_type_name (signal_query.itype), name, s ? s : "<NULL>" , s2);
984 gobject = g_value_get_object (param_values + 0);
986 s = atk_object_get_name (ATK_OBJECT (gobject));
987 spi_init_any_string (&any, (char **) &s);
989 spi_atk_emit_eventv (gobject, 0, 0, &any,
995 spi_atk_tidy_windows (void)
1001 root = atk_get_root ();
1002 n_children = atk_object_get_n_accessible_children (root);
1003 for (i = 0; i < n_children; i++)
1006 AtkStateSet *stateset;
1010 child = atk_object_ref_accessible_child (root, i);
1011 stateset = atk_object_ref_state_set (child);
1013 name = atk_object_get_name (child);
1014 spi_init_any_string (&any, (char**) &name);
1015 if (atk_state_set_contains_state (stateset, ATK_STATE_ACTIVE))
1017 spi_atk_emit_eventv (G_OBJECT (child), 0, 0, &any, "window:deactivate");
1021 spi_atk_emit_eventv (G_OBJECT (child), 0, 0, &any, "window:destroy");
1022 g_object_unref (child);
1027 reinit_register_vars (void)
1029 registry = CORBA_OBJECT_NIL;
1030 device_event_controller = CORBA_OBJECT_NIL;