2002-01-11 Michael Meeks <michael@ximian.com>
authormichael <michael@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Fri, 11 Jan 2002 12:00:47 +0000 (12:00 +0000)
committermichael <michael@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Fri, 11 Jan 2002 12:00:47 +0000 (12:00 +0000)
* cspi/spi_accessible.c (role_names): add a role name
to sync this array with the enum; and make the regression
tests pass, sigh.

2002-01-10  Michael Meeks  <michael@ximian.com>

* cspi/spi_registry.c (SPI_generateKeyboardEvent):
allow expansion of enumeration & kill warning.

* test/test-simple.c (key_listener_cb): impl.
(test_keylisteners): impl.

* cspi/spi-listener.h: make listener signatures const
on the provided (const) events.

* test/keysynth-demo.c: upd. to const events.

* test/simple-at.c: ditto.

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

ChangeLog
cspi/spi-listener.h
cspi/spi_accessible.c
cspi/spi_registry.c
test/keysynth-demo.c
test/simple-at.c
test/test-simple.c

index 3c38a93..7bf3371 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,25 @@
-2002-01-11  Bill Haneman <bill.haneman@sun.com>
+2002-01-11  Michael Meeks  <michael@ximian.com>
+
+       * cspi/spi_accessible.c (role_names): add a role name
+       to sync this array with the enum; and make the regression
+       tests pass, sigh.
+
+2002-01-10  Michael Meeks  <michael@ximian.com>
+
+       * cspi/spi_registry.c (SPI_generateKeyboardEvent): 
+       allow expansion of enumeration & kill warning.
+
+       * test/test-simple.c (key_listener_cb): impl.
+       (test_keylisteners): impl.
+
+       * cspi/spi-listener.h: make listener signatures const
+       on the provided (const) events.
+
+       * test/keysynth-demo.c: upd. to const events.
+
+       * test/simple-at.c: ditto.
+
+2002-10-01  Bill Haneman <bill.haneman@sun.com>
 
        * test/demo.csh:
        Checked in a demo script, which requires editing before use!
index 61fa35c..1da413a 100644 (file)
@@ -42,10 +42,10 @@ typedef struct {
  *
  * SPIBoolean (*AccessibleKeystrokeListenerCB) (AccessibleKeystrokeEvent *Event);
  */
-typedef void       (*AccessibleEventListenerCB)     (AccessibleEvent     *event,
-                                                    void                *user_data);
-typedef SPIBoolean (*AccessibleKeystrokeListenerCB) (AccessibleKeystroke *stroke,
-                                                    void                *user_data);
+typedef void       (*AccessibleEventListenerCB)     (const AccessibleEvent     *event,
+                                                    void                      *user_data);
+typedef SPIBoolean (*AccessibleKeystrokeListenerCB) (const AccessibleKeystroke *stroke,
+                                                    void                      *user_data);
 
 #ifdef  __cplusplus
 }
index a89a36e..034637e 100644 (file)
@@ -11,6 +11,7 @@ static const char *role_names [] =
   "calendar",
   "canvas",
   "check box",
+  "check menu item",
   "color chooser",
   "column header",
   "combo box",
index 1b2049e..0f393f2 100644 (file)
@@ -506,6 +506,8 @@ SPI_generateKeyboardEvent (long int keyval,
       case SPI_KEY_STRING:
          keysynth_type = Accessibility_KEY_STRING;
          break;
+      default:
+          return FALSE;
     }
 
   Accessibility_DeviceEventController_generateKeyboardEvent (device_event_controller,
index 20d2a88..e3713eb 100644 (file)
@@ -319,7 +319,7 @@ button_exit (GtkButton *notused, void *alsonotused)
 }
 
 static SPIBoolean
