[at-spi2-core] API changes to device and event listeners for compatibility with js



commit f7348a266a6afd8aa482b923444144ca54abb54c
Author: Mike Gorse <mgorse novell com>
Date:   Wed Jul 6 16:01:21 2011 -0500

    API changes to device and event listeners for compatibility with js
    
    Skip atspi_device_listener_new_simple and
    atspi-event_listener_new_simple, since Javascript throws an error for
    callback functions that don't provide user_data.
    Add atspi_event_listener_new.
    Change order of user_data and destroy notify parameters in
    atspi_device_listener_new to match the order used other places in GNOME.
    The old order was triggering an IndexError because of what appears to be
    a bug in pygobject.  Note that this is an API change and would
    ordinarily be a bad idea, but at this point I don't know of anyone using
    libatspi directly, so going to commit it.
    Some introspection fixes.

 atspi/atspi-device-listener.c |   18 +++++++++---------
 atspi/atspi-device-listener.h |    2 +-
 atspi/atspi-event-listener.c  |   27 +++++++++++++++++++++++++--
 atspi/atspi-event-listener.h  |    5 +++++
 4 files changed, 40 insertions(+), 12 deletions(-)
---
diff --git a/atspi/atspi-device-listener.c b/atspi/atspi-device-listener.c
index 48ecc45..6f7d9cf 100644
--- a/atspi/atspi-device-listener.c
+++ b/atspi/atspi-device-listener.c
@@ -206,22 +206,22 @@ G_DEFINE_TYPE (AtspiDeviceListener, atspi_device_listener,
 
 /**
  * atspi_device_listener_new:
- * @callback: (scope notify): an #AtspiDeviceListenerCB callback function,
+ * @callback: (scope notified): an #AtspiDeviceListenerCB callback function,
  *            or NULL.
- * @callback_destroyed: A #GDestroyNotify called when the listener is freed
- * and data associated with the callback should be freed.  Can be NULL.
  * @user_data: (closure): a pointer to data which will be passed to the
  * callback when invoked.
+ * @callback_destroyed: A #GDestroyNotify called when the listener is freed
+ * and data associated with the callback should be freed.  Can be NULL.
  *
  * Create a new #AtspiDeviceListener with a specified callback function.
  *
- * Returns: a pointer to a newly-created #AtspiDeviceListener.
+ * Returns: (transfer full): a pointer to a newly-created #AtspiDeviceListener.
  *
  **/
 AtspiDeviceListener *
 atspi_device_listener_new (AtspiDeviceListenerCB callback,
-                           GDestroyNotify callback_destroyed,
-                           void *user_data)
+                           void *user_data,
+                           GDestroyNotify callback_destroyed)
 {
   AtspiDeviceListener *listener = g_object_new (atspi_device_listener_get_type (), NULL);
 
@@ -232,8 +232,8 @@ atspi_device_listener_new (AtspiDeviceListenerCB callback,
 }
 
 /**
- * atspi_device_listener_new_simple:
- * @callback: (scope notify): an #AtspiDeviceListenerCB callback function,
+ * atspi_device_listener_new_simple: (skip):
+ * @callback: (scope notified): an #AtspiDeviceListenerCB callback function,
  *            or NULL.
  * @callback_destroyed: A #GDestroyNotify called when the listener is freed
  * and data associated with the callback should be freed.  Can be NULL.
@@ -254,7 +254,7 @@ atspi_device_listener_new_simple (AtspiDeviceListenerSimpleCB callback,
 /**
  * atspi_device_listener_add_callback:
  * @listener: the #AtspiDeviceListener instance to modify.
- * @callback: (scope notify): an #AtspiDeviceListenerCB function pointer.
+ * @callback: (scope notified): an #AtspiDeviceListenerCB function pointer.
  * @user_data: (closure): a pointer to data which will be passed to the
  *             callback when invoked.
  * @callback_destroyed: A #GDestroyNotify called when the listener is freed
diff --git a/atspi/atspi-device-listener.h b/atspi/atspi-device-listener.h
index 2cf06bc..169738c 100644
--- a/atspi/atspi-device-listener.h
+++ b/atspi/atspi-device-listener.h
@@ -80,7 +80,7 @@ struct _AtspiDeviceListenerClass
 
 GType atspi_device_listener_get_type (void);
 
-AtspiDeviceListener *atspi_device_listener_new (AtspiDeviceListenerCB callback, GDestroyNotify callback_destroyed, void *user_data);
+AtspiDeviceListener *atspi_device_listener_new (AtspiDeviceListenerCB callback, void *user_data, GDestroyNotify callback_destroyed);
 
 AtspiDeviceListener *atspi_device_listener_new_simple (AtspiDeviceListenerSimpleCB callback, GDestroyNotify callback_destroyed);
 
diff --git a/atspi/atspi-event-listener.c b/atspi/atspi-event-listener.c
index e93ec6b..61e1010 100644
--- a/atspi/atspi-event-listener.c
+++ b/atspi/atspi-event-listener.c
@@ -115,7 +115,30 @@ callback_unref (gpointer callback)
 }
 
 /**
- * atspi_event_listener_new_simple:
+ * atspi_event_listener_new:
+ * @callback: (scope notified): An #AtspiEventListenerSimpleCB to be called
+ * when an event is fired.
+ * @user_data: (closure): data to pass to the callback.
+ * @callback_destroyed: A #GDestroyNotify called when the listener is freed
+ * and data associated with the callback should be freed.  Can be NULL.
+ *
+ * Returns: (transfer full): A new #AtspiEventListener.
+ */
+AtspiEventListener *
+atspi_event_listener_new (AtspiEventListenerCB callback,
+                                 gpointer user_data,
+                                 GDestroyNotify callback_destroyed)
+{
+  AtspiEventListener *listener = g_object_new (ATSPI_TYPE_EVENT_LISTENER, NULL);
+  listener->callback = callback;
+  callback_ref (callback, callback_destroyed);
+  listener->user_data = user_data;
+  listener->cb_destroyed = callback_destroyed;
+  return listener;
+}
+
+/**
+ * atspi_event_listener_new_simple: (skip)
  * @callback: (scope notified): An #AtspiEventListenerSimpleCB to be called
  * when an event is fired.
  * @callback_destroyed: A #GDestroyNotify called when the listener is freed
@@ -545,7 +568,7 @@ atspi_event_listener_register_from_callback (AtspiEventListenerCB callback,
 }
 
 /**
- * atspi_event_listener_register_no_data:
+ * atspi_event_listener_register_no_data: (skip)
  * @callback: (scope notified): the #AtspiEventListenerSimpleCB to be
  *            registered against an event type.
  * @callback_destroyed: A #GDestroyNotify called when the callback is destroyed.
diff --git a/atspi/atspi-event-listener.h b/atspi/atspi-event-listener.h
index 2826a9f..ec46bcd 100644
--- a/atspi/atspi-event-listener.h
+++ b/atspi/atspi-event-listener.h
@@ -77,6 +77,11 @@ struct _AtspiEventListenerClass
 GType atspi_event_listener_get_type (void);
 
 AtspiEventListener *
+atspi_event_listener_new (AtspiEventListenerCB callback,
+                                 gpointer user_data,
+                                 GDestroyNotify callback_destroyed);
+
+AtspiEventListener *
 atspi_event_listener_new_simple (AtspiEventListenerSimpleCB callback,
                                  GDestroyNotify callback_destroyed);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]