+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <libbonobo.h>
-#include "Registry.h"
-#include "Event.h"
-#include "accessible.h"
-#include "listener.h"
-#include "desktop.h"
+#include <libspi/Accessibility.h>
+#include <libspi/accessible.h>
+#include <libspi/listener.h>
+
+void
+check_ev (CORBA_Environment *ev, char *desc)
+{
+ if (ev->_major != CORBA_NO_EXCEPTION) {
+ fprintf(stderr,
+ ("Accessibility app error: exception during CORBA call %s (%s)\n"),
+ CORBA_exception_id(ev), desc);
+ CORBA_exception_free(ev);
+ exit(-1);
+ }
+}
int
main(int argc, char **argv)
CORBA_short n_desktops;
CORBA_long j;
CORBA_long n_apps;
+ CORBA_string s;
Accessibility_Desktop desktop;
Accessibility_Application app;
-
Accessibility_Registry registry;
- Listener *listener;
+ SpiListener *listener;
CORBA_exception_init(&ev);
g_error ("Could not initialize Bonobo");
}
- obj_id = "OAFIID:Accessibility_Registry:proto0.1";
+ obj_id = "OAFIID:Accessibility_Registry:1.0";
- oclient = oaf_activate_from_id (obj_id, 0, NULL, &ev);
+ oclient = bonobo_activation_activate_from_id (obj_id, 0, NULL, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
fprintf(stderr,
("Accessibility app error: exception during registry activation from id: %s\n"),
bonobo_activate ();
- listener = listener_new ();
+ listener = spi_listener_new ();
registry = (Accessibility_Registry) oclient;
(registry,
(Accessibility_EventListener)
bonobo_object_corba_objref (bonobo_object (listener)),
- "test",
+ "focus:",
&ev);
-
+ check_ev (&ev, "register:focus");
+ Accessibility_Registry_registerGlobalEventListener
+ (registry,
+ (Accessibility_EventListener)
+ bonobo_object_corba_objref (bonobo_object (listener)),
+ "Gtk:GtkWidget:button-press-event",
+ &ev);
+ check_ev (&ev, "register:button_press");
fprintf (stderr, "AT callback registered.\n");
-
n_desktops = Accessibility_Registry_getDesktopCount (registry, &ev);
for (i=0; i<n_desktops; ++i)
{
desktop = Accessibility_Registry_getDesktop (registry, i, &ev);
- fprintf (stderr, "desktop %d name: %s\n", i,
- Accessibility_Desktop__get_name (desktop, &ev));
+ s = Accessibility_Desktop__get_name (desktop, &ev);
+ fprintf (stderr, "desktop %d name: %s\n", i, s);
+ CORBA_free (s);
+ check_ev (&ev, "desktop:name");
n_apps = Accessibility_Desktop__get_childCount (desktop, &ev);
+ check_ev (&ev, "desktop:childCount");
fprintf (stderr, "desktop has %d apps:\n", n_apps);
for (j=0; j<n_apps; ++j)
{
app = (Accessibility_Application) Accessibility_Desktop_getChildAtIndex (desktop, j, &ev);
- fprintf (stderr, "app %d name: %s\n", j,
- Accessibility_Application__get_name (app, &ev));
+ check_ev (&ev, "desktop:getChildAtIndex");
+ s = Accessibility_Application__get_name (app, &ev);
+ fprintf (stderr, "app %d name: %s\n", j, s);
+ CORBA_free (s);
+ check_ev (&ev, "app:getName");
}
}