From ba30f6ce5f99bcde88352ef61b42cfc1241d7636 Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 11 Dec 2001 12:37:44 +0000 Subject: [PATCH] Re-work the bonobo code. git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@172 e2bd861d-eb25-0410-b326-f6ed22b6b98c --- cspi/bonobo/Makefile.am | 13 +++++--- cspi/bonobo/cspi-bonobo-listener.c | 63 ++++++++++++++++++++++++++------------ cspi/bonobo/cspi-bonobo-listener.h | 8 ++--- cspi/bonobo/cspi-bonobo.c | 42 +++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 27 deletions(-) create mode 100644 cspi/bonobo/cspi-bonobo.c diff --git a/cspi/bonobo/Makefile.am b/cspi/bonobo/Makefile.am index 6e65894..195e248 100644 --- a/cspi/bonobo/Makefile.am +++ b/cspi/bonobo/Makefile.am @@ -1,7 +1,12 @@ -noinst_LTLIBRARIES = libcspi-bonobo.la +INCLUDES = -I $(top_srcdir) \ + -I $(top_builddir) \ + $(LIBCSPI_CFLAGS) +noinst_LTLIBRARIES = libcspi-bonobo.la libcspi_bonobo_la_SOURCES = \ - spi-bonobo.h \ - spi-bonobo-listener.c \ - spi-bonobo-listener.h \ + cspi-bonobo.c \ + cspi-bonobo-listener.c \ + cspi-bonobo-listener.h + +libcspi_bonobo_la_LIBADD = $(LIBCSPI_LIBS) diff --git a/cspi/bonobo/cspi-bonobo-listener.c b/cspi/bonobo/cspi-bonobo-listener.c index c87aa31..1d1eabd 100644 --- a/cspi/bonobo/cspi-bonobo-listener.c +++ b/cspi/bonobo/cspi-bonobo-listener.c @@ -1,5 +1,6 @@ -#include -#include +#include +#include "../spi-private.h" +#include "cspi-bonobo-listener.h" typedef struct { @@ -37,7 +38,7 @@ event_handler_free (EventHandler *handler) } static GList * -event_list_remove_by_callback (GList *list, gpointer callback) +event_list_remove_by_cb (GList *list, gpointer callback) { GList *l, *next; @@ -120,28 +121,40 @@ cspi_event_listener_class_init (CSpiEventListenerClass *klass) klass->event = cspi_event; } -CSpiEventListener * +CORBA_Object cspi_event_listener_new (void) { - return g_object_new (cspi_event_listener_get_type (), NULL); + CSpiEventListener *listener; + + listener = g_object_new (cspi_event_listener_get_type (), NULL); + + return CORBA_Object_duplicate (BONOBO_OBJREF (listener), cspi_ev ()); } void -cspi_event_listener_add_callback (CSpiEventListener *listener, - AccessibleEventListenerCB callback, - void *user_data) +cspi_event_listener_add_cb (AccessibleEventListener *al, + AccessibleEventListenerCB callback, + void *user_data) { + CSpiEventListener *listener = bonobo_object ( + ORBit_small_get_servant (CSPI_OBJREF (al))); + g_return_if_fail (CSPI_IS_EVENT_LISTENER (listener)); + listener->callbacks = g_list_prepend (listener->callbacks, event_handler_new (callback, user_data)); } void -cspi_event_listener_remove_callback (CSpiEventListener *listener, - AccessibleEventListenerCB callback) +cspi_event_listener_remove_cb (AccessibleEventListener *al, + AccessibleEventListenerCB callback) { + CSpiEventListener *listener = bonobo_object ( + ORBit_small_get_servant (CSPI_OBJREF (al))); + g_return_if_fail (CSPI_IS_EVENT_LISTENER (listener)); - listener->callbacks = event_list_remove_by_callback (listener->callbacks, callback); + + listener->callbacks = event_list_remove_by_cb (listener->callbacks, callback); } /* @@ -238,26 +251,38 @@ BONOBO_TYPE_FUNC (CSpiKeystrokeListener, spi_keystroke_listener_get_type (), cspi_keystroke_listener); -CSpiKeystrokeListener * +CORBA_Object cspi_keystroke_listener_new (void) { - return g_object_new (cspi_keystroke_listener_get_type (), NULL); + CSpiEventListener *listener; + + listener = g_object_new (cspi_keystroke_listener_get_type (), NULL); + + return CORBA_Object_duplicate (BONOBO_OBJREF (listener), cspi_ev ()); } void -cspi_keystroke_listener_add_callback (CSpiKeystrokeListener *listener, - AccessibleKeystrokeListenerCB callback, - void *user_data) +cspi_keystroke_listener_add_cb (AccessibleKeystrokeListener *al, + AccessibleKeystrokeListenerCB callback, + void *user_data) { + CSpiKeystrokeListener *listener = bonobo_object ( + ORBit_small_get_servant (CSPI_OBJREF (al))); + g_return_if_fail (CSPI_IS_KEYSTROKE_LISTENER (listener)); + listener->callbacks = g_list_prepend (listener->callbacks, event_handler_new (callback, user_data)); } void -cspi_keystroke_listener_remove_callback (CSpiKeystrokeListener *listener, - AccessibleKeystrokeListenerCB callback) +cspi_keystroke_listener_remove_cb (AccessibleKeystrokeListener *al, + AccessibleKeystrokeListenerCB callback) { + CSpiKeystrokeListener *listener = bonobo_object ( + ORBit_small_get_servant (CSPI_OBJREF (al))); + g_return_if_fail (CSPI_IS_KEYSTROKE_LISTENER (listener)); - listener->callbacks = event_list_remove_by_callback (listener->callbacks, callback); + + listener->callbacks = event_list_remove_by_cb (listener->callbacks, callback); } diff --git a/cspi/bonobo/cspi-bonobo-listener.h b/cspi/bonobo/cspi-bonobo-listener.h index 073e607..0268df9 100644 --- a/cspi/bonobo/cspi-bonobo-listener.h +++ b/cspi/bonobo/cspi-bonobo-listener.h @@ -14,10 +14,10 @@ G_BEGIN_DECLS #define CSPI_IS_EVENT_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CSPI_EVENT_LISTENER_TYPE)) #define CSPI_IS_EVENT_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CSPI_EVENT_LISTENER_TYPE)) -struct _CSpiEventListener { +typedef struct { SpiEventListener parent; GList *callbacks; -}; +} CSpiEventListener; typedef SpiEventListenerClass CSpiEventListenerClass; GType cspi_event_listener_get_type (void); @@ -28,10 +28,10 @@ GType cspi_event_listener_get_type (void); #define CSPI_IS_KEYSTROKE_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CSPI_KEYSTROKE_LISTENER_TYPE)) #define CSPI_IS_KEYSTROKE_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CSPI_KEYSTROKE_LISTENER_TYPE)) -struct _CSpiKeystrokeListener { +typedef struct { SpiKeystrokeListener parent; GList *callbacks; -}; +} CSpiKeystrokeListener; typedef SpiKeystrokeListenerClass CSpiKeystrokeListenerClass; GType cspi_keystroke_listener_get_type (void); diff --git a/cspi/bonobo/cspi-bonobo.c b/cspi/bonobo/cspi-bonobo.c new file mode 100644 index 0000000..891b029 --- /dev/null +++ b/cspi/bonobo/cspi-bonobo.c @@ -0,0 +1,42 @@ +#include "../cspi-lowlevel.h" + +#include + +void +cspi_dup_ref (CORBA_Object object) +{ + bonobo_object_dup_ref (object, NULL); +} + +void +cspi_release_unref (CORBA_Object object) +{ + bonobo_object_release_unref (object, NULL); +} + +SPIBoolean +cspi_check_ev (const char *error_string) +{ + CORBA_Environment *ev = cspi_ev (); + + if (ev->_major != CORBA_NO_EXCEPTION) + { + char *err; + + err = bonobo_exception_get_text (ev); + + fprintf (stderr, "Warning: AT-SPI error: %s: %s\n", + error_string, err); + + g_free (err); + + CORBA_exception_free (ev); + + return FALSE; + } + else + { + return TRUE; + } +} + -- 2.7.4