Added new test that uses the C bindings API (test/simple-at).
authorbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Sat, 18 Aug 2001 20:27:40 +0000 (20:27 +0000)
committerbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Sat, 18 Aug 2001 20:27:40 +0000 (20:27 +0000)
Bugfix for AccessibleEventListener.

git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@38 e2bd861d-eb25-0410-b326-f6ed22b6b98c

ChangeLog
Makefile.am
cspi/spi.h
cspi/spi_main.c
libspi/accessibleeventlistener.c
libspi/eventlistener.c
test/Makefile.am
test/simple-at.c [new file with mode: 0644]

index 5c84fda..f0d5258 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2001-08-18  Bill Haneman <bill.haneman@sun.com>
 
+       * Makefile.am : changed build order to build test last.
+       * cspi/spi.h :
+       * cspi/spi_main.c :
+       Changed "createEventListener" to "CreateEventListener".
+       * libspi/accessibleeventlistener.c :
+       Bugfix for addition of callbacks.
+       * test/Makefile.am :
+       * test/simple-at.c :
+       Added new test that uses the C bindings API.
+
+2001-08-18  Bill Haneman <bill.haneman@sun.com>
+
        * Makefile.am: 
        * configure.in :
        * cspi/Makefile.am :
index d44e841..99b9331 100644 (file)
@@ -1,3 +1,3 @@
-SUBDIRS=po docs idl libspi registryd test at-bridge cspi
+SUBDIRS=po docs idl libspi registryd at-bridge cspi test
 
 EXTRA_DIST= xml-i18n-extract.in xml-i18n-merge.in xml-i18n-update.in
index 7fd1ec0..b32aae8 100644 (file)
@@ -79,7 +79,7 @@ SPI_exit (void);
  */
 
 AccessibleEventListener *
-createEventListener (AccessibleEventListenerCB callback);
+CreateEventListener (AccessibleEventListenerCB callback);
 
 boolean
 EventListener_addCallback (AccessibleEventListener *listener,
index 2eb15ce..fcf61d3 100644 (file)
@@ -93,6 +93,7 @@ CreateEventListener (AccessibleEventListenerCB callback)
     {
       accessible_event_listener_add_callback (listener, callback);
     }
+  return listener;
 }
 
 boolean
@@ -220,7 +221,7 @@ Accessible_getParent (Accessible *obj)
 long
 Accessible_getChildCount (Accessible *obj)
 {
-  return Accessibility_Accessible_getChildCount (*obj, &ev);
+  return Accessibility_Accessible__get_childCount (*obj, &ev);
 }
 
 Accessible *
@@ -293,7 +294,7 @@ AccessibleApplication_getVersion (AccessibleApplication *obj)
 long
 AccessibleApplication_getID (AccessibleApplication *obj)
 {
-  return Accessibility_Application__getID (*obj, &ev);
+  return Accessibility_Application__get_id (*obj, &ev);
 }
 
 /* Not Yet Implemented */
index 8f4eaa2..41a4050 100644 (file)
@@ -81,7 +81,10 @@ impl_accessible_event_notify_event (PortableServer_Servant     servant,
   for (n=0; n<len; ++n)
     {
       cb =  (VoidEventListenerCB) g_list_nth_data (listener->callbacks, n);
-      (*cb) (NULL);
+      if (cb)
+        {
+          (*cb) (NULL);
+        }
     }
   bonobo_object_release_unref (e->target, ev);
 }
@@ -151,11 +154,11 @@ accessible_event_listener_new ()
 void   accessible_event_listener_add_callback (AccessibleEventListener *listener,
                                                VoidEventListenerCB callback)
 {
-  listener->callbacks = g_list_append (listener->callbacks, listener);
+  listener->callbacks = g_list_append (listener->callbacks, callback);
 }
 
 void   accessible_event_listener_remove_callback (AccessibleEventListener *listener,
                                                   VoidEventListenerCB callback)
 {
-  listener->callbacks = g_list_remove (listener->callbacks, listener);
+  listener->callbacks = g_list_remove (listener->callbacks, callback);
 }
