* Boston, MA 02111-1307, USA.
*/
-/*
- * listener.c: test for accessibility implementation
- *
- */
+/* keystrokelistener.c: implement the KeystrokeListener interface */
+#include <config.h>
#ifdef SPI_DEBUG
-#include <stdio.h>
+# include <stdio.h>
#endif
+#include <libspi/keystrokelistener.h>
-#include <config.h>
-#include <bonobo/Bonobo.h>
-#include <libspi/Accessibility.h>
+/* Our parent Gtk object type */
+#define PARENT_TYPE BONOBO_TYPE_OBJECT
-/*
- * This pulls the definition for the BonoboObject (GType)
- */
-#include "keystrokelistener.h"
-
-/*
- * Our parent Gtk object type
- */
-#define PARENT_TYPE BONOBO_OBJECT_TYPE
-
-/*
- * A pointer to our parent object class
- */
-static GObjectClass *keystroke_spi_listener_parent_class;
+/* A pointer to our parent object class */
+static GObjectClass *keystroke_listener_parent_class;
/*
* Implemented GObject::finalize
*/
static void
-keystroke_spi_listener_object_finalize (GObject *object)
+keystroke_listener_object_finalize (GObject *object)
{
-/* KeystrokeListener *keystroke_listener = KEYSTROKE_SPI_LISTENER (object); */
#ifdef SPI_DEBUG
- fprintf(stderr, "keystroke_spi_listener_object_finalize called\n");
+ fprintf(stderr, "keystroke_listener_object_finalize called\n");
#endif
- keystroke_spi_listener_parent_class->finalize (object);
+ keystroke_listener_parent_class->finalize (object);
}
-void keystroke_spi_listener_add_callback (KeystrokeListener *listener,
- BooleanKeystrokeListenerCB callback)
+void spi_keystroke_listener_add_callback (SpiKeystrokeListener *listener,
+ BooleanKeystrokeListenerCB callback)
{
listener->callbacks = g_list_append (listener->callbacks, callback);
#ifdef SPI_DEBUG
- fprintf(stderr, "keystroke_spi_listener_add_callback (%p) called\n",
+ fprintf(stderr, "keystroke_listener_add_callback (%p) called\n",
(gpointer) callback);
#endif
}
-void keystroke_spi_listener_remove_callback (KeystrokeListener *listener,
+void keystroke_listener_remove_callback (SpiKeystrokeListener *listener,
BooleanKeystrokeListenerCB callback)
{
listener->callbacks = g_list_remove (listener->callbacks, callback);
const Accessibility_KeyStroke *key,
CORBA_Environment *ev)
{
- KeystrokeListener *listener = KEYSTROKE_SPI_LISTENER (bonobo_object_from_servant (servant));
+ SpiKeystrokeListener *listener = SPI_KEYSTROKE_LISTENER (bonobo_object_from_servant (servant));
GList *callbacks = listener->callbacks;
gboolean was_consumed = FALSE;
#ifdef SPI_KEYEVENT_DEBUG
}
else {
fprintf(stderr, "%s%c",
- (key->modifiers & KEYMASK_ALT)?"Alt-":"",
- ((key->modifiers & KEYMASK_SHIFT)^(key->modifiers & KEYMASK_SHIFTLOCK))?
+ (key->modifiers & SPI_KEYMASK_ALT)?"Alt-":"",
+ ((key->modifiers & SPI_KEYMASK_SHIFT)^(key->modifiers & SPI_KEYMASK_SHIFTLOCK))?
(char) toupper((int) key->keyID) : (char) tolower((int) key->keyID));
}
#endif
}
static void
-keystroke_spi_listener_class_init (KeystrokeListenerClass *klass)
+spi_keystroke_listener_class_init (SpiKeystrokeListenerClass *klass)
{
GObjectClass * object_class = (GObjectClass *) klass;
POA_Accessibility_KeystrokeListener__epv *epv = &klass->epv;
- keystroke_spi_listener_parent_class = g_type_class_ref (BONOBO_OBJECT_TYPE);
+ keystroke_listener_parent_class = g_type_class_peek_parent (klass);
- object_class->finalize = keystroke_spi_listener_object_finalize;
+ object_class->finalize = keystroke_listener_object_finalize;
epv->keyEvent = impl_key_event;
}
static void
-keystroke_spi_listener_init (KeystrokeListener *keystroke_listener)
+spi_keystroke_listener_init (SpiKeystrokeListener *keystroke_listener)
{
keystroke_listener->callbacks = NULL;
}
-GType
-keystroke_spi_listener_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo tinfo = {
- sizeof (KeystrokeListenerClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) keystroke_spi_listener_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class data */
- sizeof (KeystrokeListener),
- 0, /* n preallocs */
- (GInstanceInitFunc) keystroke_spi_listener_init,
- NULL /* value table */
- };
- /*
- * Here we use bonobo_type_unique instead of
- * gtk_type_unique, this auto-generates a load of
- * CORBA structures for us. All derived types must
- * use bonobo_type_unique.
- */
- type = bonobo_type_unique (
- PARENT_TYPE,
- POA_Accessibility_KeystrokeListener__init,
- NULL,
- G_STRUCT_OFFSET (KeystrokeListenerClass, epv),
- &tinfo,
- "KeystrokeListener");
- }
-
- return type;
-}
+BONOBO_TYPE_FUNC_FULL (SpiKeystrokeListener,
+ Accessibility_KeystrokeListener,
+ BONOBO_TYPE_OBJECT,
+ spi_keystroke_listener);
-KeystrokeListener *
-keystroke_spi_listener_new (void)
+SpiKeystrokeListener *
+spi_keystroke_listener_new (void)
{
- KeystrokeListener *retval =
- KEYSTROKE_SPI_LISTENER (g_object_new (keystroke_spi_listener_get_type (), NULL));
+ SpiKeystrokeListener *retval =
+ SPI_KEYSTROKE_LISTENER (g_object_new (spi_keystroke_listener_get_type (), NULL));
return retval;
}