+2001-11-28 Bill Haneman <bill.haneman@sun.com>
+
+ Merged Michael's branch (see his ChangeLog entries below).
+
+ * at-bridge/bridge.c: Explicitly hold a ref to the registry while
+ bridge is alive, release on exit.
+
+ * cspi/spi-listener-impl.c (cspi_event_listener_add_callback):
+ Fix type check macro.
+
+ * cspi/spi_event.c:
+ Added AccessibleKeystrokeListener_unref() method to reduce leakage.
+
+ * cspi/spi_main.c:
+ Added is_gnome_app static, and method cspi_is_gnome_app(),
+ so we can call the appropriate shutdown routine at exit in SPI_exit.
+
+ * cspi/spi_main.c (cspi_object_ref):
+ Duplicate the corba object passed in, since we're keeping it around.
+
+ * cspi/SPI_exit.c, cspi_cleanup:
+ Moved the releasing of the live refs to its own function, so we
+ can put it in g_atexit (). Call the appropriate shutdown API
+ depending on whethe calling client is a gnome app or not
+ (bonobo_main_quit or CORBA_ORB_shutdown).
+
+ * cspi/spi_registry.c (deregisterGlobalEventListenerAll):
+ Unref the listener when this method is called, after
+ deregistration. Updated the API docs to note this behavior.
+
+ * libspi/accessible.c (impl_get_parent, impl_get_child_at_index):
+ Bugfixes: Ref the bonobo object when returning a parent or child
+ reference, or an AccessibleRelation. Generally made sure
+ BonoboObject refcount is incremented whenever we return an
+ Accessible.
+
+ * libspi/accessibleeventlistener.c (spi_event_listener_class_init):
+ Fixed typo/bug in signal declaration.
+
+ * libspi/accessibleeventlistener.h:
+ Fixed a type macro.
+
+ * libspi/application.c (spi_application_new):
+ Fixed leak in initialization.
+
+ * libspi/desktop.c:
+ Remembered to increment bonobo-object refcount when returning
+ children (applications) from desktop object.
+ Added (empty) finalize method.
+
+ * libspi/deviceeventcontroller.c:
+ Hold a ref to listeners inside DEControllerKeyListeners.
+ Added dec_key_listener_free() method. Use prepend instead of
+ append in key_listener list. Fixed some refcount madness and
+ leaks in the listener registration/deregistration - deregistration
+ now calls dec_key_listener_free() on listeners, and on the
+ temporarily constructed dec_key_listener() used to perform the search/match.
+
+ * libspi/hypertext.c (spi_hypertest_finalize):
+ Fixed 'double unref' of AtkObject held by parent SpiAccessibleText
+ class. Also fixed spi_hypertext_interface_new() and
+ SpiHypertextClass. Fixed a couple of paren-whitespace formatting bugs.
+
+ * libspi/hypertext.h:
+ Removed pointless and duplicate AtkObject pointer from
+ SpiHypertextClass.
+
+ * libspi/keystrokelistener.c:
+ Fixed incorrect type of keystroke_listener_parent_class,
+ renamed keystroke_listener_object_finalize to
+ spi_keystroke_listener_object_finalize.
+ Fixed typo in signal declaration
+ (spi_keystroke_listener_class_init).
+
+ * libspi/registry.c:
+ Added funcsions spi_listener_struct_new() and
+ spi_listener_struct_free() to help with memory management issues.
+ We also now use these methods instead of gnew + poking stuff into
+ the struct, and to decrement listener counts/free the listeners
+ when deregistering them.
+ Fix more refcount bugs in getDesktop() and
+ getDeviceEventController().
+
+ * test/simple-at.c:
+ De-ref the desktop after enumerating the applications. Explicitly
+ decrement the refcounts on the created listeners on exit (using
+ _unref for keystroke listeners, and via the
+ deregisterGlobalEventListenerAll command for other event
+ listeners).
+
+2001-11-27 Michael Meeks <michael@ximian.com>
+
+ * cspi/spi-listener.h: fixup enum.
+
+2001-11-27 Michael Meeks <michael@ximian.com>
+
+ * cspi/spi-listener-impl.c (cspi_event_listener_new),
+ (cspi_keystroke_listener_new): Use the cspi variants.
+
+2001-11-26 Michael Meeks <michael@ximian.com>
+
+ * test/keysynth-demo.c: fix 2 compile warnings, missing
+ type in decl. etc.
+
+ * test/simple-at.c (report_focussed_accessible),
+ (report_focus_event, report_button_press),
+ (check_property_change, is_command_key),
+ (report_ordinary_key_event, report_command_key_event): upd.
+
+ * util/mag_client.h: include pre-requisites.
+
+ * libspi/accessibleeventlistener.c
+ (spi_event_listener_object_finalize): free any lingering
+ callbacks.
+
+ * libspi/keystrokelistener.c
+ (keystroke_listener_object_finalize): ditto.
+
+ * cspi/spi-listener-impl.[ch]: Add to implement cspi style
+ callbacks, with cspi types.
+
+ * cspi/spi_event.c (createAccessibleEventListener): chain to
+ (AccessibleEventListener_addCallback): here.
+ (createAccessibleKeystrokeListener): chain to
+ (AccessibleKeystrokeListener_addCallback): here.
+
+ * libspi/keystrokelistener.c
+ (spi_keystroke_listener_class_init): add signal.
+ (impl_key_event): emit the event.
+ (boolean_handled_accumulator): impl.
+ (marshal_BOOLEAN__POINTER): add, gack.
+
+ * libspi/accessibleeventlistener.c
+ (spi_event_listener_class_init): add signal.
+ (impl_accessible_event_notify_event): emit the signal &
+ make the loop efficient.
+ (spi_event_listener_add_callback): prepend the callback.
+
+ * libspi/accessibleeventlistener.h: add an 'event' signal,
+ decl type on callback.
+
+ * libspi/keystrokelistener.h: ditto.
+
+ * cspi/spi-listener.h: make methods typesafe and
+ make them use the new event typedefs.
+
+ * test/simple-at.c (report_focussed_accessible):
+ include mag_client.h
+ Use *(void *)text_interface not the other thing.
+
+ * configure.in: add gtk to registryd bits - since we use
+ gdk there ( why ? )
+
+ * util/magnifier.c: include libbonobo.h
+
2001-11-25 Bill Haneman <bill.haneman@sun.com>
* test/keysynth-demo.c:
("Accessibility app error: exception during registry activation from id: %s\n"),
CORBA_exception_id(&ev));
CORBA_exception_free(&ev);
- exit(-1);
}
if (CORBA_Object_is_nil (oclient, &ev))
fprintf(stderr, "About to register application\n");
+ Accessibility_Registry_ref (registry, &ev);
+
bonobo_activate ();
Accessibility_Registry_registerApplication (registry,
Accessibility_Registry_deregisterApplication (registry,
CORBA_Object_duplicate (BONOBO_OBJREF (this_app), &ev),
&ev);
+ Accessibility_Registry_unref (registry, &ev);
+
fprintf (stderr, "bridge exit func complete.\n");
}
("Accessibility app error: exception during registry activation from id: %s\n"),
CORBA_exception_id(&ev));
CORBA_exception_free(&ev);
- exit(-1);
}
if (CORBA_Object_is_nil (oclient, &ev))
fprintf(stderr, "About to register application\n");
+ Accessibility_Registry_ref (registry, &ev);
+
bonobo_activate ();
Accessibility_Registry_registerApplication (registry,
Accessibility_Registry_deregisterApplication (registry,
CORBA_Object_duplicate (BONOBO_OBJREF (this_app), &ev),
&ev);
+ Accessibility_Registry_unref (registry, &ev);
+
fprintf (stderr, "bridge exit func complete.\n");
}
AC_SUBST(LIBSPI_LIBS)
AC_SUBST(LIBSPI_CFLAGS)
-PKG_CHECK_MODULES(REGISTRYD, bonobo-activation-2.0 >= 0.9.1 libbonobo-2.0 >= 1.97.0 atk >= 0.2)
+PKG_CHECK_MODULES(REGISTRYD, bonobo-activation-2.0 >= 0.9.1 libbonobo-2.0 >= 1.97.0 atk >= 0.2 gdk-2.0)
AC_SUBST(REGISTRYD_LIBS)
AC_SUBST(REGISTRYD_CFLAGS)
spi-statetypes.h
libcspi_la_SOURCES = \
- spi_main.c \
- spi_event.c \
- spi_registry.c \
- spi-util.c \
spi_accessible.c \
spi_action.c \
spi_application.c \
spi_component.c \
spi_editabletext.c \
+ spi_event.c \
spi_hyperlink.c \
spi_hypertext.c \
spi_image.c \
+ spi-listener-impl.h \
+ spi-listener-impl.c \
+ spi_main.c \
spi-private.h \
+ spi_registry.c \
spi_selection.c \
spi_table.c \
spi_text.c \
+ spi-util.c \
spi_value.c
CSpiEventListener *
cspi_event_listener_new (void)
{
- return g_object_new (spi_event_listener_get_type (), NULL);
+ return g_object_new (cspi_event_listener_get_type (), NULL);
}
void
cspi_event_listener_add_callback (CSpiEventListener *listener,
AccessibleEventListenerCB callback)
{
- g_return_if_fail (IS_CSPI_KEYSTROKE_LISTENER (listener));
+ g_return_if_fail (IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER (listener));
listener->callbacks = g_slist_prepend (listener->callbacks, callback);
}
CSpiKeystrokeListener *
cspi_keystroke_listener_new (void)
{
- return g_object_new (spi_keystroke_listener_get_type (), NULL);
+ return g_object_new (cspi_keystroke_listener_get_type (), NULL);
}
void
SpiEventListener parent;
GSList *callbacks;
};
+
typedef SpiEventListenerClass CSpiEventListenerClass;
GType cspi_event_listener_get_type (void);
/*
- * Note: this header is a private implementation header, clients of
- * the at-spi interfaces or the C bindings in libcspi should
- * not depend on any of the information in this file directly,
- * as it it not intended for use as a public interface.
- *
- * You have been warned !
+ * A load of opaque handles that people can't poke at.
*/
-
#ifndef _SPI_IMPL_H_
#define _SPI_IMPL_H_
-#include <libspi/accessibleeventlistener.h>
-#include <libspi/keystrokelistener.h>
-#include <libspi/Accessibility.h>
-
-typedef unsigned int boolean;
+typedef struct _Accessible Accessible;
+typedef Accessible AccessibleAction;
+typedef Accessible AccessibleApplication;
+typedef Accessible AccessibleComponent;
+typedef Accessible AccessibleEditableText;
+typedef Accessible AccessibleHyperlink;
+typedef Accessible AccessibleHypertext;
+typedef Accessible AccessibleImage;
+typedef Accessible AccessibleRelation;
+typedef Accessible AccessibleSelection;
+typedef Accessible AccessibleStateSet;
+typedef Accessible AccessibleTable;
+typedef Accessible AccessibleText;
+typedef Accessible AccessibleValue;
+typedef Accessible AccessibilityRegistry;
+typedef Accessible GenericInterface;
-typedef CORBA_Object Accessible;
-typedef CORBA_Object AccessibleAction;
-typedef CORBA_Object AccessibleApplication;
-typedef CORBA_Object AccessibleComponent;
-typedef CORBA_Object AccessibleEditableText;
-typedef CORBA_Object AccessibleHyperlink;
-typedef CORBA_Object AccessibleHypertext;
-typedef CORBA_Object AccessibleImage;
-typedef CORBA_Object AccessibleRelation;
-typedef CORBA_Object AccessibleSelection;
-typedef CORBA_Object AccessibleStateSet;
-typedef CORBA_Object AccessibleTable;
-typedef CORBA_Object AccessibleText;
-typedef CORBA_Object AccessibleValue;
-typedef CORBA_Object AccessibilityRegistry;
-typedef CORBA_Object GenericInterface;
+typedef struct _CSpiEventListener AccessibleEventListener;
+typedef struct _CSpiKeystrokeListener AccessibleKeystrokeListener;
-typedef SpiKeystrokeListener AccessibleKeystrokeListener;
-typedef SpiEventListener AccessibleEventListener;
+typedef unsigned int boolean;
#endif
CSpiEventListener *
cspi_event_listener_new (void)
{
- return g_object_new (spi_event_listener_get_type (), NULL);
+ return g_object_new (cspi_event_listener_get_type (), NULL);
}
void
cspi_event_listener_add_callback (CSpiEventListener *listener,
AccessibleEventListenerCB callback)
{
- g_return_if_fail (IS_CSPI_KEYSTROKE_LISTENER (listener));
+ g_return_if_fail (IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER (listener));
listener->callbacks = g_slist_prepend (listener->callbacks, callback);
}
CSpiKeystrokeListener *
cspi_keystroke_listener_new (void)
{
- return g_object_new (spi_keystroke_listener_get_type (), NULL);
+ return g_object_new (cspi_keystroke_listener_get_type (), NULL);
}
void
SpiEventListener parent;
GSList *callbacks;
};
+
typedef SpiEventListenerClass CSpiEventListenerClass;
GType cspi_event_listener_get_type (void);
#ifndef _SPI_LISTENER_H_
#define _SPI_LISTENER_H_
-#include <libspi/accessibleeventlistener.h>
-#include <libspi/keystrokelistener.h>
+#include <cspi/spi-impl.h>
G_BEGIN_DECLS
/*
- *
* Structure used to encapsulate event information
- *
*/
-
-typedef Accessibility_Event AccessibleEvent;
+typedef struct {
+ const char *type;
+ Accessible *source;
+ long detail1;
+ long detail2;
+} AccessibleEvent;
+
+typedef enum {
+ SPI_KEY_PRESSED = 1<<0,
+ SPI_KEY_RELEASED = 1<<1
+} AccessibleKeyEventType;
+
+typedef struct {
+ long keyID;
+ short keycode;
+ long timestamp;
+ AccessibleKeyEventType type;
+ unsigned short modifiers;
+} AccessibleKeystroke;
/*
- *
* Function prototype typedefs for Event Listener Callbacks.
* (see libspi/accessibleeventlistener.h for definition of SpiVoidEventListenerCB).
*
*
* boolean (*AccessibleKeystrokeListenerCB) (AccessibleKeystrokeEvent *Event);
*/
-
-typedef VoidSpiEventListenerCB AccessibleEventListenerCB;
-typedef BooleanKeystrokeListenerCB AccessibleKeystrokeListenerCB;
+typedef void (*AccessibleEventListenerCB) (AccessibleEvent *event);
+typedef boolean (*AccessibleKeystrokeListenerCB) (AccessibleKeystroke *stroke);
G_END_DECLS
-#ifndef __SPI_PRIVATE_H__
-#define __SPI_PRIVATE_H__
+#ifndef _SPI_PRIVATE_H_
+#define _SPI_PRIVATE_H_
-#include <cspi/spi.h>
-
-G_BEGIN_DECLS
-
-CORBA_Environment *spi_ev (void);
-AccessibilityRegistry spi_registry (void);
-
-boolean spi_exception (void);
+/*
+ * Private internal implementation details of at-spi.
+ */
-Accessible *spi_object_add (Accessible corba_object);
-
-int SPI_init (void);
-void SPI_exit (void);
-
-G_END_DECLS
-
-#endif /* __SPI_PRIVATE_H__ */
+#include <libbonobo.h>
+#include <libspi/Accessibility.h>
+#include <cspi/spi.h>
+#include "cspi/spi-listener.h"
+
+struct _Accessible {
+ CORBA_Object objref;
+ /* And some other bits */
+ guint ref_count;
+};
+
+#define CSPI_OBJREF(a) (((Accessible *)(a))->objref)
+
+CORBA_Environment *cspi_ev (void);
+boolean cspi_exception (void);
+Accessibility_Registry cspi_registry (void);
+Accessible *cspi_object_add (CORBA_Object corba_object);
+void cspi_object_ref (Accessible *accessible);
+void cspi_object_unref (Accessible *accessible);
+boolean cspi_warn_ev (CORBA_Environment *ev,
+ const char *error_string);
+void cspi_check_ev (CORBA_Environment *ev,
+ const char *error_string);
+
+#endif /* _SPI_PRIVATE_H_ */
#include <stdlib.h>
-#include <libbonobo.h>
#include <cspi/spi-private.h>
void
}
boolean
-spi_warn_ev (CORBA_Environment *ev, const char *error_string)
+cspi_warn_ev (CORBA_Environment *ev, const char *error_string)
{
if (ev->_major != CORBA_NO_EXCEPTION)
{
}
void
-spi_check_ev (CORBA_Environment *ev, const char *error_string)
+cspi_check_ev (CORBA_Environment *ev, const char *error_string)
{
if (ev->_major != CORBA_NO_EXCEPTION)
{
SPI_COORD_TYPE_WINDOW
} AccessibleCoordType;
-/* XXX: must be single bits since they are used as masks in keylistener API */
-typedef enum {
- SPI_KEY_PRESSED = 1,
- SPI_KEY_RELEASED = 2
-} AccessibleKeyEventType;
-
typedef enum {
SPI_KEY_PRESS,
SPI_KEY_RELEASE,
typedef unsigned long AccessibleKeyEventMask;
-typedef struct _AccessibleKeyStroke
-{
- long keyID;
- short keycode;
- long timestamp;
- AccessibleKeyEventType type;
- unsigned short modifiers;
-} AccessibleKeyStroke;
/**
* AccessibleKeySet:
int
Accessible_ref (Accessible *obj)
{
- Accessibility_Accessible_ref (*obj, spi_ev ());
- spi_check_ev (spi_ev (), "ref");
+ cspi_object_ref (obj);
return 0;
}
int
Accessible_unref (Accessible *obj)
{
- Accessibility_Accessible_unref (*obj, spi_ev ());
- spi_check_ev (spi_ev (), "unref");
+ cspi_object_unref (obj);
return 0;
}
{
char *retval =
(char *)
- Accessibility_Accessible__get_name (*obj, spi_ev ());
- spi_check_ev (spi_ev (), "getName");
+ Accessibility_Accessible__get_name (CSPI_OBJREF (obj), cspi_ev ());
+ cspi_check_ev (cspi_ev (), "getName");
return retval;
}
Accessible_getDescription (Accessible *obj)
{
char *retval = (char *)
- Accessibility_Accessible__get_description (*obj, spi_ev ());
- spi_check_ev (spi_ev (), "getDescription");
+ Accessibility_Accessible__get_description (CSPI_OBJREF (obj), cspi_ev ());
+ cspi_check_ev (cspi_ev (), "getDescription");
return retval;
}
Accessible_getParent (Accessible *obj)
{
Accessible *retval =
- spi_object_add (Accessibility_Accessible__get_parent (*obj, spi_ev ()));
- spi_check_ev (spi_ev (), "getParent");
+ cspi_object_add (Accessibility_Accessible__get_parent (CSPI_OBJREF (obj), cspi_ev ()));
+ cspi_check_ev (cspi_ev (), "getParent");
return retval;
}
long
Accessible_getChildCount (Accessible *obj)
{
- long retval = (long) Accessibility_Accessible__get_childCount (*obj, spi_ev ());
- spi_check_ev (spi_ev (), "getChildCount");
+ long retval = (long) Accessibility_Accessible__get_childCount (CSPI_OBJREF (obj), cspi_ev ());
+ cspi_check_ev (cspi_ev (), "getChildCount");
return retval;
}
Accessible_getChildAtIndex (Accessible *obj,
long int childIndex)
{
- Accessible *retval = spi_object_add (Accessibility_Accessible_getChildAtIndex (*obj, childIndex, spi_ev ()));
- spi_check_ev (spi_ev (), "getChildAtIndex");
+ Accessible *retval = cspi_object_add (Accessibility_Accessible_getChildAtIndex (CSPI_OBJREF (obj), childIndex, cspi_ev ()));
+ cspi_check_ev (cspi_ev (), "getChildAtIndex");
return retval;
}
long
Accessible_getIndexInParent (Accessible *obj)
{
- long retval = (long) Accessibility_Accessible_getIndexInParent (*obj, spi_ev ());
- spi_check_ev (spi_ev (), "getIndexInParent");
+ long retval = (long) Accessibility_Accessible_getIndexInParent (CSPI_OBJREF (obj), cspi_ev ());
+ cspi_check_ev (cspi_ev (), "getIndexInParent");
return retval;
}
int n_relations;
int i;
Accessibility_RelationSet *relation_set =
- Accessibility_Accessible_getRelationSet (*obj, spi_ev ());
+ Accessibility_Accessible_getRelationSet (CSPI_OBJREF (obj), cspi_ev ());
/* this looks hack-ish, but it's based on the CORBA C bindings spec */
n_relations = relation_set->_length;
for (i=0; i<n_relations; ++i)
{
- relations[i] = spi_object_add (relation_set->_buffer[i]);
+ relations[i] = cspi_object_add (relation_set->_buffer[i]);
}
relations[i] = CORBA_OBJECT_NIL;
Accessible_getRole (Accessible *obj)
{
char *retval = AccessibleRole_getName (
- Accessibility_Accessible_getRole (*obj, spi_ev ()));
- spi_check_ev (spi_ev (), "getRole");
+ Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ()));
+ cspi_check_ev (cspi_ev (), "getRole");
return retval;
}
/* Interface query methods */
+static boolean
+cspi_accessible_is_a (Accessible *obj,
+ const char *interface_name)
+{
+ boolean retval;
+ Bonobo_Unknown unknown;
+
+ unknown = Bonobo_Unknown_queryInterface (CSPI_OBJREF (obj),
+ interface_name, cspi_ev ());
+
+ if (BONOBO_EX (cspi_ev ()))
+ {
+ g_error ("Exception '%s' checking if is '%s'",
+ bonobo_exception_get_text (cspi_ev ()),
+ interface_name);
+ }
+
+ if (unknown != CORBA_OBJECT_NIL)
+ {
+ retval = TRUE;
+ bonobo_object_release_unref (unknown, NULL);
+ }
+ else
+ {
+ retval= FALSE;
+ }
+
+ return retval;
+}
+
/**
* Accessible_isAction:
* @obj: a pointer to the #Accessible instance to query.
boolean
Accessible_isAction (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Action:1.0",
- spi_ev ());
- spi_warn_ev (spi_ev (), "isAction");
-
- return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE;
+ return cspi_accessible_is_a (obj,
+ "IDL:Accessibility/Action:1.0");
}
/**
boolean
Accessible_isComponent (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Component:1.0",
- spi_ev ());
- spi_warn_ev (spi_ev (), "isComponent");
-
- return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE;
+ return cspi_accessible_is_a (obj,
+ "IDL:Accessibility/Component:1.0");
}
/**
boolean
Accessible_isEditableText (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/EditableText:1.0",
- spi_ev ());
- spi_check_ev (spi_ev (), "isEditableText");
-
- return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE;
+ return cspi_accessible_is_a (obj,
+ "IDL:Accessibility/EditableText:1.0");
}
/**
boolean
Accessible_isHypertext (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Hypertext:1.0",
- spi_ev ());
-
- spi_check_ev (spi_ev (), "isHypertext");
-
- return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE;
+ return cspi_accessible_is_a (obj,
+ "IDL:Accessibility/Hypertext:1.0");
}
/**
boolean
Accessible_isImage (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Image:1.0",
- spi_ev ());
- spi_check_ev (spi_ev (), "isImage");
-
- return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE;
+ return cspi_accessible_is_a (obj,
+ "IDL:Accessibility/Image:1.0");
}
/**
boolean
Accessible_isSelection (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Selection:1.0",
- spi_ev ());
- spi_warn_ev (spi_ev (), "isSelection");
-
- return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE;
-
+ return cspi_accessible_is_a (obj,
+ "IDL:Accessibility/Selection:1.0");
}
/**
boolean
Accessible_isTable (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Table:1.0",
- spi_ev ());
- spi_check_ev (spi_ev (), "isTable");
-
- return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE;
-
+ return cspi_accessible_is_a (obj,
+ "IDL:Accessibility/Table:1.0");
}
/**
boolean
Accessible_isText (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Text:1.0",
- spi_ev ());
- spi_warn_ev (spi_ev (), "isText");
-
- return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE;
+ return cspi_accessible_is_a (obj,
+ "IDL:Accessibility/Text:1.0");
}
/**
boolean
Accessible_isValue (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Value:1.0",
- spi_ev ());
- spi_check_ev (spi_ev (), "isValue");
-
- return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE;
+ return cspi_accessible_is_a (obj,
+ "IDL:Accessibility/Value:1.0");
}
/**
AccessibleAction *
Accessible_getAction (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Action:1.0",
- spi_ev ());
- spi_check_ev (spi_ev (), "getAction");
-
- return (AccessibleAction *) spi_object_add (iface);
+ return (AccessibleAction *) Accessible_queryInterface (
+ obj, "IDL:Accessibility/Action:1.0");
}
/**
AccessibleComponent *
Accessible_getComponent (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Component:1.0",
- spi_ev ());
- spi_check_ev (spi_ev (), "getComponent");
-
- return (AccessibleComponent *) spi_object_add (iface);
+ return (AccessibleComponent *) Accessible_queryInterface (
+ obj, "IDL:Accessibility/Component:1.0");
}
/**
AccessibleEditableText *
Accessible_getEditableText (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/EditableText:1.0",
- spi_ev ());
- spi_check_ev (spi_ev (), "getEditableText");
-
- return (AccessibleEditableText *) spi_object_add (iface);
+ return (AccessibleEditableText *) Accessible_queryInterface (
+ obj, "IDL:Accessibility/EditableText:1.0");
}
AccessibleHypertext *
Accessible_getHypertext (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Hypertext:1.0",
- spi_ev ());
- spi_check_ev (spi_ev (), "getHypertext");
-
- return (AccessibleHypertext *) spi_object_add (iface);
+ return (AccessibleHypertext *) Accessible_queryInterface (
+ obj, "IDL:Accessibility/Hypertext:1.0");
}
AccessibleImage *
Accessible_getImage (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Image:1.0",
- spi_ev ());
- spi_check_ev (spi_ev (), "getImage");
-
- return (AccessibleImage *) spi_object_add (iface);
+ return (AccessibleImage *) Accessible_queryInterface (
+ obj, "IDL:Accessibility/Image:1.0");
}
AccessibleSelection *
Accessible_getSelection (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Selection:1.0",
- spi_ev ());
- spi_warn_ev (spi_ev (), "getSelection");
-
- return (AccessibleSelection *) spi_object_add (iface);
+ return (AccessibleSelection *) Accessible_queryInterface (
+ obj, "IDL:Accessibility/Selection:1.0");
}
AccessibleTable *
Accessible_getTable (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Table:1.0",
- spi_ev ());
- spi_check_ev (spi_ev (), "getTable");
-
- return (AccessibleTable *) spi_object_add (iface);
+ return (AccessibleTable *) Accessible_queryInterface (
+ obj, "IDL:Accessibility/Table:1.0");
}
/**
AccessibleText *
Accessible_getText (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Text:1.0",
- spi_ev ());
-
- spi_check_ev (spi_ev (), "getText");
-
- return (AccessibleText *) spi_object_add (iface);
+ return (AccessibleText *) Accessible_queryInterface (
+ obj, "IDL:Accessibility/Text:1.0");
}
AccessibleValue *
Accessible_getValue (Accessible *obj)
{
- Bonobo_Unknown iface =
- Accessibility_Accessible_queryInterface (*obj,
- "IDL:Accessibility/Value:1.0",
- spi_ev ());
- return (AccessibleValue *) spi_object_add (iface);
+ return (AccessibleValue *) Accessible_queryInterface (
+ obj, "IDL:Accessibility/Value:1.0");
}
GenericInterface *
Accessible_queryInterface (Accessible *obj, char *interface_name)
{
- GenericInterface iface;
- iface = Accessibility_Accessible_queryInterface (*obj,
- interface_name,
- spi_ev ());
- return spi_object_add (iface);
+ Bonobo_Unknown iface;
+
+ iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
+ interface_name,
+ cspi_ev ());
+
+ /*
+ * FIXME: we need to be fairly sure that references are going
+ * to mach up if we are going to expose QueryInterface, ie. we
+ * can't allow people to do:
+ * b = a.qi ("b"); b.unref, b.unref to release a's reference.
+ * this should be no real problem though for this level of API
+ * user.
+ */
+
+ return cspi_object_add (iface);
}
int
AccessibleRelation_ref (AccessibleRelation *obj)
{
- Accessibility_Relation_ref (*obj, spi_ev ());
- spi_check_ev (spi_ev (), "ref");
+ cspi_object_ref (obj);
return 0;
}
int
AccessibleRelation_unref (AccessibleRelation *obj)
{
- Accessibility_Relation_unref (*obj, spi_ev ());
- spi_check_ev (spi_ev (), "unref");
+ cspi_object_unref (obj);
return 0;
}
int
AccessibleStateSet_ref (AccessibleStateSet *obj)
{
-/* Accessibility_StateSet_ref (*obj, spi_ev ()); */
- spi_check_ev (spi_ev (), "ref");
+ cspi_object_ref (obj);
return 0;
}
int
AccessibleStateSet_unref (AccessibleStateSet *obj)
{
-/* Accessibility_StateSet_unref (*obj, spi_ev ()); */
- spi_check_ev (spi_ev (), "unref");
+ cspi_object_unref (obj);
return 0;
}
AccessibleStateSet_contains (AccessibleStateSet *obj,
AccessibleState state)
{
- CORBA_boolean retval = Accessibility_StateSet_contains (*obj, state, spi_ev ());
- spi_check_ev (spi_ev (), "contains");
+ CORBA_boolean retval = Accessibility_StateSet_contains (CSPI_OBJREF (obj), state, cspi_ev ());
+ cspi_check_ev (cspi_ev (), "contains");
return (boolean) retval;
}
AccessibleStateSet_add (AccessibleStateSet *obj,
AccessibleState state)
{
- Accessibility_StateSet_add (*obj, state, spi_ev ());
- spi_check_ev (spi_ev (), "contains");
+ Accessibility_StateSet_add (CSPI_OBJREF (obj), state, cspi_ev ());
+ cspi_check_ev (cspi_ev (), "contains");
}
AccessibleStateSet_remove (AccessibleStateSet *obj,
AccessibleState state)
{
- Accessibility_StateSet_remove (*obj, state, spi_ev ());
- spi_check_ev (spi_ev (), "contains");
+ Accessibility_StateSet_remove (CSPI_OBJREF (obj), state, cspi_ev ());
+ cspi_check_ev (cspi_ev (), "contains");
}
/**
AccessibleStateSet_equals (AccessibleStateSet *obj,
AccessibleStateSet *obj2)
{
- return Accessibility_StateSet_equals (*obj, *obj2, spi_ev ());
+ return Accessibility_StateSet_equals (CSPI_OBJREF (obj), CSPI_OBJREF (obj2), cspi_ev ());
}
/**
AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
{
return TRUE;
- /* return Accessibility_StateSet_isEmpty (*obj, spi_ev ());*/
+ /* return Accessibility_StateSet_isEmpty (CSPI_OBJREF (obj), cspi_ev ());*/
}
*
**/
int
-AccessibleAction_ref (
- AccessibleAction *obj)
+AccessibleAction_ref (AccessibleAction *obj)
{
- Accessibility_Action_ref (*obj, spi_ev ());
+ cspi_object_ref (obj);
return 0;
}
int
AccessibleAction_unref (AccessibleAction *obj)
{
- Accessibility_Action_unref (*obj, spi_ev ());
+ cspi_object_unref (obj);
return 0;
}
AccessibleAction_getNActions (AccessibleAction *obj)
{
return (long)
- Accessibility_Action__get_nActions (*obj, spi_ev ());
+ Accessibility_Action__get_nActions (CSPI_OBJREF (obj), cspi_ev ());
}
long int i)
{
return (char *)
- Accessibility_Action_getDescription (*obj,
+ Accessibility_Action_getDescription (CSPI_OBJREF (obj),
(CORBA_long) i,
- spi_ev ());
+ cspi_ev ());
}
/**
long int i)
{
return (char *)
- Accessibility_Action_getKeyBinding (*obj,
+ Accessibility_Action_getKeyBinding (CSPI_OBJREF (obj),
(CORBA_long) i,
- spi_ev ());
+ cspi_ev ());
}
long int i)
{
return (char *)
- Accessibility_Action_getName (*obj,
+ Accessibility_Action_getName (CSPI_OBJREF (obj),
(CORBA_long) i,
- spi_ev ());
+ cspi_ev ());
}
long int i)
{
return (boolean)
- Accessibility_Action_doAction (*obj,
+ Accessibility_Action_doAction (CSPI_OBJREF (obj),
(CORBA_long) i,
- spi_ev ());
+ cspi_ev ());
}
int
AccessibleApplication_ref (AccessibleApplication *obj)
{
- Accessibility_Application_ref (*obj, spi_ev ());
+ cspi_object_ref (obj);
return 0;
}
int
AccessibleApplication_unref (AccessibleApplication *obj)
{
- Accessibility_Application_unref (*obj, spi_ev ());
+ cspi_object_unref (obj);
return 0;
}
char *
AccessibleApplication_getToolkitName (AccessibleApplication *obj)
{
- return Accessibility_Application__get_toolkitName (*obj, spi_ev ());
+ return Accessibility_Application__get_toolkitName (CSPI_OBJREF (obj), cspi_ev ());
}
/**
char *
AccessibleApplication_getVersion (AccessibleApplication *obj)
{
- return Accessibility_Application__get_version (*obj, spi_ev ());
+ return Accessibility_Application__get_version (CSPI_OBJREF (obj), cspi_ev ());
}
/**
long
AccessibleApplication_getID (AccessibleApplication *obj)
{
- return Accessibility_Application__get_id (*obj, spi_ev ());
+ return Accessibility_Application__get_id (CSPI_OBJREF (obj), cspi_ev ());
}
/**
int
AccessibleComponent_ref (AccessibleComponent *obj)
{
- Accessibility_Component_ref (*obj, spi_ev ());
+ cspi_object_ref (obj);
return 0;
}
int
AccessibleComponent_unref (AccessibleComponent *obj)
{
- Accessibility_Component_unref (*obj, spi_ev ());
+ cspi_object_unref (obj);
return 0;
}
* @x: a #long specifying the x coordinate in question.
* @y: a #long specifying the y coordinate in question.
* @ctype: the desired coordinate system of the point (@x, @y)
- * (e.g. SPI_COORD_TYPE_WINDOW, SPI_COORD_TYPE_SCREEN).
+ * (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN).
*
* Query whether a given #AccessibleComponent contains a particular point.
*
long int y,
AccessibleCoordType ctype)
{
- return Accessibility_Component_contains (*obj,
+ return Accessibility_Component_contains (CSPI_OBJREF (obj),
(CORBA_long) x,
(CORBA_long) y,
ctype,
- spi_ev ());
+ cspi_ev ());
}
/**
* @x: a #long specifying the x coordinate of the point in question.
* @y: a #long specifying the y coordinate of the point in question.
* @ctype: the coordinate system of the point (@x, @y)
- * (e.g. SPI_COORD_TYPE_WINDOW, SPI_COORD_TYPE_SCREEN).
+ * (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN).
*
* Get the accessible child at a given coordinate within an #AccessibleComponent.
*
long int y,
AccessibleCoordType ctype)
{
- Accessible child;
- child = Accessibility_Component_getAccessibleAtPoint(*obj,
+ Accessibility_Accessible child;
+
+ child = Accessibility_Component_getAccessibleAtPoint(CSPI_OBJREF (obj),
(CORBA_long) x,
(CORBA_long) y,
ctype,
- spi_ev ());
- return spi_object_add (child);
+ cspi_ev ());
+ return cspi_object_add (child);
}
/**
* @width: a pointer to a #long into which the x extents (width) will be returned.
* @height: a pointer to a #long into which the y extents (height) will be returned.
* @ctype: the desired coordinate system into which to return the results,
- * (e.g. SPI_COORD_TYPE_WINDOW, SPI_COORD_TYPE_SCREEN).
+ * (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN).
*
* Get the bounding box of the specified #AccessibleComponent.
*
AccessibleCoordType ctype)
{
CORBA_long cx, cy, cw, ch;
- Accessibility_Component_getExtents (*obj,
+ Accessibility_Component_getExtents (CSPI_OBJREF (obj),
&cx,
&cy,
&cw,
&ch,
ctype,
- spi_ev ());
- spi_warn_ev (spi_ev (), "AccessibleComponent_getExtents");
+ cspi_ev ());
+ cspi_warn_ev (cspi_ev (), "AccessibleComponent_getExtents");
*x = (long) cx;
*y = (long) cy;
*width = (long) cw;
* @x: a pointer to a #long into which the minimum x coordinate will be returned.
* @y: a pointer to a #long into which the minimum y coordinate will be returned.
* @ctype: the desired coordinate system into which to return the results,
- * (e.g. SPI_COORD_TYPE_WINDOW, SPI_COORD_TYPE_SCREEN).
+ * (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN).
*
* Get the minimum x and y coordinates of the specified #AccessibleComponent.
*
long int *y,
AccessibleCoordType ctype)
{
- Accessibility_Component_getPosition (*obj,
+ Accessibility_Component_getPosition (CSPI_OBJREF (obj),
(CORBA_long *) x,
(CORBA_long *) y,
ctype,
- spi_ev ());
+ cspi_ev ());
}
/**
long int *width,
long int *height)
{
- Accessibility_Component_getSize (*obj,
+ Accessibility_Component_getSize (CSPI_OBJREF (obj),
(CORBA_long *) width,
(CORBA_long *) height,
- spi_ev ());
+ cspi_ev ());
}
/**
int
AccessibleEditableText_ref (AccessibleEditableText *obj)
{
- Accessibility_EditableText_ref (*obj, spi_ev ());
+ cspi_object_ref (obj);
return 0;
}
int
AccessibleEditableText_unref (AccessibleEditableText *obj)
{
- Accessibility_EditableText_unref (*obj, spi_ev ());
+ cspi_object_unref (obj);
return 0;
}
long int endPos)
{
return (boolean)
- Accessibility_EditableText_setAttributes (*obj,
+ Accessibility_EditableText_setAttributes (CSPI_OBJREF (obj),
(CORBA_char *) attributes,
(CORBA_long) startPos,
- (CORBA_long) endPos, spi_ev ());
+ (CORBA_long) endPos, cspi_ev ());
}
AccessibleEditableText_setTextContents (AccessibleEditableText *obj,
const char *newContents)
{
- Accessibility_EditableText_setTextContents (*obj,
- (CORBA_char *) newContents, spi_ev ());
+ Accessibility_EditableText_setTextContents (CSPI_OBJREF (obj),
+ (CORBA_char *) newContents, cspi_ev ());
return TRUE; /* TODO: make bonobo method return a boolean */
}
char *text,
long int length)
{
- Accessibility_EditableText_insertText (*obj,
+ Accessibility_EditableText_insertText (CSPI_OBJREF (obj),
(CORBA_long) position, (CORBA_char *) text,
- (CORBA_long) length, spi_ev ());
+ (CORBA_long) length, cspi_ev ());
return TRUE;
}
long int startPos,
long int endPos)
{
- Accessibility_EditableText_copyText (*obj,
- (CORBA_long) startPos, (CORBA_long) endPos, spi_ev ());
+ Accessibility_EditableText_copyText (CSPI_OBJREF (obj),
+ (CORBA_long) startPos, (CORBA_long) endPos, cspi_ev ());
return TRUE;
}
long int startPos,
long int endPos)
{
- Accessibility_EditableText_cutText (*obj,
- (CORBA_long) startPos, (CORBA_long) endPos, spi_ev ());
+ Accessibility_EditableText_cutText (CSPI_OBJREF (obj),
+ (CORBA_long) startPos, (CORBA_long) endPos, cspi_ev ());
return TRUE;
}
long startPos,
long endPos)
{
- Accessibility_EditableText_deleteText (*obj,
- (CORBA_long) startPos, (CORBA_long) endPos, spi_ev ());
+ Accessibility_EditableText_deleteText (CSPI_OBJREF (obj),
+ (CORBA_long) startPos, (CORBA_long) endPos, cspi_ev ());
return TRUE;
}
AccessibleEditableText_pasteText (AccessibleEditableText *obj,
long int position)
{
- Accessibility_EditableText_pasteText (*obj,
- (CORBA_long) position, spi_ev ());
+ Accessibility_EditableText_pasteText (CSPI_OBJREF (obj),
+ (CORBA_long) position, cspi_ev ());
return TRUE;
}
*/
#include <cspi/spi-private.h>
+#include <cspi/spi-listener-impl.h>
/**
* createAccessibleEventListener:
AccessibleEventListener *
createAccessibleEventListener (AccessibleEventListenerCB callback)
{
- AccessibleEventListener *listener = spi_event_listener_new ();
+ AccessibleEventListener *listener = cspi_event_listener_new ();
if (callback)
{
- spi_event_listener_add_callback (listener, callback);
+ AccessibleEventListener_addCallback (listener, callback);
}
return listener;
}
**/
boolean
AccessibleEventListener_addCallback (AccessibleEventListener *listener,
- AccessibleEventListenerCB callback)
+ AccessibleEventListenerCB callback)
{
- spi_event_listener_add_callback (listener, callback);
+ cspi_event_listener_add_callback (listener, callback);
return TRUE;
}
*
**/
boolean
-AccessibleEventListener_removeCallback (AccessibleEventListener *listener,
+AccessibleEventListener_removeCallback (AccessibleEventListener *listener,
AccessibleEventListenerCB callback)
{
-/* spi_event_listener_remove_callback (listener, callback); */
+ cspi_event_listener_remove_callback (listener, callback);
return TRUE;
}
AccessibleKeystrokeListener *
createAccessibleKeystrokeListener (AccessibleKeystrokeListenerCB callback)
{
- SpiKeystrokeListener *listener = spi_keystroke_listener_new ();
+ CSpiKeystrokeListener *listener = cspi_keystroke_listener_new ();
if (callback)
{
- spi_keystroke_listener_add_callback (listener, callback);
+ AccessibleKeystrokeListener_addCallback (listener, callback);
}
return (AccessibleKeystrokeListener *)listener;
}
AccessibleKeystrokeListener_addCallback (AccessibleKeystrokeListener *listener,
AccessibleKeystrokeListenerCB callback)
{
- spi_keystroke_listener_add_callback (listener, callback);
+ cspi_keystroke_listener_add_callback (listener, callback);
return TRUE;
}
AccessibleKeystrokeListener_removeCallback (AccessibleKeystrokeListener *listener,
AccessibleKeystrokeListenerCB callback)
{
- spi_keystroke_listener_remove_callback (listener, callback);
+ cspi_keystroke_listener_remove_callback (listener, callback);
return TRUE;
}
+
+/**
+ * AccessibleKeystrokeListener_unref:
+ * @listener: a pointer to the #AccessibleKeystrokeListener being operated on.
+ *
+ * Decrements an #AccessibleKeystrokeListener's reference count.
+ **/
+void AccessibleKeystrokeListener_unref (AccessibleKeystrokeListener *listener)
+{
+ /* Would prefer this not to be bonobo api */
+ bonobo_object_unref (BONOBO_OBJECT (listener));
+}
int
AccessibleHyperlink_ref (AccessibleHyperlink *obj)
{
- Accessibility_Hyperlink_ref (*obj, spi_ev ());
+ cspi_object_ref (obj);
return 0;
}
int
AccessibleHyperlink_unref (AccessibleHyperlink *obj)
{
- Accessibility_Hyperlink_unref (*obj, spi_ev ());
+ cspi_object_ref (obj);
return 0;
}
AccessibleHyperlink_getNAnchors (AccessibleHyperlink *obj)
{
return (long)
- Accessibility_Hyperlink__get_nAnchors (*obj, spi_ev ());
+ Accessibility_Hyperlink__get_nAnchors (CSPI_OBJREF (obj), cspi_ev ());
}
long int i)
{
return (char *)
- Accessibility_Hyperlink_getURI (*obj,
- (CORBA_long) i, spi_ev ());
+ Accessibility_Hyperlink_getURI (CSPI_OBJREF (obj),
+ (CORBA_long) i, cspi_ev ());
}
/**
AccessibleHyperlink_getObject (AccessibleHyperlink *obj,
long int i)
{
- return spi_object_add (
- Accessibility_Hyperlink_getObject (*obj,
- (CORBA_long) i, spi_ev ()));
+ return cspi_object_add (
+ Accessibility_Hyperlink_getObject (CSPI_OBJREF (obj),
+ (CORBA_long) i, cspi_ev ()));
}
/**
long int *endIndex)
{
*startIndex = (long)
- Accessibility_Hyperlink__get_startIndex (*obj, spi_ev ());
+ Accessibility_Hyperlink__get_startIndex (CSPI_OBJREF (obj), cspi_ev ());
*endIndex = (long)
- Accessibility_Hyperlink__get_endIndex (*obj, spi_ev ());
+ Accessibility_Hyperlink__get_endIndex (CSPI_OBJREF (obj), cspi_ev ());
}
AccessibleHyperlink_isValid (AccessibleHyperlink *obj)
{
return (boolean)
- Accessibility_Hyperlink_isValid (*obj, spi_ev ());
+ Accessibility_Hyperlink_isValid (CSPI_OBJREF (obj), cspi_ev ());
}
int
AccessibleHypertext_ref (AccessibleHypertext *obj)
{
- Accessibility_Hypertext_ref (*obj, spi_ev ());
+ cspi_object_ref (obj);
return 0;
}
int
AccessibleHypertext_unref (AccessibleHypertext *obj)
{
- Accessibility_Hypertext_unref (*obj, spi_ev ());
+ cspi_object_unref (obj);
return 0;
}
AccessibleHypertext_getNLinks (AccessibleHypertext *obj)
{
return (long)
- Accessibility_Hypertext_getNLinks (*obj, spi_ev ());
+ Accessibility_Hypertext_getNLinks (CSPI_OBJREF (obj), cspi_ev ());
}
long int linkIndex)
{
return (AccessibleHyperlink *)
- Accessibility_Hypertext_getLink (*obj,
- (CORBA_long) linkIndex, spi_ev ());
+ Accessibility_Hypertext_getLink (CSPI_OBJREF (obj),
+ (CORBA_long) linkIndex, cspi_ev ());
}
long int characterOffset)
{
return (long)
- Accessibility_Hypertext_getLinkIndex (*obj,
- (CORBA_long) characterOffset, spi_ev ());
+ Accessibility_Hypertext_getLinkIndex (CSPI_OBJREF (obj),
+ (CORBA_long) characterOffset, cspi_ev ());
}
int
AccessibleImage_ref (AccessibleImage *obj)
{
- Accessibility_Image_ref (*obj, spi_ev ());
+ cspi_object_ref (obj);
return 0;
}
int
AccessibleImage_unref (AccessibleImage *obj)
{
- Accessibility_Image_unref (*obj, spi_ev ());
+ cspi_object_unref (obj);
return 0;
}
AccessibleImage_getImageDescription (AccessibleImage *obj)
{
return (char *)
- Accessibility_Image__get_imageDescription (*obj, spi_ev ());
+ Accessibility_Image__get_imageDescription (CSPI_OBJREF (obj), cspi_ev ());
}
long int *width,
long int *height)
{
- Accessibility_Image_getImageSize (*obj,
- (CORBA_long *) width, (CORBA_long *) height, spi_ev ());
+ Accessibility_Image_getImageSize (CSPI_OBJREF (obj),
+ (CORBA_long *) width, (CORBA_long *) height, cspi_ev ());
}
long *y,
AccessibleCoordType ctype)
{
- Accessibility_Image_getImagePosition (*obj,
+ Accessibility_Image_getImagePosition (CSPI_OBJREF (obj),
(CORBA_long *) x, (CORBA_long *) y, (CORBA_short) ctype,
- spi_ev ());
+ cspi_ev ());
}
* Basic SPI initialization and event loop function prototypes
*
*/
+#include <string.h>
#include <stdlib.h>
-#include <libbonobo.h>
#include <cspi/spi-private.h>
static CORBA_Environment ev = { 0 };
-static AccessibilityRegistry registry = CORBA_OBJECT_NIL;
+static Accessibility_Registry registry = CORBA_OBJECT_NIL;
+static boolean is_gnome_app = FALSE;
+static GSList *live_refs = NULL;
CORBA_Environment *
-spi_ev (void)
+cspi_ev (void)
{
/* This method is an ugly hack */
return &ev;
}
-AccessibilityRegistry
-spi_registry (void)
+Accessibility_Registry
+cspi_registry (void)
{
- /* This method is an ugly hack */
return registry;
}
boolean
-spi_exception (void)
+cspi_is_gnome_app (void)
+{
+ return is_gnome_app;
+}
+
+boolean
+cspi_exception (void)
{
boolean retval;
}
Accessible *
-spi_object_add (Accessible corba_object)
+cspi_object_add (CORBA_Object corba_object)
{
- /* TODO: keep list of live object refs */
- Accessible *oref = NULL;
+ Accessible *ref;
if (corba_object != CORBA_OBJECT_NIL)
{
- oref = g_malloc (sizeof (Accessible));
- *oref = corba_object;
+ ref = g_new (Accessible, 1);
+
+ ref->objref = CORBA_Object_duplicate (corba_object, cspi_ev());
+ ref->ref_count = 1;
+
+ live_refs = g_slist_prepend (live_refs, ref);
+ }
+ else
+ {
+ ref = NULL;
+ }
+
+ return ref;
+}
+
+void
+cspi_object_ref (Accessible *accessible)
+{
+ g_return_if_fail (accessible != NULL);
+
+ accessible->ref_count++;
+}
+
+void
+cspi_object_unref (Accessible *accessible)
+{
+ g_return_if_fail (accessible != NULL);
+
+ if (--accessible->ref_count == 0)
+ {
+ live_refs = g_slist_remove (live_refs, accessible);
+
+ bonobo_object_release_unref (accessible->objref, cspi_ev ());
+
+ cspi_check_ev (cspi_ev (), "unref");
+
+ memset (accessible, 0xaa, sizeof (Accessible));
+
+ g_free (accessible);
+ }
+}
+
+static void
+cspi_cleanup (void)
+{
+ GSList *l, *refs;
+
+ refs = live_refs;
+ live_refs = NULL;
+
+ for (l = refs; l; l = l->next)
+ {
+ Accessible *a = l->data;
+
+ g_print ("releasing %p\n", l->data);
+ bonobo_object_release_unref (a->objref, NULL);
+
+ g_free (a);
+ }
+
+ g_slist_free (refs);
+
+ if (registry != CORBA_OBJECT_NIL)
+ {
+ bonobo_object_release_unref (registry, NULL);
+ registry = CORBA_OBJECT_NIL;
}
-
- return oref;
}
/**
{
int argc = 0;
char *obj_id;
- CORBA_Object oclient;
static gboolean inited = FALSE;
if (inited)
obj_id = "OAFIID:Accessibility_Registry:proto0.1";
- oclient = bonobo_activation_activate_from_id (
- obj_id, 0, NULL, spi_ev ());
+ registry = bonobo_activation_activate_from_id (
+ obj_id, 0, NULL, cspi_ev ());
if (ev._major != CORBA_NO_EXCEPTION)
{
g_error ("AT-SPI error: during registry activation: %s\n",
- bonobo_exception_get_text (spi_ev ()));
+ bonobo_exception_get_text (cspi_ev ()));
}
- if (CORBA_Object_is_nil (oclient, spi_ev ()))
+ if (registry == CORBA_OBJECT_NIL)
{
g_error ("Could not locate registry");
}
- registry = (Accessibility_Registry) oclient;
-
+ Accessibility_Registry_ref (registry, &ev);
+
bonobo_activate ();
-
+
return 0;
}
*
* Starts/enters the main event loop for the SPI services.
*
- * (NOTE: This method does not return control, it is exited via a call to exit()
+ * (NOTE: This method does not return control, it is exited via a call to SPI_exit()
* from within an event handler).
*
**/
void
SPI_event_main (boolean isGNOMEApp)
{
+ is_gnome_app = isGNOMEApp;
if (isGNOMEApp)
{
- g_atexit (SPI_exit);
+ g_atexit (cspi_cleanup);
bonobo_main ();
}
else
{
/* TODO: install signal handlers to do cleanup */
- CORBA_ORB_run (bonobo_orb(), spi_ev ());
+ CORBA_ORB_run (bonobo_orb (), cspi_ev ());
fprintf (stderr, "orb loop exited...\n");
}
}
* Not Yet Implemented.
*
* Returns: the next #AccessibleEvent in the SPI event queue.
- *
**/
AccessibleEvent *
SPI_nextEvent (boolean waitForEvent)
/**
* SPI_exit:
*
- * Disconnects from the Accessibility Registry and releases resources.
- *
+ * Disconnects from the Accessibility Registry and releases
+ * any floating resources.
**/
void
SPI_exit (void)
{
- fprintf (stderr, "bye-bye!\n");
- exit(0);
+ cspi_cleanup();
+ if (cspi_is_gnome_app ())
+ {
+ bonobo_main_quit ();
+ }
+ else
+ {
+ CORBA_ORB_shutdown (bonobo_orb (), TRUE, cspi_ev ());
+ }
+ fprintf (stderr, "bye-bye!\n");
}
*
*/
+#if 0
/* static stuff used only by registry C bindings */
static GList *key_listeners = NULL;
static Display *display = NULL;
+#endif
/**
* registerGlobalEventListener:
boolean retval;
Accessibility_Registry_registerGlobalEventListener (
- spi_registry (),
+ cspi_registry (),
(Accessibility_EventListener)
bonobo_object_corba_objref (bonobo_object (listener)),
eventType,
- spi_ev ());
+ cspi_ev ());
- retval = !spi_exception ();
+ retval = !cspi_exception ();
return retval;
}
* an event type.
*
* deregisters an AccessibleEventListener from the registry, for all
- * event types it may be listening to.
+ * event types it may be listening to. Also unrefs the listener.
+ * The listener cannot subsequently be reused.
*
* Returns: #TRUE if successful, otherwise #FALSE.
*
deregisterGlobalEventListenerAll (AccessibleEventListener *listener)
{
Accessibility_Registry_deregisterGlobalEventListenerAll (
- spi_registry (),
+ cspi_registry (),
(Accessibility_EventListener)
CORBA_Object_duplicate (
bonobo_object_corba_objref (
- bonobo_object (listener)), spi_ev ()),
- spi_ev ());
+ bonobo_object (listener)), cspi_ev ()),
+ cspi_ev ());
+ if (!cspi_exception ())
+ {
+ bonobo_object_unref (BONOBO_OBJECT (listener));
+ /* Would prefer that this were not a bonobo object: g_object_unref (listener);*/
+ }
- return !spi_exception ();
+ return !cspi_exception ();
}
/**
* deregisterGlobalEventListener:
char *eventType)
{
Accessibility_Registry_deregisterGlobalEventListener (
- spi_registry (),
+ cspi_registry (),
(Accessibility_EventListener)
CORBA_Object_duplicate (
- bonobo_object_corba_objref (bonobo_object (listener)), spi_ev ()),
+ bonobo_object_corba_objref (bonobo_object (listener)), cspi_ev ()),
(CORBA_char *) eventType,
- spi_ev ());
+ cspi_ev ());
- return !spi_exception ();
+ return !cspi_exception ();
}
/**
int
getDesktopCount ()
{
- return Accessibility_Registry_getDesktopCount (
- spi_registry (), spi_ev ());
+ return Accessibility_Registry_getDesktopCount (cspi_registry (), cspi_ev ());
}
/**
Accessible*
getDesktop (int i)
{
- return spi_object_add (Accessibility_Registry_getDesktop (spi_registry (), (CORBA_short) i, spi_ev ()));
+ return cspi_object_add (Accessibility_Registry_getDesktop (cspi_registry (),
+ (CORBA_short) i,
+ cspi_ev ()));
}
/**
return 0;
}
+#if 0
static gboolean
key_event_source_func (void *p)
{
}
return TRUE;
}
+#endif
/**
* registerAccessibleKeystrokeListener:
* @listener: a pointer to the #AccessibleKeystrokeListener for which
* keystroke events are requested.
* @keys: a pointer to the #AccessibleKeySet indicating which
- * keystroke events are requested, or #SPI_KEYSET_ALL_KEYS.
+ * keystroke events are requested, or #CSPI_KEYSET_ALL_KEYS.
* @modmask: an #AccessibleKeyMaskType mask indicating which
* key event modifiers must be set in combination with @keys,
* events will only be reported for key events for which all
* the behavior of the notification/listener transaction.
*
* Register a listener for keystroke events, either pre-emptively for
- * all windows (SPI_KEYLISTENER_ALL_WINDOWS), or
- * non-preemptively (SPI_KEYLISTENER_NOSYNC).
+ * all windows (CSPI_KEYLISTENER_ALL_WINDOWS), or
+ * non-preemptively (CSPI_KEYLISTENER_NOSYNC).
* ( Other sync_type values may be available in the future.)
**/
void
Accessibility_ControllerEventMask *controller_event_mask =
Accessibility_ControllerEventMask__alloc();
Accessibility_DeviceEventController device_event_controller =
- Accessibility_Registry_getDeviceEventController (spi_registry (), spi_ev ());
+ Accessibility_Registry_getDeviceEventController (cspi_registry (), cspi_ev ());
Accessibility_KeySet *key_set = Accessibility_KeySet__alloc();
Accessibility_KeyEventTypeSeq *key_events = Accessibility_KeyEventTypeSeq__alloc();
- Accessibility_KeystrokeListener spi_listener_corba_ref;
+ Accessibility_KeystrokeListener cspi_listener_corba_ref;
gint i, mask;
- Accessibility_DeviceEventController_ref (device_event_controller, spi_ev ());
+ Accessibility_DeviceEventController_ref (device_event_controller, cspi_ev ());
/* copy the keyval filter values from the C api into the CORBA KeySet */
if (keys)
controller_event_mask->value = (CORBA_unsigned_long) modmask;
controller_event_mask->refcount = (CORBA_unsigned_short) 1;
- spi_listener_corba_ref = (Accessibility_KeystrokeListener)
- CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), spi_ev ());
+ cspi_listener_corba_ref = (Accessibility_KeystrokeListener)
+ CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), cspi_ev ());
Accessibility_DeviceEventController_registerKeystrokeListener (
device_event_controller,
- spi_listener_corba_ref,
+ cspi_listener_corba_ref,
key_set,
controller_event_mask,
key_events,
(CORBA_boolean) ((sync_type & SPI_KEYLISTENER_ALL_WINDOWS)!=0),
- spi_ev ());
+ cspi_ev ());
}
/**
Accessibility_ControllerEventMask *controller_event_mask =
Accessibility_ControllerEventMask__alloc();
Accessibility_DeviceEventController device_event_controller =
- Accessibility_Registry_getDeviceEventController (spi_registry (), spi_ev ());
+ Accessibility_Registry_getDeviceEventController (cspi_registry (), cspi_ev ());
Accessibility_KeySet *all_keys = Accessibility_KeySet__alloc();
Accessibility_KeyEventTypeSeq *key_events = Accessibility_KeyEventTypeSeq__alloc();
- Accessibility_KeystrokeListener spi_listener_corba_ref;
- Accessibility_DeviceEventController_unref (device_event_controller, spi_ev ());
+ Accessibility_KeystrokeListener cspi_listener_corba_ref;
+ Accessibility_DeviceEventController_unref (device_event_controller, cspi_ev ());
controller_event_mask->value = (CORBA_unsigned_long) modmask;
controller_event_mask->refcount = (CORBA_unsigned_short) 1;
- spi_listener_corba_ref = (Accessibility_KeystrokeListener)
- CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), spi_ev ());
+ cspi_listener_corba_ref = (Accessibility_KeystrokeListener)
+ CORBA_Object_duplicate (BONOBO_OBJREF(listener), cspi_ev ());
Accessibility_DeviceEventController_deregisterKeystrokeListener (
device_event_controller,
- spi_listener_corba_ref,
+ cspi_listener_corba_ref,
all_keys,
controller_event_mask,
key_events,
(CORBA_boolean) TRUE,
- spi_ev ());
+ cspi_ev ());
}
/**
* being synthesized.
* @synth_type: a #AccessibleKeySynthType flag indicating whether @keyval
* is to be interpreted as a keysym rather than a keycode
- * (SPI_KEYSYM), or whether to synthesize
+ * (CSPI_KEYSYM), or whether to synthesize
* SPI_KEY_PRESS, SPI_KEY_RELEASE, or both (SPI_KEY_PRESSRELEASE).
*
* Synthesize a keyboard event (as if a hardware keyboard event occurred in the
* send keycode to alter, if necessary
*/
Accessibility_DeviceEventController device_event_controller =
- Accessibility_Registry_getDeviceEventController (spi_registry (), spi_ev ());
+ Accessibility_Registry_getDeviceEventController (cspi_registry (), cspi_ev ());
Accessibility_DeviceEventController_generateKeyEvent (device_event_controller,
keyval,
(unsigned long) synth_type,
- spi_ev ());
+ cspi_ev ());
}
/**
int
AccessibleSelection_ref (AccessibleSelection *obj)
{
- Accessibility_Selection_ref (*obj, spi_ev ());
+ cspi_object_ref (obj);
return 0;
}
int
AccessibleSelection_unref (AccessibleSelection *obj)
{
- Accessibility_Selection_unref (*obj, spi_ev ());
+ cspi_object_unref (obj);
return 0;
}
AccessibleSelection_getNSelectedChildren (AccessibleSelection *obj)
{
return (long)
- Accessibility_Selection__get_nSelectedChildren (*obj, spi_ev ());
+ Accessibility_Selection__get_nSelectedChildren (CSPI_OBJREF (obj), cspi_ev ());
}
long int selectedChildIndex)
{
Accessibility_Accessible child =
- Accessibility_Selection_getSelectedChild (*obj,
- (CORBA_long) selectedChildIndex, spi_ev ());
- spi_warn_ev (spi_ev (), "getSelectedChild");
+ Accessibility_Selection_getSelectedChild (CSPI_OBJREF (obj),
+ (CORBA_long) selectedChildIndex, cspi_ev ());
+ cspi_warn_ev (cspi_ev (), "getSelectedChild");
- return (Accessible *) spi_object_add (child);
+ return (Accessible *) cspi_object_add (child);
}
/**
long int childIndex)
{
return (boolean)
- Accessibility_Selection_selectChild (*obj,
- (CORBA_long) childIndex, spi_ev ());
+ Accessibility_Selection_selectChild (CSPI_OBJREF (obj),
+ (CORBA_long) childIndex, cspi_ev ());
}
long int selectedChildIndex)
{
return Accessibility_Selection_deselectSelectedChild (
- *obj, (CORBA_long) selectedChildIndex, spi_ev ());
+ CSPI_OBJREF (obj), (CORBA_long) selectedChildIndex, cspi_ev ());
}
long int childIndex)
{
return (boolean)
- Accessibility_Selection_isChildSelected (*obj,
- (CORBA_long) childIndex, spi_ev ());
+ Accessibility_Selection_isChildSelected (CSPI_OBJREF (obj),
+ (CORBA_long) childIndex, cspi_ev ());
}
boolean
AccessibleSelection_selectAll (AccessibleSelection *obj)
{
- Accessibility_Selection_selectAll (*obj, spi_ev ());
+ Accessibility_Selection_selectAll (CSPI_OBJREF (obj), cspi_ev ());
return TRUE; /* TODO: change the bonobo method to return boolean */
}
void
AccessibleSelection_clearSelection (AccessibleSelection *obj)
{
- Accessibility_Selection_clearSelection (*obj, spi_ev ());
+ Accessibility_Selection_clearSelection (CSPI_OBJREF (obj), cspi_ev ());
}
int
AccessibleTable_ref (AccessibleTable *obj)
{
- Accessibility_Table_ref (*obj, spi_ev ());
+ cspi_object_ref (obj);
return 0;
}
int
AccessibleTable_unref (AccessibleTable *obj)
{
- Accessibility_Table_unref (*obj, spi_ev ());
+ cspi_object_unref (obj);
return 0;
}
AccessibleTable_getCaption (AccessibleTable *obj)
{
return (Accessible *)
- Accessibility_Table__get_caption (*obj, spi_ev ());
+ Accessibility_Table__get_caption (CSPI_OBJREF (obj), cspi_ev ());
}
AccessibleTable_getSummary (AccessibleTable *obj)
{
return (Accessible *)
- Accessibility_Table__get_summary (*obj, spi_ev ());
+ Accessibility_Table__get_summary (CSPI_OBJREF (obj), cspi_ev ());
}
AccessibleTable_getNRows (AccessibleTable *obj)
{
return (long)
- Accessibility_Table__get_nRows (*obj, spi_ev ());
+ Accessibility_Table__get_nRows (CSPI_OBJREF (obj), cspi_ev ());
}
AccessibleTable_getNColumns (AccessibleTable *obj)
{
return (long)
- Accessibility_Table__get_nColumns (*obj, spi_ev ());
+ Accessibility_Table__get_nColumns (CSPI_OBJREF (obj), cspi_ev ());
}
long int column)
{
return (Accessible *)
- Accessibility_Table_getAccessibleAt (*obj,
- (CORBA_long) row, (CORBA_long) column, spi_ev ());
+ Accessibility_Table_getAccessibleAt (CSPI_OBJREF (obj),
+ (CORBA_long) row, (CORBA_long) column, cspi_ev ());
}
long int column)
{
return (long)
- Accessibility_Table_getIndexAt (*obj,
- (CORBA_long) row, (CORBA_long) column, spi_ev ());
+ Accessibility_Table_getIndexAt (CSPI_OBJREF (obj),
+ (CORBA_long) row, (CORBA_long) column, cspi_ev ());
}
long index)
{
return (long)
- Accessibility_Table_getRowAtIndex (*obj,
- (CORBA_long) index, spi_ev ());
+ Accessibility_Table_getRowAtIndex (CSPI_OBJREF (obj),
+ (CORBA_long) index, cspi_ev ());
}
long index)
{
return (long)
- Accessibility_Table_getColumnAtIndex (*obj,
- (CORBA_long) index, spi_ev ());
+ Accessibility_Table_getColumnAtIndex (CSPI_OBJREF (obj),
+ (CORBA_long) index, cspi_ev ());
}
long int row)
{
return (char *)
- Accessibility_Table_getRowDescription (*obj,
- (CORBA_long) row, spi_ev ());
+ Accessibility_Table_getRowDescription (CSPI_OBJREF (obj),
+ (CORBA_long) row, cspi_ev ());
}
long int column)
{
return (char *)
- Accessibility_Table_getColumnDescription (*obj,
- (CORBA_long) column, spi_ev ());
+ Accessibility_Table_getColumnDescription (CSPI_OBJREF (obj),
+ (CORBA_long) column, cspi_ev ());
}
long int column)
{
return (long)
- Accessibility_Table_getRowExtentAt (*obj,
- (CORBA_long) row, (CORBA_long) column, spi_ev ());
+ Accessibility_Table_getRowExtentAt (CSPI_OBJREF (obj),
+ (CORBA_long) row, (CORBA_long) column, cspi_ev ());
}
long int column)
{
return (long)
- Accessibility_Table_getColumnExtentAt (*obj,
- (CORBA_long) row, (CORBA_long) column, spi_ev ());
+ Accessibility_Table_getColumnExtentAt (CSPI_OBJREF (obj),
+ (CORBA_long) row, (CORBA_long) column, cspi_ev ());
}
long int row)
{
return (Accessible *)
- Accessibility_Table_getRowHeader (*obj,
- (CORBA_long) row, spi_ev ());
+ Accessibility_Table_getRowHeader (CSPI_OBJREF (obj),
+ (CORBA_long) row, cspi_ev ());
}
long int column)
{
return (Accessible *)
- Accessibility_Table_getColumnHeader (*obj,
- (CORBA_long) column, spi_ev ());
+ Accessibility_Table_getColumnHeader (CSPI_OBJREF (obj),
+ (CORBA_long) column, cspi_ev ());
}
AccessibleTable_getNSelectedRows (AccessibleTable *obj)
{
return (long)
- Accessibility_Table__get_nSelectedRows (*obj, spi_ev ());
+ Accessibility_Table__get_nSelectedRows (CSPI_OBJREF (obj), cspi_ev ());
}
AccessibleTable_getSelectedRows (AccessibleTable *obj,
long int **selectedRows)
{
- Accessibility_LongSeq *rows = Accessibility_Table_getSelectedRows (*obj, spi_ev ());
+ Accessibility_LongSeq *rows = Accessibility_Table_getSelectedRows (CSPI_OBJREF (obj), cspi_ev ());
CORBA_long *i;
long *j;
long length;
AccessibleTable_getNSelectedColumns (AccessibleTable *obj)
{
return (long)
- Accessibility_Table__get_nSelectedColumns (*obj, spi_ev ());
+ Accessibility_Table__get_nSelectedColumns (CSPI_OBJREF (obj), cspi_ev ());
}
AccessibleTable_getSelectedColumns (AccessibleTable *obj,
long int **selectedColumns)
{
- Accessibility_LongSeq *columns = Accessibility_Table_getSelectedColumns (*obj, spi_ev ());
+ Accessibility_LongSeq *columns = Accessibility_Table_getSelectedColumns (CSPI_OBJREF (obj), cspi_ev ());
CORBA_long *i;
long *j;
long length;
long int row)
{
return (boolean)
- Accessibility_Table_isRowSelected (*obj,
- (CORBA_long) row, spi_ev ());
+ Accessibility_Table_isRowSelected (CSPI_OBJREF (obj),
+ (CORBA_long) row, cspi_ev ());
}
long int column)
{
return (boolean)
- Accessibility_Table_isColumnSelected (*obj,
- (CORBA_long) column, spi_ev ());
+ Accessibility_Table_isColumnSelected (CSPI_OBJREF (obj),
+ (CORBA_long) column, cspi_ev ());
}
long int column)
{
return (boolean)
- Accessibility_Table_isSelected (*obj,
- (CORBA_long) row, (CORBA_long) column, spi_ev ());
+ Accessibility_Table_isSelected (CSPI_OBJREF (obj),
+ (CORBA_long) row, (CORBA_long) column, cspi_ev ());
}
int
AccessibleText_ref (AccessibleText *obj)
{
- Accessibility_Text_ref (*obj, spi_ev ());
+ cspi_object_ref (obj);
return 0;
}
int
AccessibleText_unref (AccessibleText *obj)
{
- Accessibility_Text_unref (*obj, spi_ev ());
+ cspi_object_unref (obj);
return 0;
}
{
long retval;
- CORBA_exception_init (spi_ev ());
+ CORBA_exception_init (cspi_ev ());
retval = (long)
- Accessibility_Text__get_characterCount (*obj, spi_ev ());
+ Accessibility_Text__get_characterCount (CSPI_OBJREF (obj), cspi_ev ());
- spi_check_ev (spi_ev (), "SpiAccessibleText_getCharacterCount");
+ cspi_check_ev (cspi_ev (), "SpiAccessibleText_getCharacterCount");
return retval;
}
long int endOffset)
{
return (char *)
- Accessibility_Text_getText (*obj,
- (CORBA_long) startOffset, (CORBA_long) endOffset, spi_ev ());
+ Accessibility_Text_getText (CSPI_OBJREF (obj),
+ (CORBA_long) startOffset, (CORBA_long) endOffset, cspi_ev ());
}
/**
AccessibleText_getCaretOffset (AccessibleText *obj)
{
return (long)
- Accessibility_Text__get_caretOffset (*obj, spi_ev ());
+ Accessibility_Text__get_caretOffset (CSPI_OBJREF (obj), cspi_ev ());
}
CORBA_long retStartOffset, retEndOffset;
char *retval;
retval = (char *)
- Accessibility_Text_getAttributes (*obj,
+ Accessibility_Text_getAttributes (CSPI_OBJREF (obj),
(CORBA_long) offset,
&retStartOffset,
&retEndOffset,
- spi_ev ());
+ cspi_ev ());
*startOffset = (long) retStartOffset;
*endOffset = (long) retEndOffset;
return retval;
long int newOffset)
{
return (boolean)
- Accessibility_Text_setCaretOffset (*obj,
- (CORBA_long) newOffset, spi_ev ());
+ Accessibility_Text_setCaretOffset (CSPI_OBJREF (obj),
+ (CORBA_long) newOffset, cspi_ev ());
}
/**
char *retval;
CORBA_long retStartOffset, retEndOffset;
retval = (char *)
- Accessibility_Text_getTextBeforeOffset (*obj,
+ Accessibility_Text_getTextBeforeOffset (CSPI_OBJREF (obj),
(CORBA_long) offset, (Accessibility_TEXT_BOUNDARY_TYPE) type,
&retStartOffset, &retEndOffset,
- spi_ev ());
+ cspi_ev ());
*startOffset = (long) retStartOffset;
*endOffset = (long) retEndOffset;
return retval;
CORBA_long corbaStartOffset;
CORBA_long corbaEndOffset;
char *retval = "";
- retval = Accessibility_Text_getTextAtOffset (*obj,
+ retval = Accessibility_Text_getTextAtOffset (CSPI_OBJREF (obj),
(CORBA_long) offset,
(Accessibility_TEXT_BOUNDARY_TYPE) type,
&corbaStartOffset,
&corbaEndOffset,
- spi_ev ());
+ cspi_ev ());
*startOffset = (long) corbaStartOffset;
*endOffset = (long) corbaEndOffset;
-#ifdef SPI_DEBUG
+#ifdef CSPI_DEBUG
fprintf (stderr, "text offsets %ld to %ld\n", *startOffset, *endOffset);
#endif
return retval;
char *retval;
CORBA_long retStartOffset, retEndOffset;
retval = (char *)
- Accessibility_Text_getTextAfterOffset (*obj,
+ Accessibility_Text_getTextAfterOffset (CSPI_OBJREF (obj),
(CORBA_long) offset, (Accessibility_TEXT_BOUNDARY_TYPE) type,
&retStartOffset, &retEndOffset,
- spi_ev ());
+ cspi_ev ());
*startOffset = (long) retStartOffset;
*endOffset = (long) retEndOffset;
return retval;
long int offset)
{
return (unsigned long)
- Accessibility_Text_getCharacterAtOffset (*obj,
- (CORBA_long) offset, spi_ev ());
+ Accessibility_Text_getCharacterAtOffset (CSPI_OBJREF (obj),
+ (CORBA_long) offset, cspi_ev ());
}
/**
AccessibleCoordType type)
{
CORBA_long retX, retY, retWidth, retHeight;
- Accessibility_Text_getCharacterExtents (*obj,
+ Accessibility_Text_getCharacterExtents (CSPI_OBJREF (obj),
(CORBA_long) offset,
&retX,
&retY,
&retWidth,
&retHeight,
- (CORBA_short) type, spi_ev ());
+ (CORBA_short) type, cspi_ev ());
*x = (long) retX;
*y = (long) retY;
*width = (long) retWidth;
AccessibleCoordType type)
{
return (long)
- Accessibility_Text_getOffsetAtPoint (*obj,
- (CORBA_long) x, (CORBA_long) y, (CORBA_short) type, spi_ev ());
+ Accessibility_Text_getOffsetAtPoint (CSPI_OBJREF (obj),
+ (CORBA_long) x, (CORBA_long) y, (CORBA_short) type, cspi_ev ());
}
AccessibleText_getNSelections (AccessibleText *obj)
{
return (long)
- Accessibility_Text_getNSelections (*obj, spi_ev ());
+ Accessibility_Text_getNSelections (CSPI_OBJREF (obj), cspi_ev ());
}
long int *endOffset)
{
CORBA_long retStartOffset, retEndOffset;
- Accessibility_Text_getSelection (*obj,
+ Accessibility_Text_getSelection (CSPI_OBJREF (obj),
(CORBA_long) selectionNum,
- &retStartOffset, &retEndOffset, spi_ev ());
+ &retStartOffset, &retEndOffset, cspi_ev ());
*startOffset = (long) retStartOffset;
*endOffset = (long) retEndOffset;
long int startOffset, long int endOffset)
{
return (boolean)
- Accessibility_Text_addSelection (*obj,
+ Accessibility_Text_addSelection (CSPI_OBJREF (obj),
(CORBA_long) startOffset, (CORBA_long) endOffset,
- spi_ev ());
+ cspi_ev ());
}
long int selectionNum)
{
return (boolean)
- Accessibility_Text_removeSelection (*obj,
- (CORBA_long) selectionNum, spi_ev ());
+ Accessibility_Text_removeSelection (CSPI_OBJREF (obj),
+ (CORBA_long) selectionNum, cspi_ev ());
}
/**
long int endOffset)
{
return (boolean)
- Accessibility_Text_setSelection (*obj,
+ Accessibility_Text_setSelection (CSPI_OBJREF (obj),
(CORBA_long) selectionNum,
(CORBA_long) startOffset,
- (CORBA_long) endOffset, spi_ev ());
+ (CORBA_long) endOffset, cspi_ev ());
}
int
AccessibleValue_ref (AccessibleValue *obj)
{
- Accessibility_Value_ref (*obj, spi_ev ());
+ cspi_object_ref (obj);
return 0;
}
int
AccessibleValue_unref (AccessibleValue *obj)
{
- Accessibility_Value_unref (*obj, spi_ev ());
+ cspi_object_unref (obj);
return 0;
}
AccessibleValue_getMinimumValue (AccessibleValue *obj)
{
return (float)
- Accessibility_Value__get_minimumValue (*obj, spi_ev ());
+ Accessibility_Value__get_minimumValue (CSPI_OBJREF (obj), cspi_ev ());
}
AccessibleValue_getCurrentValue (AccessibleValue *obj)
{
return (float)
- Accessibility_Value__get_currentValue (*obj, spi_ev ());
+ Accessibility_Value__get_currentValue (CSPI_OBJREF (obj), cspi_ev ());
}
AccessibleValue_getMaximumValue (AccessibleValue *obj)
{
return (float)
- Accessibility_Value__get_maximumValue (*obj, spi_ev ());
+ Accessibility_Value__get_maximumValue (CSPI_OBJREF (obj), cspi_ev ());
}
AccessibleValue_setCurrentValue (AccessibleValue *obj,
float newValue)
{
- Accessibility_Value__set_currentValue (*obj,
- (CORBA_float) newValue, spi_ev ());
+ Accessibility_Value__set_currentValue (CSPI_OBJREF (obj),
+ (CORBA_float) newValue, cspi_ev ());
return TRUE;
}
{
SpiAccessible *accessible = SPI_ACCESSIBLE (object);
- printf("spi_accessible_object_finalize called\n");
ATK_OBJECT (accessible->atko); /* assertion */
g_object_unref (G_OBJECT(accessible->atko));
accessible->atko = NULL;
- printf("atko freed, calling parent finalize\n");
spi_accessible_parent_class->finalize (object);
}
parent = atk_object_get_parent (accessible->atko);
retval = BONOBO_OBJREF (spi_accessible_new (parent));
- printf ("SpiAccessible get_parent called\n");
-
- return CORBA_Object_duplicate (retval, ev);
+ return bonobo_object_dup_ref (retval, ev);
}
/*
SpiAccessible *accessible = SPI_ACCESSIBLE (bonobo_object_from_servant (servant));
AtkObject *child = atk_object_ref_accessible_child (accessible->atko, (gint) index);
retval = BONOBO_OBJREF (spi_accessible_new (child));
- printf ("SpiAccessible get_child_at_index called.\n");
- return CORBA_Object_duplicate (retval, ev);
+ return bonobo_object_dup_ref (retval, ev);
}
/*
for (i=0; i<n_relations; ++i)
{
retval->_buffer[i] =
- CORBA_Object_duplicate (bonobo_object_corba_objref (
+ bonobo_object_dup_ref (bonobo_object_corba_objref (
BONOBO_OBJECT (spi_relation_new (atk_relation_set_get_relation (relation_set, i)))),
ev);
}
/* A pointer to our parent object class */
static SpiListenerClass *spi_event_listener_parent_class;
+enum {
+ EVENT,
+ LAST_SIGNAL
+};
+static guint signals [LAST_SIGNAL];
+
/*
* Implemented GObject::finalize
*/
static void
spi_event_listener_object_finalize (GObject *object)
{
+ SpiEventListener *listener = SPI_ACCESSIBLE_EVENT_SPI_LISTENER (object);
#ifdef SPI_DEBUG
fprintf(stderr, "spi_listener_object_finalize called\n");
#endif
+ g_list_free (listener->callbacks);
+
((GObjectClass *) spi_event_listener_parent_class)->finalize (object);
}
const Accessibility_Event *e,
CORBA_Environment *ev)
{
- int n;
- int len;
+ GList *l;
VoidSpiEventListenerCB cb;
SpiEventListener *listener = SPI_ACCESSIBLE_EVENT_SPI_LISTENER (
bonobo_object_from_servant (servant));
- len = g_list_length (listener->callbacks);
- for (n=0; n<len; ++n)
+ for (l = listener->callbacks; l; l = l->next)
{
- cb = (VoidSpiEventListenerCB) g_list_nth_data (listener->callbacks, n);
+ cb = (VoidSpiEventListenerCB) l->data;
if (cb)
{
(*cb) (e);
}
}
- /* Accessibility_Accessible_unref (e->source, ev); */
+
+ g_signal_emit (G_OBJECT (listener), signals [EVENT], 0, e);
}
static void
POA_Accessibility_EventListener__epv *epv = &spi_listener_class->epv;
spi_event_listener_parent_class = g_type_class_ref (SPI_LISTENER_TYPE);
+ signals [EVENT] = g_signal_new (
+ "event",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (SpiEventListenerClass, event),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
object_class->finalize = spi_event_listener_object_finalize;
epv->notifyEvent = impl_accessible_event_notify_event;
spi_event_listener_add_callback (SpiEventListener *listener,
VoidSpiEventListenerCB callback)
{
- listener->callbacks = g_list_append (listener->callbacks, callback);
+ listener->callbacks = g_list_prepend (listener->callbacks, callback);
}
void
G_BEGIN_DECLS
+/* FIXME: these macro names are all messed up, probably from the namespacing */
+
#define SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE (spi_event_listener_get_type ())
#define SPI_ACCESSIBLE_EVENT_SPI_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE, SpiEventListener))
#define SPI_ACCESSIBLE_EVENT_SPI_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE, SpiEventListenerClass))
-#define IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER(o) (G_TYPE_CHECK__INSTANCE_TYPE ((o), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE))
+#define IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE))
#define IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE))
-typedef void (*VoidSpiEventListenerCB) (gpointer event_ptr);
+typedef void (*VoidSpiEventListenerCB) (const Accessibility_Event *e);
-typedef struct {
+typedef struct _SpiEventListener SpiEventListener;
+
+struct _SpiEventListener {
SpiListener parent;
- GList *callbacks;
-} SpiEventListener;
+ GList *callbacks;
+};
typedef struct {
SpiListenerClass parent_class;
+
+ /* signals */
+ void (*event) (SpiEventListener *listener,
+ Accessibility_Event *e);
+
} SpiEventListenerClass;
-GType spi_event_listener_get_type (void);
-SpiEventListener *spi_event_listener_new (void);
-void spi_event_listener_add_callback (SpiEventListener *listener,
- VoidSpiEventListenerCB callback);
-void spi_event_listener_remove_callback (SpiEventListener *listener,
- VoidSpiEventListenerCB callback);
+GType spi_event_listener_get_type (void);
+SpiEventListener *spi_event_listener_new (void);
+void spi_event_listener_add_callback (SpiEventListener *listener,
+ VoidSpiEventListenerCB callback);
+void spi_event_listener_remove_callback (SpiEventListener *listener,
+ VoidSpiEventListenerCB callback);
G_END_DECLS
spi_accessible_application_finalize (GObject *object)
{
/* TODO: any necessary cleanup */
+ g_print ("application finalize called\n");
(G_OBJECT_CLASS (spi_application_parent_class))->finalize (object);
}
spi_application_new (AtkObject *app_root)
{
SpiApplication *retval = g_object_new (SPI_APPLICATION_TYPE, NULL);
+ g_object_unref (retval->parent.atko);
retval->parent.atko = app_root;
g_object_ref (G_OBJECT (app_root));
return retval;
atk_object_set_name (ATK_OBJECT (SPI_ACCESSIBLE (desktop)->atko), "main");
}
+static void
+spi_desktop_finalize (GObject *object)
+{
+ (G_OBJECT_CLASS (parent_class))->finalize (object);
+}
+
static CORBA_long
impl_desktop_get_child_count (PortableServer_Servant servant,
CORBA_Environment * ev)
/* */
fprintf (stderr, "object address %p\n",
g_list_nth_data (desktop->applications, index));
- retval = CORBA_Object_duplicate (
+ retval = bonobo_object_dup_ref (
(CORBA_Object) g_list_nth_data (desktop->applications, index), ev);
}
else
static void
spi_desktop_class_init (SpiDesktopClass *klass)
{
+ GObjectClass * object_class = (GObjectClass *) klass;
SpiAccessibleClass * spi_accessible_class = (SpiAccessibleClass *) klass;
POA_Accessibility_Accessible__epv *epv = &spi_accessible_class->epv;
+ object_class->finalize = spi_desktop_finalize;
+
parent_class = g_type_class_ref (SPI_ACCESSIBLE_TYPE);
epv->_get_childCount = impl_desktop_get_child_count;
CORBA_Environment *ev)
{
DEControllerKeyListener *key_listener = g_new0 (DEControllerKeyListener, 1);
- key_listener->listener.object = CORBA_Object_duplicate (l, ev);
+ key_listener->listener.object = bonobo_object_dup_ref (l, ev);
key_listener->listener.type = SPI_DEVICE_TYPE_KBD;
key_listener->keys = ORBit_copy_value (keys, TC_Accessibility_KeySet);
key_listener->mask = ORBit_copy_value (mask, TC_Accessibility_ControllerEventMask);
}
static void
+dec_key_listener_free (DEControllerKeyListener *key_listener, CORBA_Environment *ev)
+{
+ bonobo_object_release_unref (key_listener->listener.object, ev);
+ CORBA_free (key_listener->typeseq);
+ CORBA_free (key_listener->mask);
+ CORBA_free (key_listener->keys);
+ g_free (key_listener);
+}
+
+static void
controller_register_device_listener (SpiDeviceEventController *controller,
DEControllerListener *listener,
CORBA_Environment *ev)
switch (listener->type) {
case SPI_DEVICE_TYPE_KBD:
key_listener = (DEControllerKeyListener *) listener;
- controller->key_listeners = g_list_append (controller->key_listeners, key_listener);
+ controller->key_listeners = g_list_prepend (controller->key_listeners, key_listener);
if (key_listener->is_system_global)
{
mask_ptr = (Accessibility_ControllerEventMask *)
{
Accessibility_ControllerEventMask *mask_ptr;
DEControllerKeyListener *key_listener;
+ DEControllerListener *dec_listener;
GList *list_ptr;
switch (listener->type) {
case SPI_DEVICE_TYPE_KBD:
key_listener = (DEControllerKeyListener *) listener;
- list_ptr = g_list_find_custom (controller->key_listeners, listener, _compare_listeners);
- /* TODO: need a different custom compare func */
- if (list_ptr)
- controller->key_listeners = g_list_remove (controller->key_listeners, list_ptr);
+ /* first, deref matching event mask, if any */
list_ptr = (GList *)
g_list_find_custom (controller->keymask_list, (gpointer) key_listener->mask,
_eventmask_compare_value);
if (!mask_ptr->refcount)
{
controller->keymask_list =
- g_list_remove (controller->keymask_list, mask_ptr);
+ g_list_remove_link (controller->keymask_list, list_ptr);
; /* TODO: release any key grabs that are in place for this key mask */
}
}
+ /* now, remove this listener from the keylistener list */
+ list_ptr = g_list_find_custom (controller->key_listeners, listener, _compare_listeners);
+ if (list_ptr)
+ {
+ dec_listener = (DEControllerListener *) list_ptr->data;
+#ifdef SPI_DEBUG
+ g_print ("removing keylistener %p\n", dec_listener->object);
+#endif
+ controller->key_listeners = g_list_remove_link (controller->key_listeners,
+ list_ptr);
+ dec_key_listener_free (dec_listener, ev);
+ }
break;
case SPI_DEVICE_TYPE_MOUSE:
/* controller->mouse_listeners = g_list_append (controller->mouse_listeners,
#ifdef SPI_DEBUG
fprintf(stderr, "spi_device_event_controller_object_finalize called\n");
#endif
+ /* disconnect any special listeners, get rid of outstanding keygrabs */
+
spi_device_event_controller_parent_class->finalize (object);
}
type,
is_system_global,
ev);
-#ifdef SPI_DEBUG
+#ifdef SPI_DEREGISTER_DEBUG
fprintf (stderr, "deregistering keystroke listener %p with maskVal %lu\n",
(void *) l, (unsigned long) mask->value);
#endif
controller_deregister_device_listener(controller,
(DEControllerListener *) key_listener,
ev);
+ dec_key_listener_free (key_listener, ev);
}
/*
/* A pointer to our parent object class */
static SpiListenerClass *spi_event_listener_parent_class;
+enum {
+ EVENT,
+ LAST_SIGNAL
+};
+static guint signals [LAST_SIGNAL];
+
/*
* Implemented GObject::finalize
*/
static void
spi_event_listener_object_finalize (GObject *object)
{
+ SpiEventListener *listener = SPI_ACCESSIBLE_EVENT_SPI_LISTENER (object);
#ifdef SPI_DEBUG
fprintf(stderr, "spi_listener_object_finalize called\n");
#endif
+ g_list_free (listener->callbacks);
+
((GObjectClass *) spi_event_listener_parent_class)->finalize (object);
}
const Accessibility_Event *e,
CORBA_Environment *ev)
{
- int n;
- int len;
+ GList *l;
VoidSpiEventListenerCB cb;
SpiEventListener *listener = SPI_ACCESSIBLE_EVENT_SPI_LISTENER (
bonobo_object_from_servant (servant));
- len = g_list_length (listener->callbacks);
- for (n=0; n<len; ++n)
+ for (l = listener->callbacks; l; l = l->next)
{
- cb = (VoidSpiEventListenerCB) g_list_nth_data (listener->callbacks, n);
+ cb = (VoidSpiEventListenerCB) l->data;
if (cb)
{
(*cb) (e);
}
}
- /* Accessibility_Accessible_unref (e->source, ev); */
+
+ g_signal_emit (G_OBJECT (listener), signals [EVENT], 0, e);
}
static void
POA_Accessibility_EventListener__epv *epv = &spi_listener_class->epv;
spi_event_listener_parent_class = g_type_class_ref (SPI_LISTENER_TYPE);
+ signals [EVENT] = g_signal_new (
+ "event",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (SpiEventListenerClass, event),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
object_class->finalize = spi_event_listener_object_finalize;
epv->notifyEvent = impl_accessible_event_notify_event;
spi_event_listener_add_callback (SpiEventListener *listener,
VoidSpiEventListenerCB callback)
{
- listener->callbacks = g_list_append (listener->callbacks, callback);
+ listener->callbacks = g_list_prepend (listener->callbacks, callback);
}
void
G_BEGIN_DECLS
+/* FIXME: these macro names are all messed up, probably from the namespacing */
+
#define SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE (spi_event_listener_get_type ())
#define SPI_ACCESSIBLE_EVENT_SPI_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE, SpiEventListener))
#define SPI_ACCESSIBLE_EVENT_SPI_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE, SpiEventListenerClass))
-#define IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER(o) (G_TYPE_CHECK__INSTANCE_TYPE ((o), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE))
+#define IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE))
#define IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE))
-typedef void (*VoidSpiEventListenerCB) (gpointer event_ptr);
+typedef void (*VoidSpiEventListenerCB) (const Accessibility_Event *e);
-typedef struct {
+typedef struct _SpiEventListener SpiEventListener;
+
+struct _SpiEventListener {
SpiListener parent;
- GList *callbacks;
-} SpiEventListener;
+ GList *callbacks;
+};
typedef struct {
SpiListenerClass parent_class;
+
+ /* signals */
+ void (*event) (SpiEventListener *listener,
+ Accessibility_Event *e);
+
} SpiEventListenerClass;
-GType spi_event_listener_get_type (void);
-SpiEventListener *spi_event_listener_new (void);
-void spi_event_listener_add_callback (SpiEventListener *listener,
- VoidSpiEventListenerCB callback);
-void spi_event_listener_remove_callback (SpiEventListener *listener,
- VoidSpiEventListenerCB callback);
+GType spi_event_listener_get_type (void);
+SpiEventListener *spi_event_listener_new (void);
+void spi_event_listener_add_callback (SpiEventListener *listener,
+ VoidSpiEventListenerCB callback);
+void spi_event_listener_remove_callback (SpiEventListener *listener,
+ VoidSpiEventListenerCB callback);
G_END_DECLS
static void
spi_hypertext_finalize (GObject *obj)
{
- SpiHypertext *hypertext = SPI_HYPERTEXT(obj);
- g_object_unref (hypertext->atko);
- hypertext->atko = NULL;
parent_class->finalize (obj);
}
spi_hypertext_interface_new (AtkObject *obj)
{
SpiHypertext *new_hypertext = g_object_new (SPI_HYPERTEXT_TYPE, NULL);
- new_hypertext->atko = obj;
+ (SPI_TEXT (new_hypertext))->atko = obj;
g_object_ref (obj);
return new_hypertext;
}
impl_getNLinks (PortableServer_Servant _servant,
CORBA_Environment * ev)
{
- SpiHypertext *hypertext = SPI_HYPERTEXT(bonobo_object_from_servant(_servant));
+ SpiHypertext *hypertext = SPI_HYPERTEXT (bonobo_object_from_servant(_servant));
return (CORBA_long)
- atk_hypertext_get_n_links (ATK_HYPERTEXT(hypertext->atko));
+ atk_hypertext_get_n_links (ATK_HYPERTEXT ((SPI_TEXT (hypertext))->atko));
}
hypertext = SPI_HYPERTEXT (bonobo_object_from_servant (servant));
link = atk_hypertext_get_link (
- ATK_HYPERTEXT (hypertext->atko), linkIndex);
+ ATK_HYPERTEXT ((SPI_TEXT (hypertext))->atko), linkIndex);
rv = bonobo_object_corba_objref (BONOBO_OBJECT (
spi_hyperlink_new (ATK_OBJECT (link))));
{
SpiHypertext *hypertext = SPI_HYPERTEXT(bonobo_object_from_servant(_servant));
return (CORBA_long)
- atk_hypertext_get_link_index (ATK_HYPERTEXT(hypertext->atko),
+ atk_hypertext_get_link_index (ATK_HYPERTEXT ((SPI_TEXT (hypertext))->atko),
(gint) characterIndex);
}
#include <bonobo/bonobo-object.h>
#include <atk/atk.h>
#include <libspi/Accessibility.h>
+#include <libspi/text.h>
G_BEGIN_DECLS
typedef struct _HypertextClass SpiHypertextClass;
struct _Hypertext {
- BonoboObject parent;
- AtkObject *atko;
+ SpiText parent;
};
struct _HypertextClass {
#ifdef SPI_DEBUG
# include <stdio.h>
#endif
+#include <libspi/listener.h>
#include <libspi/keystrokelistener.h>
/* Our parent Gtk object type */
#define PARENT_TYPE BONOBO_TYPE_OBJECT
/* A pointer to our parent object class */
-static GObjectClass *keystroke_listener_parent_class;
+static BonoboObjectClass *keystroke_listener_parent_class;
-/*
- * Implemented GObject::finalize
- */
+enum {
+ KEY_EVENT,
+ LAST_SIGNAL
+};
+static guint signals [LAST_SIGNAL];
+
+/* GObject::finalize */
static void
-keystroke_listener_object_finalize (GObject *object)
+spi_keystroke_listener_object_finalize (GObject *object)
{
+ SpiKeystrokeListener *listener = SPI_KEYSTROKE_LISTENER (object);
+ g_list_free (listener->callbacks);
#ifdef SPI_DEBUG
- fprintf(stderr, "keystroke_listener_object_finalize called\n");
+ fprintf(stderr, "keystroke_listener_object_finalize called\n");
#endif
- keystroke_listener_parent_class->finalize (object);
+ ((GObjectClass *) keystroke_listener_parent_class)->finalize (object);
}
void spi_keystroke_listener_add_callback (SpiKeystrokeListener *listener,
#endif
}
-void spi_keystroke_listener_remove_callback (SpiKeystrokeListener *listener,
- BooleanKeystrokeListenerCB callback)
+void
+spi_keystroke_listener_remove_callback (SpiKeystrokeListener *listener,
+ BooleanKeystrokeListenerCB callback)
{
listener->callbacks = g_list_remove (listener->callbacks, callback);
}
SpiKeystrokeListener *listener = SPI_KEYSTROKE_LISTENER (bonobo_object_from_servant (servant));
GList *callbacks = listener->callbacks;
gboolean was_consumed = FALSE;
+
+ g_signal_emit (G_OBJECT (listener), signals [KEY_EVENT], 0, key, &was_consumed);
+ if (was_consumed)
+ {
+ return TRUE;
+ }
+
#ifdef SPI_KEYEVENT_DEBUG
if (ev->_major != CORBA_NO_EXCEPTION) {
fprintf(stderr,
return was_consumed;
}
-static void
-spi_keystroke_listener_class_init (SpiKeystrokeListenerClass *klass)
+
+static gboolean
+boolean_handled_accumulator (GSignalInvocationHint *ihint,
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer dummy)
+{
+ gboolean continue_emission;
+ gboolean signal_handled;
+
+ signal_handled = g_value_get_boolean (handler_return);
+ g_value_set_boolean (return_accu, signal_handled);
+ continue_emission = !signal_handled;
+
+ return continue_emission;
+}
+
+void
+marshal_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
{
- GObjectClass * object_class = (GObjectClass *) klass;
- POA_Accessibility_KeystrokeListener__epv *epv = &klass->epv;
- keystroke_listener_parent_class = g_type_class_peek_parent (klass);
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 2);
- object_class->finalize = keystroke_listener_object_finalize;
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
- epv->keyEvent = impl_key_event;
+ v_return = callback (data1,
+ g_value_get_pointer (param_values + 1),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+static void
+spi_keystroke_listener_class_init (SpiKeystrokeListenerClass *klass)
+{
+ GObjectClass * object_class = (GObjectClass *) klass;
+ POA_Accessibility_KeystrokeListener__epv *epv = &klass->epv;
+ keystroke_listener_parent_class = g_type_class_peek_parent (klass);
+
+ signals [KEY_EVENT] = g_signal_new (
+ "key_event",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (SpiKeystrokeListenerClass, key_event),
+ boolean_handled_accumulator, NULL,
+ marshal_BOOLEAN__POINTER,
+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
+
+ object_class->finalize = spi_keystroke_listener_object_finalize;
+
+ epv->keyEvent = impl_key_event;
}
static void
spi_keystroke_listener_init (SpiKeystrokeListener *keystroke_listener)
{
- keystroke_listener->callbacks = NULL;
+ keystroke_listener->callbacks = NULL;
}
BONOBO_TYPE_FUNC_FULL (SpiKeystrokeListener,
typedef struct {
BonoboObjectClass parent_class;
POA_Accessibility_KeystrokeListener__epv epv;
+
+ gboolean (*key_event) (SpiKeystrokeListener *listener,
+ const Accessibility_KeyStroke *key);
} SpiKeystrokeListenerClass;
GType spi_keystroke_listener_get_type (void);
static gboolean _device_event_controller_hook (gpointer source);
-/*
- * Implemented GObject::finalize
- */
+SpiListenerStruct *
+spi_listener_struct_new (Accessibility_EventListener *listener, CORBA_Environment *ev)
+{
+ SpiListenerStruct *retval = g_malloc (sizeof (SpiListenerStruct));
+ retval->listener = bonobo_object_dup_ref (listener, ev);
+ return retval;
+}
+
+void
+spi_listener_struct_free (SpiListenerStruct *ls, CORBA_Environment *ev)
+{
+ /* TODO: sanity check for ls */
+ Accessibility_EventListener_unref (ls->listener, ev);
+ g_free (ls);
+}
+
+/* GObject::finalize */
static void
spi_registry_object_finalize (GObject *object)
{
-/* SpiRegistry *registry = SPI_REGISTRY (object); */
- GObjectClass *object_class = G_OBJECT_GET_CLASS( object);
+ SpiRegistry *registry = SPI_REGISTRY (object);
printf("spi_registry_object_finalize called\n");
-
- object_class->finalize (object);
+ /* TODO: unref deviceeventcontroller, which disconnects key listener */
+ G_OBJECT_CLASS (spi_registry_parent_class)->finalize (object);
}
/**
CORBA_Environment *ev)
{
SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
- SpiListenerStruct *ls = g_malloc (sizeof (SpiListenerStruct));
+ SpiListenerStruct *ls = spi_listener_struct_new (listener, ev);
EventTypeStruct etype;
fprintf(stderr, "registering for events of type %s\n", event_name);
case (ETYPE_FOCUS) :
case (ETYPE_OBJECT) :
case (ETYPE_PROPERTY) :
- ls->listener = CORBA_Object_duplicate (listener, ev);
registry->object_listeners =
g_list_append (registry->object_listeners, ls);
break;
case (ETYPE_WINDOW) :
/* Support for Window Manager Events is not yet implemented */
+ spi_listener_struct_free (ls, ev);
break;
case (ETYPE_TOOLKIT) :
- ls->listener = CORBA_Object_duplicate (listener, ev);
registry->toolkit_listeners =
g_list_append (registry->toolkit_listeners, ls);
register_with_toolkits (registry, &etype, ev);
break;
default:
+ spi_listener_struct_free (ls, ev);
break;
}
}
CORBA_Environment *ev)
{
SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
- SpiListenerStruct *ls = g_malloc (sizeof (SpiListenerStruct));
+ SpiListenerStruct *spi_listener_struct, *ls = spi_listener_struct_new (listener, ev);
GList *list;
- ls->listener = listener;
list = g_list_find_custom (registry->object_listeners, ls,
compare_listener_corbaref);
while (list)
{
- fprintf (stderr, "deregistering listener\n");
+ spi_listener_struct_free ((SpiListenerStruct *) list->data, ev);
registry->object_listeners = g_list_delete_link (registry->object_listeners, list);
list = g_list_find_custom (registry->object_listeners, ls, compare_listener_corbaref);
}
list = g_list_find_custom (registry->toolkit_listeners, ls, compare_listener_corbaref);
while (list)
{
- fprintf (stderr, "deregistering listener\n");
+ spi_listener_struct_free ((SpiListenerStruct *) list->data, ev);
registry->toolkit_listeners = g_list_delete_link (registry->toolkit_listeners, list);
list = g_list_find_custom (registry->toolkit_listeners, ls, compare_listener_corbaref);
}
+ spi_listener_struct_free (ls, ev);
}
/*
CORBA_Environment *ev)
{
SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
- SpiListenerStruct ls;
+ SpiListenerStruct ls, *spi_listener_struct;
EventTypeStruct etype;
GList *list;
GList **listeners;
while (list)
{
- fprintf (stderr, "deregistering listener\n");
+ spi_listener_struct_free ((SpiListenerStruct *) list->data, ev);
*listeners = g_list_delete_link (*listeners, list);
list = g_list_find_custom (*listeners, &ls, compare_listener_hash);
}
if (n == 0)
{
return (Accessibility_Desktop)
- CORBA_Object_duplicate (BONOBO_OBJREF (registry->desktop), ev);
+ bonobo_object_dup_ref (BONOBO_OBJREF (registry->desktop), ev);
}
else
{
if (!registry->device_event_controller)
registry->device_event_controller = spi_device_event_controller_new (registry);
- return CORBA_Object_duplicate (BONOBO_OBJREF (registry->device_event_controller), ev);
+ return bonobo_object_dup_ref (BONOBO_OBJREF (registry->device_event_controller), ev);
}
static void
return ++id;
}
+#define SPI_DEBUG
+
static void
_registry_notify_listeners (GList *listeners,
const Accessibility_Event *e_in,
fprintf(stderr, "event source name %s\n", Accessibility_Accessible__get_name(e_in->source, ev));
#endif
e_out = ORBit_copy_value (e_in, TC_Accessibility_Event);
- e_out->source = CORBA_Object_duplicate (e_in->source, ev);
- Accessibility_Accessible_ref ( e_out->source, ev);
+ e_out->source = bonobo_object_dup_ref (e_in->source, ev);
Accessibility_EventListener_notifyEvent ((Accessibility_EventListener) ls->listener,
e_out,
ev);
atk_object_set_name (ATK_OBJECT (SPI_ACCESSIBLE (desktop)->atko), "main");
}
+static void
+spi_desktop_finalize (GObject *object)
+{
+ (G_OBJECT_CLASS (parent_class))->finalize (object);
+}
+
static CORBA_long
impl_desktop_get_child_count (PortableServer_Servant servant,
CORBA_Environment * ev)
/* */
fprintf (stderr, "object address %p\n",
g_list_nth_data (desktop->applications, index));
- retval = CORBA_Object_duplicate (
+ retval = bonobo_object_dup_ref (
(CORBA_Object) g_list_nth_data (desktop->applications, index), ev);
}
else
static void
spi_desktop_class_init (SpiDesktopClass *klass)
{
+ GObjectClass * object_class = (GObjectClass *) klass;
SpiAccessibleClass * spi_accessible_class = (SpiAccessibleClass *) klass;
POA_Accessibility_Accessible__epv *epv = &spi_accessible_class->epv;
+ object_class->finalize = spi_desktop_finalize;
+
parent_class = g_type_class_ref (SPI_ACCESSIBLE_TYPE);
epv->_get_childCount = impl_desktop_get_child_count;
CORBA_Environment *ev)
{
DEControllerKeyListener *key_listener = g_new0 (DEControllerKeyListener, 1);
- key_listener->listener.object = CORBA_Object_duplicate (l, ev);
+ key_listener->listener.object = bonobo_object_dup_ref (l, ev);
key_listener->listener.type = SPI_DEVICE_TYPE_KBD;
key_listener->keys = ORBit_copy_value (keys, TC_Accessibility_KeySet);
key_listener->mask = ORBit_copy_value (mask, TC_Accessibility_ControllerEventMask);
}
static void
+dec_key_listener_free (DEControllerKeyListener *key_listener, CORBA_Environment *ev)
+{
+ bonobo_object_release_unref (key_listener->listener.object, ev);
+ CORBA_free (key_listener->typeseq);
+ CORBA_free (key_listener->mask);
+ CORBA_free (key_listener->keys);
+ g_free (key_listener);
+}
+
+static void
controller_register_device_listener (SpiDeviceEventController *controller,
DEControllerListener *listener,
CORBA_Environment *ev)
switch (listener->type) {
case SPI_DEVICE_TYPE_KBD:
key_listener = (DEControllerKeyListener *) listener;
- controller->key_listeners = g_list_append (controller->key_listeners, key_listener);
+ controller->key_listeners = g_list_prepend (controller->key_listeners, key_listener);
if (key_listener->is_system_global)
{
mask_ptr = (Accessibility_ControllerEventMask *)
{
Accessibility_ControllerEventMask *mask_ptr;
DEControllerKeyListener *key_listener;
+ DEControllerListener *dec_listener;
GList *list_ptr;
switch (listener->type) {
case SPI_DEVICE_TYPE_KBD:
key_listener = (DEControllerKeyListener *) listener;
- list_ptr = g_list_find_custom (controller->key_listeners, listener, _compare_listeners);
- /* TODO: need a different custom compare func */
- if (list_ptr)
- controller->key_listeners = g_list_remove (controller->key_listeners, list_ptr);
+ /* first, deref matching event mask, if any */
list_ptr = (GList *)
g_list_find_custom (controller->keymask_list, (gpointer) key_listener->mask,
_eventmask_compare_value);
if (!mask_ptr->refcount)
{
controller->keymask_list =
- g_list_remove (controller->keymask_list, mask_ptr);
+ g_list_remove_link (controller->keymask_list, list_ptr);
; /* TODO: release any key grabs that are in place for this key mask */
}
}
+ /* now, remove this listener from the keylistener list */
+ list_ptr = g_list_find_custom (controller->key_listeners, listener, _compare_listeners);
+ if (list_ptr)
+ {
+ dec_listener = (DEControllerListener *) list_ptr->data;
+#ifdef SPI_DEBUG
+ g_print ("removing keylistener %p\n", dec_listener->object);
+#endif
+ controller->key_listeners = g_list_remove_link (controller->key_listeners,
+ list_ptr);
+ dec_key_listener_free (dec_listener, ev);
+ }
break;
case SPI_DEVICE_TYPE_MOUSE:
/* controller->mouse_listeners = g_list_append (controller->mouse_listeners,
#ifdef SPI_DEBUG
fprintf(stderr, "spi_device_event_controller_object_finalize called\n");
#endif
+ /* disconnect any special listeners, get rid of outstanding keygrabs */
+
spi_device_event_controller_parent_class->finalize (object);
}
type,
is_system_global,
ev);
-#ifdef SPI_DEBUG
+#ifdef SPI_DEREGISTER_DEBUG
fprintf (stderr, "deregistering keystroke listener %p with maskVal %lu\n",
(void *) l, (unsigned long) mask->value);
#endif
controller_deregister_device_listener(controller,
(DEControllerListener *) key_listener,
ev);
+ dec_key_listener_free (key_listener, ev);
}
/*
static gboolean _device_event_controller_hook (gpointer source);
-/*
- * Implemented GObject::finalize
- */
+SpiListenerStruct *
+spi_listener_struct_new (Accessibility_EventListener *listener, CORBA_Environment *ev)
+{
+ SpiListenerStruct *retval = g_malloc (sizeof (SpiListenerStruct));
+ retval->listener = bonobo_object_dup_ref (listener, ev);
+ return retval;
+}
+
+void
+spi_listener_struct_free (SpiListenerStruct *ls, CORBA_Environment *ev)
+{
+ /* TODO: sanity check for ls */
+ Accessibility_EventListener_unref (ls->listener, ev);
+ g_free (ls);
+}
+
+/* GObject::finalize */
static void
spi_registry_object_finalize (GObject *object)
{
-/* SpiRegistry *registry = SPI_REGISTRY (object); */
- GObjectClass *object_class = G_OBJECT_GET_CLASS( object);
+ SpiRegistry *registry = SPI_REGISTRY (object);
printf("spi_registry_object_finalize called\n");
-
- object_class->finalize (object);
+ /* TODO: unref deviceeventcontroller, which disconnects key listener */
+ G_OBJECT_CLASS (spi_registry_parent_class)->finalize (object);
}
/**
CORBA_Environment *ev)
{
SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
- SpiListenerStruct *ls = g_malloc (sizeof (SpiListenerStruct));
+ SpiListenerStruct *ls = spi_listener_struct_new (listener, ev);
EventTypeStruct etype;
fprintf(stderr, "registering for events of type %s\n", event_name);
case (ETYPE_FOCUS) :
case (ETYPE_OBJECT) :
case (ETYPE_PROPERTY) :
- ls->listener = CORBA_Object_duplicate (listener, ev);
registry->object_listeners =
g_list_append (registry->object_listeners, ls);
break;
case (ETYPE_WINDOW) :
/* Support for Window Manager Events is not yet implemented */
+ spi_listener_struct_free (ls, ev);
break;
case (ETYPE_TOOLKIT) :
- ls->listener = CORBA_Object_duplicate (listener, ev);
registry->toolkit_listeners =
g_list_append (registry->toolkit_listeners, ls);
register_with_toolkits (registry, &etype, ev);
break;
default:
+ spi_listener_struct_free (ls, ev);
break;
}
}
CORBA_Environment *ev)
{
SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
- SpiListenerStruct *ls = g_malloc (sizeof (SpiListenerStruct));
+ SpiListenerStruct *spi_listener_struct, *ls = spi_listener_struct_new (listener, ev);
GList *list;
- ls->listener = listener;
list = g_list_find_custom (registry->object_listeners, ls,
compare_listener_corbaref);
while (list)
{
- fprintf (stderr, "deregistering listener\n");
+ spi_listener_struct_free ((SpiListenerStruct *) list->data, ev);
registry->object_listeners = g_list_delete_link (registry->object_listeners, list);
list = g_list_find_custom (registry->object_listeners, ls, compare_listener_corbaref);
}
list = g_list_find_custom (registry->toolkit_listeners, ls, compare_listener_corbaref);
while (list)
{
- fprintf (stderr, "deregistering listener\n");
+ spi_listener_struct_free ((SpiListenerStruct *) list->data, ev);
registry->toolkit_listeners = g_list_delete_link (registry->toolkit_listeners, list);
list = g_list_find_custom (registry->toolkit_listeners, ls, compare_listener_corbaref);
}
+ spi_listener_struct_free (ls, ev);
}
/*
CORBA_Environment *ev)
{
SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
- SpiListenerStruct ls;
+ SpiListenerStruct ls, *spi_listener_struct;
EventTypeStruct etype;
GList *list;
GList **listeners;
while (list)
{
- fprintf (stderr, "deregistering listener\n");
+ spi_listener_struct_free ((SpiListenerStruct *) list->data, ev);
*listeners = g_list_delete_link (*listeners, list);
list = g_list_find_custom (*listeners, &ls, compare_listener_hash);
}
if (n == 0)
{
return (Accessibility_Desktop)
- CORBA_Object_duplicate (BONOBO_OBJREF (registry->desktop), ev);
+ bonobo_object_dup_ref (BONOBO_OBJREF (registry->desktop), ev);
}
else
{
if (!registry->device_event_controller)
registry->device_event_controller = spi_device_event_controller_new (registry);
- return CORBA_Object_duplicate (BONOBO_OBJREF (registry->device_event_controller), ev);
+ return bonobo_object_dup_ref (BONOBO_OBJREF (registry->device_event_controller), ev);
}
static void
return ++id;
}
+#define SPI_DEBUG
+
static void
_registry_notify_listeners (GList *listeners,
const Accessibility_Event *e_in,
fprintf(stderr, "event source name %s\n", Accessibility_Accessible__get_name(e_in->source, ev));
#endif
e_out = ORBit_copy_value (e_in, TC_Accessibility_Event);
- e_out->source = CORBA_Object_duplicate (e_in->source, ev);
- Accessibility_Accessible_ref ( e_out->source, ev);
+ e_out->source = bonobo_object_dup_ref (e_in->source, ev);
Accessibility_EventListener_notifyEvent ((Accessibility_EventListener) ls->listener,
e_out,
ev);
* Boston, MA 02111-1307, USA.
*/
+#include <stdio.h>
+#include <string.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
}
static boolean
-is_command_key (void *p)
+is_command_key (AccessibleKeystroke *key)
{
- AccessibleKeyStroke *key = (AccessibleKeyStroke *)p;
switch (key->keyID)
{
case 'Q':
keysynth_exit();
return TRUE; /* not reached */
}
+ return FALSE;
}
static boolean
-switch_callback (void *p)
+switch_callback (AccessibleKeystroke *key)
{
- AccessibleKeyStroke *key = (AccessibleKeyStroke *)p;
- static is_down = FALSE;
- if (key->type == Accessibility_KEY_RELEASED)
+ static boolean is_down = FALSE;
+ if (key->type == SPI_KEY_RELEASED)
{
g_print ("spacebar up\n");
is_down = FALSE;
static void
create_vkbd()
{
- GtkWidget *window, *button, *container, *hbox;
+ GtkWidget *window, *container, *hbox;
int i, j;
KeyCode *keycodeptr, keycode = MIN_KEYCODE;
static boolean true_val = True;
AccessibleKeySet switch_set;
if ((argc > 1) && (!strncmp(argv[1],"-h",2)))
- {
- printf ("Usage: keysynth-demo\n");
- exit(0);
- }
+ {
+ printf ("Usage: keysynth-demo\n");
+ exit (1);
+ }
gtk_init (&argc, &argv); /* must call, because this program uses GTK+ */
- SPI_init();
+ SPI_init ();
- key_listener = createAccessibleKeystrokeListener(is_command_key);
+ key_listener = createAccessibleKeystrokeListener (is_command_key);
/* will listen only to Alt-key combinations */
- registerAccessibleKeystrokeListener(key_listener,
- (AccessibleKeySet *) SPI_KEYSET_ALL_KEYS,
- SPI_KEYMASK_ALT,
- (unsigned long) ( KeyPress | KeyRelease),
- SPI_KEYLISTENER_CANCONSUME | SPI_KEYLISTENER_ALL_WINDOWS);
- create_vkbd();
+ registerAccessibleKeystrokeListener (key_listener,
+ (AccessibleKeySet *) SPI_KEYSET_ALL_KEYS,
+ SPI_KEYMASK_ALT,
+ (unsigned long) ( KeyPress | KeyRelease),
+ SPI_KEYLISTENER_CANCONSUME | SPI_KEYLISTENER_ALL_WINDOWS);
+ create_vkbd ();
/*
* Register a listener on an 'unused' key, to serve as a 'single switch'.
switch_set.len = 1;
switch_set.keysyms[0] = (unsigned long) 0;
switch_set.keycodes[0] = (unsigned short) 0;
- switch_listener = createAccessibleKeystrokeListener(switch_callback);
- registerAccessibleKeystrokeListener(switch_listener,
- &switch_set,
- SPI_KEYMASK_UNMODIFIED,
- (unsigned long) ( KeyPress | KeyRelease),
- SPI_KEYLISTENER_CANCONSUME);
+ switch_listener = createAccessibleKeystrokeListener (switch_callback);
+ registerAccessibleKeystrokeListener (switch_listener,
+ &switch_set,
+ SPI_KEYMASK_UNMODIFIED,
+ (unsigned long) ( KeyPress | KeyRelease),
+ SPI_KEYLISTENER_CANCONSUME);
- SPI_event_main(TRUE);
+ SPI_event_main (TRUE);
+
+ return 0;
}
*/
#include <stdlib.h>
+#include <ctype.h>
+#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
-#include "spi.h"
-
-static void report_focus_event (void *fp);
-static void report_button_press (void *fp);
-static boolean report_command_key_event (void *fp);
-static boolean report_ordinary_key_event (void *fp);
-static void check_property_change (void *fp);
+#include <cspi/spi.h>
+#include "../util/mag_client.h"
+
+static void report_focus_event (AccessibleEvent *event);
+static void report_button_press (AccessibleEvent *event);
+static void check_property_change (AccessibleEvent *event);
+static boolean report_command_key_event (AccessibleKeystroke *stroke);
+static boolean report_ordinary_key_event (AccessibleKeystroke *stroke);
static void get_environment_vars (void);
static int _festival_init ();
fprintf (stderr, "app %d name: %s\n", j, Accessible_getName (application));
Accessible_unref (application);
}
+ Accessible_unref (desktop);
}
/* prepare the keyboard snoopers */
- command_key_listener = createAccessibleKeystrokeListener(report_command_key_event);
- ordinary_key_listener = createAccessibleKeystrokeListener(report_ordinary_key_event);
+ command_key_listener = createAccessibleKeystrokeListener (report_command_key_event);
+ ordinary_key_listener = createAccessibleKeystrokeListener (report_ordinary_key_event);
/* will listen only to Alt-key combinations, and only to KeyPress events */
registerAccessibleKeystrokeListener(command_key_listener,
long start_offset, end_offset;
char *first_sentence = "empty";
text_interface = Accessible_getText (obj);
- fprintf (stderr, "isText...%p %p\n", text_interface, (void *)*text_interface);
+ fprintf (stderr, "isText...%p\n", text_interface);
first_sentence = AccessibleText_getTextAtOffset (
text_interface, (long) 0, SPI_TEXT_BOUNDARY_SENTENCE_START, &start_offset, &end_offset);
if (first_sentence) _festival_say(first_sentence, "voice_don_diphone", FALSE);
}
void
-report_focus_event (void *p)
+report_focus_event (AccessibleEvent *event)
{
- AccessibleEvent *ev = (AccessibleEvent *) p;
- fprintf (stderr, "%s event from %s\n", ev->type,
- Accessible_getName (&ev->source));
- report_focussed_accessible (&ev->source, TRUE);
+ fprintf (stderr, "%s event from %s\n", event->type,
+ Accessible_getName (event->source));
+ report_focussed_accessible (event->source, TRUE);
}
void
-report_button_press (void *p)
+report_button_press (AccessibleEvent *event)
{
- AccessibleEvent *ev = (AccessibleEvent *) p;
- fprintf (stderr, "%s event from %s\n", ev->type,
- Accessible_getName (&ev->source));
+ fprintf (stderr, "%s event from %s\n", event->type,
+ Accessible_getName (event->source));
fprintf (stderr, "Object description %s\n",
- Accessible_getDescription (&ev->source));
+ Accessible_getDescription (event->source));
}
void
-check_property_change (void *p)
+check_property_change (AccessibleEvent *event)
{
- AccessibleEvent *ev = (AccessibleEvent *) p;
- AccessibleSelection *selection = Accessible_getSelection (&ev->source);
+ AccessibleSelection *selection = Accessible_getSelection (event->source);
int n_selections;
int i;
if (selection)
{
n_selections = (int) AccessibleSelection_getNSelectedChildren (selection);
- fprintf (stderr, "(Property) %s event from %s, %d selected children\n", ev->type,
- Accessible_getName (&ev->source), n_selections);
+ fprintf (stderr, "(Property) %s event from %s, %d selected children\n",
+ event->type, Accessible_getName (event->source), n_selections);
/* for now, speak entire selection set */
for (i=0; i<n_selections; ++i)
- {
- Accessible *obj = AccessibleSelection_getSelectedChild (selection, (long) i);
- g_return_if_fail (obj);
- fprintf (stderr, "Child %d, name=%s\n", i, Accessible_getName (obj));
- report_focussed_accessible (obj, i==0);
+ {
+ Accessible *obj = AccessibleSelection_getSelectedChild (selection, (long) i);
+ g_return_if_fail (obj);
+ fprintf (stderr, "Child %d, name=%s\n", i, Accessible_getName (obj));
+ report_focussed_accessible (obj, i==0);
}
}
}
deregisterGlobalEventListenerAll (focus_listener);
deregisterGlobalEventListenerAll (property_listener);
deregisterGlobalEventListenerAll (button_listener);
+
deregisterAccessibleKeystrokeListener (command_key_listener, SPI_KEYMASK_ALT );
deregisterAccessibleKeystrokeListener (ordinary_key_listener, SPI_KEYMASK_UNMODIFIED );
deregisterAccessibleKeystrokeListener (ordinary_key_listener, SPI_KEYMASK_SHIFT );
+ AccessibleKeystrokeListener_unref (command_key_listener);
+ AccessibleKeystrokeListener_unref (ordinary_key_listener);
SPI_exit ();
}
static boolean
-is_command_key (AccessibleKeyStroke *key)
+is_command_key (AccessibleKeystroke *key)
{
switch (key->keyID)
{
}
static boolean
-report_command_key_event (void *p)
+report_command_key_event (AccessibleKeystroke *key)
{
- AccessibleKeyStroke *key = (AccessibleKeyStroke *) p;
fprintf (stderr, "Command KeyEvent %s%c (keycode %d)\n",
(key->modifiers & SPI_KEYMASK_ALT)?"Alt-":"",
((key->modifiers & SPI_KEYMASK_SHIFT)^(key->modifiers & SPI_KEYMASK_SHIFTLOCK))?
static boolean
-report_ordinary_key_event (void *p)
+report_ordinary_key_event (AccessibleKeystroke *key)
{
- AccessibleKeyStroke *key = (AccessibleKeyStroke *) p;
fprintf (stderr, "Received key event:\tsym %ld\n\tmods %x\n\tcode %d\n\ttime %ld\n",
(long) key->keyID,
(unsigned int) key->modifiers,
(int) key->keycode,
(long int) key->timestamp);
+ return FALSE;
}
static int _festival_init ()
#ifndef MAG_CLIENT_H_
#define MAG_CLIENT_H_
+#include "util/Magnifier.h"
#ifdef __cplusplus
extern "C" {
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#include <libbonobo.h>
#include "Magnifier.h"
#include "mag_client.h"
#include <popt.h>
#include <gdk/gdkwindow.h>
-#include <bonobo/Bonobo.h>
+#include <libbonobo.h>
#include "magnifier.h"
#include "mag_image.h"