index 8f4eaa2..41a4050 100644 (file)
@@ -81,7 +81,10 @@ impl_accessible_event_notify_event (PortableServer_Servant     servant,
   for (n=0; n<len; ++n)
     {
       cb =  (VoidEventListenerCB) g_list_nth_data (listener->callbacks, n);
-      (*cb) (NULL);
+      if (cb)
+        {
+          (*cb) (NULL);
+        }
     }
   bonobo_object_release_unref (e->target, ev);
 }
@@ -151,11 +154,11 @@ accessible_event_listener_new ()
 void   accessible_event_listener_add_callback (AccessibleEventListener *listener,
                                                VoidEventListenerCB callback)
 {
-  listener->callbacks = g_list_append (listener->callbacks, listener);
+  listener->callbacks = g_list_append (listener->callbacks, callback);
 }
 
 void   accessible_event_listener_remove_callback (AccessibleEventListener *listener,
                                                   VoidEventListenerCB callback)
 {
-  listener->callbacks = g_list_remove (listener->callbacks, listener);
+  listener->callbacks = g_list_remove (listener->callbacks, callback);
 }
index 0c48983..52c3020 100644 (file)
@@ -1,19 +1,23 @@
 NULL=
 
-noinst_PROGRAMS = at app
+noinst_PROGRAMS = at app simple-at
 
 at_SOURCES = at.c
 
 app_SOURCES = app.c
 
+simple_at_SOURCES = simple-at.c
+
 INCLUDES = -I$(top_srcdir)           \
            -I$(top_builddir)         \
            -I$(top_srcdir)/libspi    \
            -I$(top_builddir)/libspi  \
+          -I$(top_srcdir)/cspi      \
+          -I$(top_builddir)/cspi    \
           $(TESTS_CFLAGS)
 
 DEBUG_CFLAGS=-DSPI_DEBUG
 
 CFLAGS += $(TESTS_CFLAGS) $(DEBUG_CFLAGS)
 
-LDADD = ../libspi/libspi.la $(TESTS_LIBS)
+LDADD = ../libspi/libspi.la ../cspi/libcspi.la $(TESTS_LIBS)
diff --git a/test/simple-at.c b/test/simple-at.c
new file mode 100644 (file)
index 0000000..a0438f2
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2001 Sun Microsystems 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 <stdlib.h>
+#include "spi.h"
+
+void report_focus_event (void *fp);
+
+void report_button_press (void *fp);
+
+int
+main(int argc, char **argv)
+{
+  int i, j;
+  int n_desktops;
+  int n_apps;
+  Accessible *desktop;
+  Accessible *application;
+  AccessibleEventListener *focus_listener;
+  AccessibleEventListener *button_listener;
+
+  SPI_init();
+
+  focus_listener = CreateEventListener (report_focus_event);
+  button_listener = CreateEventListener (report_button_press);
+
+  RegisterGlobalEventListener (focus_listener, "focus:");
+  RegisterGlobalEventListener (button_listener, "Gtk:GtkWidget:button-press-event");
+
+  n_desktops = GetDesktopCount ();
+
+  for (i=0; i<n_desktops; ++i)
+    {
+      desktop = getDesktop (i);
+      fprintf (stderr, "desktop %d name: %s\n", i, Accessible_getName (desktop));
+      n_apps = Accessible_getChildCount (desktop);
+      for (j=0; j<n_apps; ++j)
+        {
+          application = Accessible_getChildAtIndex (desktop, j);
+          fprintf (stderr, "app %d name: %s\n", j, Accessible_getName (application));
+        }
+    }
+  SPI_event_main(FALSE);
+}
+
+void
+report_focus_event (void *fp)
+{
+  fprintf (stderr, "focus\n");
+}
+
+void
+report_button_press (void *fp)
+{
+  fprintf (stderr, "button press\n");
+}