+ DBusError error;
+
+ spi_registry_set_debug (g_getenv ("AT_SPI_DEBUG"));
+ /*
+ * TODO: FIXME, this module makes the foolish assumptions that
+ * registryd uses the same display as the apps, and that the
+ * DISPLAY environment variable is set.
+ */
+ gdk_init (NULL, NULL);
+
+ registry->exit_notify_timeout = 200;
+ registry->queue_handler_id = 0;
+
+ dbus_error_init (&error);
+ registry->droute.bus = dbus_bus_get(DBUS_BUS_SESSION, &error);
+ if (!registry->droute.bus)
+ {
+ g_warning("Couldn't connect to dbus: %s\n", error.message);
+ return;
+ }
+ registry->droute.user_data = registry;
+ spi_registry_initialize_registry_interface (®istry->droute);
+ spi_registry_initialize_desktop_interface (®istry->droute);
+ spi_registry_initialize_dec_interface (®istry->droute);
+ // todo: initialize accessible and component interfaces, for desktop?
+ if (!dbus_connection_try_register_fallback (registry->droute.bus, "/org/freedesktop/atspi", &droute_vtable, ®istry->droute, &error))
+ {
+ g_warning("Couldn't register droute.\n");
+ }
+ dbus_connection_setup_with_g_main(registry->droute.bus, g_main_context_default());
+
+ // TODO: decide whether focus_object is still relevant
+ registry->desktop = spi_desktop_new ();
+ /* Register callback notification for application addition and removal */
+ g_signal_connect (G_OBJECT (registry->desktop),
+ "application_added",
+ G_CALLBACK (desktop_add_application),
+ registry);
+
+ g_signal_connect (G_OBJECT (registry->desktop),
+ "application_removed",
+ G_CALLBACK (desktop_remove_application),
+ registry);
+
+ registry->de_controller = spi_device_event_controller_new (registry);