-is_command_key (AccessibleKeystroke *key, void *user_data)
+is_command_key (const AccessibleKeystroke *key, void *user_data)
 {
   switch (key->keyID)
     {
@@ -332,7 +332,7 @@ is_command_key (AccessibleKeystroke *key, void *user_data)
 }
 
 static SPIBoolean
-switch_callback (AccessibleKeystroke *key, void *user_data)
+switch_callback (const AccessibleKeystroke *key, void *user_data)
 {
   static SPIBoolean is_down = FALSE;
 
index 2b1e846..996a900 100644 (file)
 #include "../util/mag_client.h"
 #include "../cspi/spi-private.h" /* A hack for now */
 
-static void report_focus_event    (AccessibleEvent *event, void *user_data);
-static void report_generic_event  (AccessibleEvent *event, void *user_data);
-static void report_button_press   (AccessibleEvent *event, void *user_data);
-static void check_property_change (AccessibleEvent *event, void *user_data);
-static SPIBoolean report_command_key_event  (AccessibleKeystroke *stroke, void *user_data);
-static SPIBoolean report_ordinary_key_event (AccessibleKeystroke *stroke, void *user_data);
+static void report_focus_event    (const AccessibleEvent *event, void *user_data);
+static void report_generic_event  (const AccessibleEvent *event, void *user_data);
+static void report_button_press   (const AccessibleEvent *event, void *user_data);
+static void check_property_change (const AccessibleEvent *event, void *user_data);
+static SPIBoolean report_command_key_event  (const AccessibleKeystroke *stroke, void *user_data);
+static SPIBoolean report_ordinary_key_event (const AccessibleKeystroke *stroke, void *user_data);
 static void get_environment_vars (void);
 
 static int _festival_init ();
@@ -238,7 +238,7 @@ report_focussed_accessible (Accessible *obj, SPIBoolean shutup_previous_speech)
 }
 
 void
-report_focus_event (AccessibleEvent *event, void *user_data)
+report_focus_event (const AccessibleEvent *event, void *user_data)
 {
   char *s;
 
@@ -255,13 +255,13 @@ report_focus_event (AccessibleEvent *event, void *user_data)
 }
 
 void
-report_generic_event (AccessibleEvent *event, void *user_data)
+report_generic_event (const AccessibleEvent *event, void *user_data)
 {
   fprintf (stderr, "%s event received\n", event->type);
 }
 
 void
-report_button_press (AccessibleEvent *event, void *user_data)
+report_button_press (const AccessibleEvent *event, void *user_data)
 {
   char *s;
 
@@ -277,7 +277,7 @@ report_button_press (AccessibleEvent *event, void *user_data)
 }
 
 void
-check_property_change (AccessibleEvent *event, void *user_data)
+check_property_change (const AccessibleEvent *event, void *user_data)
 {
   AccessibleSelection *selection = Accessible_getSelection (event->source);
   int n_selections;
@@ -330,7 +330,7 @@ simple_at_exit ()
 }
 
 static SPIBoolean
-is_command_key (AccessibleKeystroke *key)
+is_command_key (const AccessibleKeystroke *key)
 {
   switch (key->keyID)
     {
@@ -354,7 +354,7 @@ is_command_key (AccessibleKeystroke *key)
 }
 
 static SPIBoolean
-report_command_key_event (AccessibleKeystroke *key, void *user_data)
+report_command_key_event (const AccessibleKeystroke *key, void *user_data)
 {
   fprintf (stderr, "Command KeyEvent %s%c (keycode %d); string=%s; time=%lx\n",
          (key->modifiers & SPI_KEYMASK_ALT)?"Alt-":"",
@@ -368,7 +368,7 @@ report_command_key_event (AccessibleKeystroke *key, void *user_data)
 
 
 static SPIBoolean
-report_ordinary_key_event (AccessibleKeystroke *key, void *user_data)
+report_ordinary_key_event (const AccessibleKeystroke *key, void *user_data)
 {
   fprintf (stderr, "Received key event:\tsym %ld\n\tmods %x\n\tcode %d\n\tstring=\'%s\'\n\ttime %lx\n",
           (long) key->keyID,
index fa70a6b..eba026c 100644 (file)
@@ -611,8 +611,8 @@ test_misc (void)
 }
 
 static void
-global_listener_cb (AccessibleEvent     *event,
-                   void                *user_data)
+global_listener_cb (const AccessibleEvent *event,
+                   void                  *user_data)
 {
        TestWindow *win = user_data;
        Accessible *desktop;
@@ -643,6 +643,50 @@ global_listener_cb (AccessibleEvent     *event,
        validate_accessible (event->source, TRUE, TRUE);
 }
 
+static SPIBoolean
+key_listener_cb (const AccessibleKeystroke *stroke,
+                void                      *user_data)
+{
+       AccessibleKeystroke *s = user_data;
+
+       *s = *stroke;
+
+       g_warning ("Key listener callback");
+
+       return FALSE;
+}
+
+static void
+test_keylisteners (void)
+{
+       AccessibleKeystroke stroke;
+       AccessibleKeystrokeListener *key_listener;
+
+       key_listener = SPI_createAccessibleKeystrokeListener (
+               key_listener_cb, &stroke);
+
+       g_assert (SPI_registerAccessibleKeystrokeListener (
+               key_listener, SPI_KEYSET_ALL_KEYS, 0,
+               SPI_KEY_PRESSED | SPI_KEY_RELEASED,
+               SPI_KEYLISTENER_CANCONSUME));
+
+#if FIXME_HOW_SHOULD_THIS_WORK
+       memset (&stroke, 0, sizeof (AccessibleKeystroke));
+
+       g_assert (SPI_generateKeyboardEvent (33, "!", SPI_KEY_PRESSRELEASE));
+
+       while (stroke.type == 0)
+               g_main_iteration (TRUE);
+
+       g_assert (!strcmp (stroke.keystring, "!"));
+       g_assert (stroke.type == SPI_KEY_PRESSRELEASE);
+#endif
+
+       g_assert (SPI_deregisterAccessibleKeystrokeListener (key_listener, 0));
+
+       AccessibleKeystrokeListener_unref (key_listener);
+}
+
 int
 main (int argc, char **argv)
 {
@@ -670,6 +714,7 @@ main (int argc, char **argv)
        test_roles ();
        test_misc ();
        test_desktop ();
+       test_keylisteners ();
 
        win = create_test_window ();