[at-spi2-core/gi] Box some types, add missing header file, and other fixes



commit f5ad78008ea864a19ca48e610c3b38c2de9fc06e
Author: Mike Gorse <mgorse novell com>
Date:   Sun Nov 7 08:43:41 2010 -0500

    Box some types, add missing header file, and other fixes

 atspi/atspi-accessible.c     |   11 +++--
 atspi/atspi-application.c    |    4 +-
 atspi/atspi-application.h    |    2 +-
 atspi/atspi-component.c      |   26 ++++++++-
 atspi/atspi-component.h      |  102 ++++++++++++++++++++++++++++++++++++
 atspi/atspi-constants.h      |   60 +++++++++++-----------
 atspi/atspi-event-listener.c |  119 +++++++++++++++++++++++++++++++++++-------
 atspi/atspi-event-listener.h |   19 +++++++
 atspi/atspi-event-types.h    |   24 +++-----
 atspi/atspi-misc-private.h   |    4 +-
 atspi/atspi-misc.c           |   19 ++++---
 11 files changed, 308 insertions(+), 82 deletions(-)
---
diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c
index a5c9f32..ccb4ec8 100644
--- a/atspi/atspi-accessible.c
+++ b/atspi/atspi-accessible.c
@@ -31,8 +31,10 @@ atspi_accessible_init (AtspiAccessible *accessible)
 }
 
 static void
-atspi_accessible_finalize (AtspiAccessible *accessible)
+atspi_accessible_finalize (GObject *obj)
 {
+  AtspiAccessible *accessible = ATSPI_ACCESSIBLE (obj);
+
   if (accessible->app)
     g_object_unref (accessible->app);
 
@@ -460,7 +462,7 @@ GArray *
 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
 {
   DBusMessage *message;
-  GHashTable *ret;
+  GArray *ret;
 
     g_return_val_if_fail (obj != NULL, NULL);
 
@@ -768,7 +770,7 @@ AtspiComponent *
 atspi_accessible_get_component (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_component) ?
-          accessible : NULL);  
+          ATSPI_COMPONENT (accessible) : NULL);  
 }
 
 #if 0
@@ -1251,10 +1253,11 @@ cspi_object_destroyed (AtspiAccessible *accessible)
   AtspiEvent e;
 
   /* TODO: Only fire if object not already marked defunct */
-  memset (&e, 0, sizeof(e));
   e.type = "object:state-change:defunct";
   e.source = accessible;
   e.detail1 = 1;
+  e.detail2 = 0;
+  g_value_unset (&e.any);
   _atspi_send_event (&e);
 
     g_free (accessible->path);
diff --git a/atspi/atspi-application.c b/atspi/atspi-application.c
index c037c4b..6dbadce 100644
--- a/atspi/atspi-application.c
+++ b/atspi/atspi-application.c
@@ -31,8 +31,10 @@ atspi_application_init (AtspiApplication *application)
 }
 
 static void
-atspi_application_finalize (AtspiApplication *application)
+atspi_application_finalize (GObject *obj)
 {
+  AtspiApplication *application = ATSPI_APPLICATION (obj);
+
   if (application->bus_name)
     g_free (application->bus_name);
 }
diff --git a/atspi/atspi-application.h b/atspi/atspi-application.h
index be3d4e1..ecc4657 100644
--- a/atspi/atspi-application.h
+++ b/atspi/atspi-application.h
@@ -30,7 +30,7 @@
 #include "atspi-accessible.h"
 
 #define ATSPI_TYPE_APPLICATION                        (atspi_application_get_type ())
-#define ATSPI_APPLICATION(obj)                        (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATSPI_TYPE_APPLICATION, AtspiAccessible))
+#define ATSPI_APPLICATION(obj)                        (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATSPI_TYPE_APPLICATION, AtspiApplication))
 #define ATSPI_APPLICATION_CLASS(klass)                (G_TYPE_CHECK_CLASS_CAST ((klass), ATSPI_TYPE_APPLICATION, AtspiAccessibleClass))
 #define ATSPI_IS_APPLICATION(obj)                     (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATSPI_TYPE_APPLICATION))
 #define ATSPI_IS_APPLICATION_CLASS(klass)             (G_TYPE_CHECK_CLASS_TYPE ((klass), ATSPI_TYPE_APPLICATION))
diff --git a/atspi/atspi-component.c b/atspi/atspi-component.c
index 574bb4a..3759655 100644
--- a/atspi/atspi-component.c
+++ b/atspi/atspi-component.c
@@ -29,6 +29,28 @@
 
 #include "atspi-private.h"
 
+static AtspiRect *
+atspi_rect_copy (AtspiRect *src)
+{
+  AtspiRect *dst = g_new (AtspiRect, 1);
+  dst->x = src->x;
+  dst->y = src->y;
+  dst->height = src->height;
+  dst->width = src->width;
+}
+
+G_DEFINE_BOXED_TYPE (AtspiRect, atspi_rect, atspi_rect_copy, g_free)
+
+static AtspiPoint *
+atspi_point_copy (AtspiPoint *src)
+{
+  AtspiPoint *dst = g_new (AtspiPoint, 1);
+  dst->x = src->x;
+  dst->y = src->y;
+}
+
+G_DEFINE_BOXED_TYPE (AtspiPoint, atspi_point, atspi_point_copy, g_free)
+
 /**
  * atspi_component_contains:
  * @obj: a pointer to the #AtspiComponent to query.
@@ -254,7 +276,7 @@ atspi_component_get_alpha    (AtspiComponent *obj, GError **error)
 }
 
 static void
-atspi_component_base_init (AtspiComponentIface *klass)
+atspi_component_base_init (AtspiComponent *klass)
 {
   static gboolean initialized = FALSE;
 
@@ -282,7 +304,7 @@ atspi_component_get_type (void)
   if (!type) {
     static const GTypeInfo tinfo =
     {
-      sizeof (AtspiComponentIface),
+      sizeof (AtspiComponent),
       (GBaseInitFunc) atspi_component_base_init,
       (GBaseFinalizeFunc) NULL,
 
diff --git a/atspi/atspi-component.h b/atspi/atspi-component.h
new file mode 100644
index 0000000..86fa5c3
--- /dev/null
+++ b/atspi/atspi-component.h
@@ -0,0 +1,102 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2002 Ximian, Inc.
+ *           2002 Sun Microsystems Inc.
+ *           
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _ATSPI_COMPONENT_H_
+#define _ATSPI_COMPONENT_H_
+
+#include "glib-object.h"
+
+#include "atspi-accessible.h"
+#include "atspi-constants.h"
+
+typedef struct _AtspiRect AtspiRect;
+struct _AtspiRect
+{
+  gint x;
+  gint y;
+  gint width;
+  gint height;
+};
+
+/**
+ * ATSPI_TYPE_RECT:
+ * 
+ * The #GType for a boxed type holding a #AtspiRect.
+ */
+#define	ATSPI_TYPE_RECT (atspi_rect_get_type ())
+
+typedef struct _AtspiPoint AtspiPoint;
+struct _AtspiPoint
+{
+  gint x;
+  gint y;
+};
+
+/**
+ * ATSPI_TYPE_POINT:
+ * 
+ * The #GType for a boxed type holding a #AtspiPoint.
+ */
+#define	ATSPI_TYPE_POINT (atspi_point_get_type ())
+
+#define ATSPI_TYPE_COMPONENT                    (atspi_component_get_type ())
+#define ATSPI_IS_COMPONENT(obj)                 G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATSPI_TYPE_COMPONENT)
+#define ATSPI_COMPONENT(obj)                    G_TYPE_CHECK_INSTANCE_CAST ((obj), ATSPI_TYPE_COMPONENT, AtspiComponent)
+#define ATSPI_COMPONENT_GET_IFACE(obj)          (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATSPI_TYPE_COMPONENT, AtspiComponent))
+
+GType atspi_component_get_type ();
+
+struct _AtspiComponent
+{
+  GTypeInterface parent;
+  gboolean (*contains) (AtspiComponent *component, gint x, gint y, AtspiCoordType ctype, GError **error);
+  AtspiAccessible *(*ref_accessible_at_point) (AtspiComponent *component, gint x, gint y, AtspiCoordType ctype, GError **error);
+  AtspiRect (*get_extents) (AtspiComponent *component, gint *x, gint *y, gint *width, gint *height, AtspiCoordType ctype, GError **error);
+  AtspiPoint (*get_position) (AtspiComponent *component, AtspiCoordType ctype, GError **error);
+  AtspiPoint (*get_size) (AtspiComponent *component, GError **error);
+  AtspiComponentLayer (*get_layer) (AtspiComponent *component, GError **error);
+
+  gshort (*get_mdi_z_order) (AtspiComponent *component, GError **error);
+  gboolean (*grab_focus) (AtspiComponent *component, GError **error);
+  gdouble (*get_alpha)    (AtspiComponent *component, GError **error);
+};
+
+gboolean atspi_component_contains (AtspiComponent *obj, gint x, gint y, AtspiCoordType ctype, GError **error);
+
+AtspiAccessible *atspi_component_ref_accessible_at_point (AtspiComponent *obj, gint x, gint y, AtspiCoordType ctype, GError **error);
+
+AtspiRect atspi_component_get_extents (AtspiComponent *obj, gint *x, gint *y, gint *width, gint *height, AtspiCoordType ctype, GError **error);
+
+AtspiPoint atspi_component_get_position (AtspiComponent *obj, AtspiCoordType ctype, GError **error);
+
+AtspiPoint atspi_component_get_size (AtspiComponent *obj, GError **error);
+
+AtspiComponentLayer atspi_component_get_layer (AtspiComponent *obj, GError **error);
+
+gshort atspi_component_get_mdi_z_order (AtspiComponent *obj, GError **error);
+
+gboolean atspi_component_grab_focus (AtspiComponent *obj, GError **error);
+
+gdouble      atspi_component_get_alpha    (AtspiComponent *obj, GError **error);
+#endif	/* _ATSPI_COMPONENT_H_ */
diff --git a/atspi/atspi-constants.h b/atspi/atspi-constants.h
index a011645..80d7976 100644
--- a/atspi/atspi-constants.h
+++ b/atspi/atspi-constants.h
@@ -89,11 +89,11 @@ typedef enum {
 } AtspiLocaleType;
 
 /**
- * NUM_ATSPI_LOCALE_TYPES:
+ * ATSPI_LOCALE_TYPE_COUNT:
  *
  * 1 higher than the highest valid value of #AtspiLocaleType.
  */
-#define NUM_ATSPI_LOCALE_TYPES (5+1)
+#define ATSPI_LOCALE_TYPE _COUNT(5+1)
 
 /**
  *
@@ -111,11 +111,11 @@ typedef enum {
 } AtspiCoordType;
 
 /**
- * NUM_ATSPI_COORD_TYPES:
+ * ATSPI_COORD_TYPE_COUNT:
  *
  * 1 higher than the highest valid value of #AtspiCoordType.
  */
-#define NUM_ATSPI_COORD_TYPES (1+1)
+#define ATSPI_COORD_TYPE_COUNT (1+1)
 
 /**
  *
@@ -143,11 +143,11 @@ typedef enum {
 } AtspiCollectionSortOrder;
 
 /**
- * NUM_ATSPI_SORTORDERS:
+ * ATSPI_SORTORDER_COUNT:
  *
  * 1 higher than the highest valid value of #AtspiCollectionSortOrder.
  */
-#define NUM_ATSPI_SORTORDERS (7+1)
+#define ATSPI_SORTORDER_COUNT (7+1)
 
 /**
  *
@@ -171,11 +171,11 @@ typedef enum {
 } AtspiCollectionMatchType;
 
 /**
- * NUM_ATSPI_MATCHTYPES:
+ * ATSPI_MATCHTYPE_COUNT:
  *
  * 1 higher than the highest valid value of #AtspiCollection_MatchType.
  */
-#define NUM_ATSPI_MATCHTYPES (5+1)
+#define ATSPI_MATCHTYPES_COUNT (5+1)
 
 /**
  *
@@ -195,11 +195,11 @@ typedef enum {
 } AtspiCollectionTreeTraversalType;
 
 /**
- * NUM_ATSPI_TREETRAVERSALTYPES:
+ * ATSPI_TREETRAVERSALTYPE_COUNT:
  *
  * 1 higher than the highest valid value of #AtspiCollection_TreeTraversalType.
  */
-#define NUM_ATSPI_TREETRAVERSALTYPES (3+1)
+#define ATSPI_TREETRAVERSALTYPE _COUNT(3+1)
 
 /**
  *
@@ -231,11 +231,11 @@ typedef enum {
 } AtspiComponentLayer;
 
 /**
- * NUM_ATSPI_COMPONENTLAYERS:
+ * ATSPI_COMPONENTLAYER:_COUNT
  *
  * 1 higher than the highest valid value of #AtspiComponentLayer.
  */
-#define NUM_ATSPI_COMPONENTLAYERS (8+1)
+#define ATSPI_COMPONENTLAYER_COUNT (8+1)
 
 /**
  *
@@ -263,11 +263,11 @@ typedef enum {
 } AtspiTextBoundaryType;
 
 /**
- * NUM_ATSPI_TEXT_BOUNDARY_TYPES:
+ * ATSPI_TEXT_BOUNDARY_TYPE_COUNT:
  *
  * 1 higher than the highest valid value of #AtspiTextBOundaryType.
  */
-#define NUM_ATSPI_TEXT_BOUNDARY_TYPES (6+1)
+#define ATSPI_TEXT_BOUNDARY_TYPE_COUNT (6+1)
 
 /**
  *
@@ -289,11 +289,11 @@ typedef enum {
 } AtspiTextClipType;
 
 /**
- * NUM_ATSPI_TEXT_CLIP_TYPES:
+ * ATSPI_TEXT_CLIP_TYPE_COUNT:
  *
  * 1 higher than the highest valid value of #AtspiTextClipType.
  */
-#define NUM_ATSPI_TEXT_CLIP_TYPES (3+1)
+#define ATSPI_TEXT_CLIP_TYPE_COUNT (3+1)
 
 /**
  *
@@ -389,11 +389,11 @@ typedef enum {
 } AtspiStateType;
 
 /**
- * NUM_ATSPI_STATETYPES:
+ * ATSPI_STATETYPE_COUNT:
  *
  * 1 higher than the highest valid value of #AtspiStateType.
  */
-#define NUM_ATSPI_STATETYPES (41+1)
+#define ATSPI_STATETYPE_COUNT (41+1)
 
 /**
  *
@@ -411,11 +411,11 @@ typedef enum {
 } AtspiKeyEventType;
 
 /**
- * NUM_ATSPI_KEYEVENTTYPES:
+ * ATSPI_KEYEVENTTYPE_COUNT:
  *
  * 1 higher than the highest valid value of #AtspiKeyEventType.
  */
-#define NUM_ATSPI_KEYEVENTTYPES (1+1)
+#define ATSPI_KEYEVENTTYPE_COUNT (1+1)
 
 /**
  *
@@ -437,11 +437,11 @@ typedef enum {
 } AtspiEventType;
 
 /**
- * NUM_ATSPI_EVENTTYPES:
+ * ATSPI_EVENTTYPE_COUNT:
  *
  * 1 higher than the highest valid value of #AtspiEventType.
  */
-#define NUM_ATSPI_EVENTTYPES (3+1)
+#define ATSPI_EVENTTYPE_COUNT (3+1)
 
 /**
  *
@@ -465,11 +465,11 @@ typedef enum {
 } AtspiKeySynthType;
 
 /**
- * NUM_ATSPI_KEYSYNTHTYPES:
+ * ATSPI_KEYSYNTHTYPE_COUNT:
  *
  * 1 higher than the highest valid value of #AtspiKeySynthType.
  */
-#define NUM_ATSPI_KEYSYNTHTYPES (4+1)
+#define ATSPI_KEYSYNTHTYPE_COUNT (4+1)
 
 /**
  *
@@ -497,11 +497,11 @@ typedef enum {
 } AtspimodifierType;
 
 /**
- * NUM_ATSPI_MODIFIERTYPES:
+ * ATSPI_MODIFIERTYPE_COUNT:
  *
  * 1 higher than the highest valid value of #AtspiModifierType.
  */
-#define NUM_ATSPI_MODIFIERTYPES (7+1)
+#define ATSPI_MODIFIERTYPE_COUNT (7+1)
 
 /**
  *
@@ -555,11 +555,11 @@ typedef enum {
 } AtspiRelationType;
 
 /**
- * NUM_ATSPI_RELATIONTYPES:
+ * ATSPI_RELATIONTYPE_COUNT:
  *
  * 1 higher than the highest valid value of #AtspiRelationType.
  */
-#define NUM_ATSPI_RELATIONTYPES (19+1)
+#define ATSPI_RELATIONTYPE_COUNT (19+1)
 
 /**
  *
@@ -753,11 +753,11 @@ typedef enum {
 } AtspiRole;
 
 /**
- * NUM_ATSPI_ROLES:
+ * ATSPI_ROLE_COUNT:
  *
  * 1 higher than the highest valid value of #AtspiRole.
  */
-#define NUM_ATSPI_ROLES (90+1)
+#define ATSPI_ROLE_COUNT (90+1)
 
 
 #ifdef __cplusplus
diff --git a/atspi/atspi-event-listener.c b/atspi/atspi-event-listener.c
index 5c834a7..8bcdd4f 100644
--- a/atspi/atspi-event-listener.c
+++ b/atspi/atspi-event-listener.c
@@ -28,6 +28,7 @@ typedef struct
 {
   AtspiEventListenerCB callback;
   void *user_data;
+  GDestroyNotify callback_destroyed;
   char *category;
   char *name;
   char *detail;
@@ -72,20 +73,24 @@ convert_name_from_dbus (const char *name)
 static void
 cache_process_children_changed (AtspiEvent *event)
 {
-  if (event->v_type != EVENT_DATA_OBJECT ||
+  AtspiAccessible *child;
+
+  if (!G_VALUE_HOLDS (&event->any, ATSPI_TYPE_ACCESSIBLE) ||
       !event->source->children ||
       atspi_state_set_contains (event->source->states, ATSPI_STATE_MANAGES_DESCENDANTS))
     return;
 
+  child = g_value_get_object (&event->any);
+
   if (!strncmp (event->type, "object:children-changed:add", 27))
   {
-    GList *new_list = g_list_insert (event->source->children, g_object_ref (event->v.accessible), event->detail1);
+    GList *new_list = g_list_insert (event->source->children, g_object_ref (child), event->detail1);
     if (new_list)
       event->source->children = new_list;
   }
-  else if (g_list_find (event->source->children, event->v.accessible))
+  else if (g_list_find (event->source->children, child))
   {
-    event->source->children = g_list_remove (event->source->children, event->v.accessible);
+    event->source->children = g_list_remove (event->source->children, child);
   }
 }
 
@@ -96,9 +101,9 @@ cache_process_property_change (AtspiEvent *event)
   {
     if (event->source->accessible_parent)
       g_object_unref (event->source->accessible_parent);
-    if (event->v_type == EVENT_DATA_OBJECT)
+    if (G_VALUE_HOLDS (&event->any, ATSPI_TYPE_ACCESSIBLE))
     {
-      event->source->accessible_parent = g_object_ref (event->v.accessible);
+      event->source->accessible_parent = g_value_dup_object (&event->any);
       event->source->cached_properties |= ATSPI_CACHE_PARENT;
     }
     else
@@ -111,9 +116,9 @@ cache_process_property_change (AtspiEvent *event)
   {
     if (event->source->name)
       g_free (event->source->name);
-    if (event->v_type == EVENT_DATA_STRING)
+    if (G_VALUE_HOLDS_STRING (&event->any))
     {
-      event->source->name = g_strdup (event->v.text);
+      event->source->name = g_value_dup_string (&event->any);
       event->source->cached_properties |= ATSPI_CACHE_NAME;
     }
     else
@@ -126,9 +131,9 @@ cache_process_property_change (AtspiEvent *event)
   {
     if (event->source->description)
       g_free (event->source->description);
-    if (event->v_type == EVENT_DATA_STRING)
+    if (G_VALUE_HOLDS_STRING (&event->any))
     {
-      event->source->description = g_strdup (event->v.text);
+      event->source->description = g_value_dup_string (&event->any);
       event->source->cached_properties |= ATSPI_CACHE_DESCRIPTION;
     }
     else
@@ -261,14 +266,17 @@ listener_entry_free (EventListenerEntry *e)
   g_free (e->category);
   g_free (e->name);
   if (e->detail) g_free (e->detail);
+  if (e->callback_destroyed)
+    (*e->callback_destroyed) (e->callback);
   g_free (e);
 }
 
 /**
  * atspi_event_listener_register:
- * @callback: (scope call): the #AtspiEventListenerCB to be registered against
+ * @callback: (scope notified): the #AtspiEventListenerCB to be registered against
  *            an event type.
  * @user_data: (closure): User data to be passed to the callback.
+ * @callback_freed: A #GDestroyNotify called when the callback is destroyed.
  * @event_type: a character string indicating the type of events for which
  *            notification is requested.  Format is
  *            EventClass:major_type:minor_type:detail
@@ -357,6 +365,7 @@ listener_entry_free (EventListenerEntry *e)
 gboolean
 atspi_event_listener_register (AtspiEventListenerCB callback,
 				 void *user_data,
+				 GDestroyNotify callback_destroyed,
 				 const gchar              *event_type)
 {
   EventListenerEntry *e;
@@ -374,6 +383,7 @@ atspi_event_listener_register (AtspiEventListenerCB callback,
   if (!e) return FALSE;
   e->callback = callback;
   e->user_data = user_data;
+  e->callback_destroyed = callback_destroyed;
   if (!convert_event_type_to_dbus (event_type, &e->category, &e->name, &e->detail, &matchrule))
   {
     g_free (e);
@@ -407,6 +417,36 @@ atspi_event_listener_register (AtspiEventListenerCB callback,
   return TRUE;
 }
 
+void
+remove_datum (const AtspiEvent *event, void *user_data)
+{
+  AtspiEventListenerSimpleCB cb = user_data;
+  cb (event);
+}
+
+/**
+ * atspi_event_listener_register_no_data:
+ * @callback: (scope notified): the #AtspiEventListenerSimpleCB to be
+ *            registered against an event type.
+ * @callback_freed: A #GDestroyNotify called when the callback is destroyed.
+ * @event_type: a character string indicating the type of events for which
+ *            notification is requested.  Format is
+ *            EventClass:major_type:minor_type:detail
+ *            where all subfields other than EventClass are optional.
+ *            EventClasses include "object", "window", "mouse",
+ *            and toolkit events (e.g. "Gtk", "AWT").
+ *            Examples: "focus:", "Gtk:GtkWidget:button_press_event".
+ *
+ * Like atspi_event_listener_register, but callback takes no user_data.
+ **/
+gboolean
+atspi_event_listener_register_no_data (AtspiEventListenerSimpleCB callback,
+				 GDestroyNotify callback_destroyed,
+				 const gchar              *event_type)
+{
+  return atspi_event_listener_register (remove_datum, callback, callback_destroyed, event_type);
+}
+
 static gboolean
 is_superset (const gchar *super, const gchar *sub)
 {
@@ -481,6 +521,25 @@ atspi_event_listener_deregister (AtspiEventListenerCB callback,
   return TRUE;
 }
 
+/**
+ * atspi_event_listener_deregister_no_data:
+ * @callback: (scope call): the #AtspiEventListenerSimpleCB registered against
+ *            an event type.
+ * @event_type: a string specifying the event type for which this
+ *             listener is to be deregistered.
+ *
+ * deregisters an #AtspiEventListenerSimpleCB from the registry, for a specific
+ *             event type.
+ *
+ * Returns: #TRUE if successful, otherwise #FALSE.
+ **/
+gboolean
+atspi_event_listener_deregister_no_data (AtspiEventListenerSimpleCB callback,
+				   const gchar              *event_type)
+{
+  return atspi_event_listener_deregister (remove_datum, callback, event_type);
+}
+
 void
 _atspi_send_event (AtspiEvent *e)
 {
@@ -573,22 +632,25 @@ atspi_dbus_handle_event (DBusConnection *bus, DBusMessage *message, void *data)
   {
     case DBUS_TYPE_STRUCT:
     {
-      if (demarshal_rect (&iter_variant, &e.v.rect))
+      AtspiRect rect;
+      if (demarshal_rect (&iter_variant, &rect))
       {
-	e.v_type = EVENT_DATA_RECT;
+	g_value_init (&e.any, ATSPI_TYPE_RECT);
+	g_value_set_instance (&e.any, &rect);
       }
       else
       {
-        e.v_type = EVENT_DATA_OBJECT;
-        e.v.accessible = _atspi_dbus_return_accessible_from_iter (&iter_variant);
+        AtspiAccessible *accessible;
+	accessible = _atspi_dbus_return_accessible_from_iter (&iter_variant);
+	g_value_init (&e.any, ATSPI_TYPE_ACCESSIBLE);
+	g_value_set_instance (&e.any, accessible);
       }
       break;
     }
     case DBUS_TYPE_STRING:
     {
       dbus_message_iter_get_basic (&iter_variant, &p);
-      e.v_type = EVENT_DATA_STRING;
-      e.v.text = g_strdup (p);
+      g_value_set_string (&e.any, p);
       break;
     }
   default:
@@ -613,8 +675,27 @@ atspi_dbus_handle_event (DBusConnection *bus, DBusMessage *message, void *data)
   g_free (name);
   g_free (detail);
   g_object_unref (e.source);
-  if (e.v_type == EVENT_DATA_OBJECT)
-    g_object_unref (e.v.accessible);
+  g_value_unset (&e.any);
   return DBUS_HANDLER_RESULT_HANDLED;
 }
 
+static AtspiEvent *
+atspi_event_copy (AtspiEvent *src)
+{
+  AtspiEvent *dst = g_new0 (AtspiEvent, 1);
+  dst->type = g_strdup (src->type);
+  dst->detail1 = src->detail1;
+  dst->detail2 = src->detail2;
+  g_value_copy (&dst->any, &src->any);
+}
+
+static void
+atspi_event_free (AtspiEvent *event)
+{
+  g_object_unref (event->source);
+  g_free (event->type);
+  g_value_unset (&event->any);
+  g_free (event);
+}
+
+G_DEFINE_BOXED_TYPE (AtspiEvent, atspi_event, atspi_event_copy, atspi_event_free)
diff --git a/atspi/atspi-event-listener.h b/atspi/atspi-event-listener.h
index 228dbcc..edc32da 100644
--- a/atspi/atspi-event-listener.h
+++ b/atspi/atspi-event-listener.h
@@ -40,13 +40,32 @@
 typedef void       (*AtspiEventListenerCB)     (const AtspiEvent     *event,
 						     void                      *user_data);
 
+/**
+ * AtspiEventListenerSimpleCB:
+ * @event: The event for which notification is sent.
+ *
+ * Like #AtspiEventlistenerCB, but with no user_data.
+ * 
+ **/
+typedef void       (*AtspiEventListenerSimpleCB)     (const AtspiEvent     *event);
+
 gboolean
 atspi_event_listener_register (AtspiEventListenerCB callback,
 				 void *user_data,
+				 GDestroyNotify callback_destroyed,
+				 const gchar              *event_type);
+
+gboolean
+atspi_event_listener_register_no_data (AtspiEventListenerSimpleCB callback,
+				 GDestroyNotify callback_destroyed,
 				 const gchar              *event_type);
 
 gboolean
 atspi_event_listener_deregister (AtspiEventListenerCB callback,
 				   void *user_data,
 				   const gchar              *event_type);
+
+gboolean
+atspi_event_listener_deregister_no_data (AtspiEventListenerSimpleCB callback,
+				   const gchar              *event_type);
 #endif	/* _ATSPI_EVENT_LISTENER_H_ */
diff --git a/atspi/atspi-event-types.h b/atspi/atspi-event-types.h
index 8f88931..3d52505 100644
--- a/atspi/atspi-event-types.h
+++ b/atspi/atspi-event-types.h
@@ -66,29 +66,23 @@ struct _AtspiKeyDefinition
   gint unused;
 };
 
-typedef enum
-{
-  EVENT_DATA_STRING,
-  EVENT_DATA_OBJECT,
-  EVENT_DATA_RECT
-} EVENT_DATA_TYPE;
-
 typedef struct _AtspiEvent AtspiEvent;
 struct _AtspiEvent
 {
-  const gchar  *type;
+  gchar  *type;
   AtspiAccessible  *source;
   gint         detail1;
   gint         detail2;
-  union
-  {
-    gchar *text;
-    AtspiAccessible *accessible;
-    AtspiRect rect;
-  } v;
-  EVENT_DATA_TYPE v_type;
+  GValue any;
 };
 
+/**
+ * ATSPI_TYPE_RECT:
+ * 
+ * The #GType for a boxed type holding a #AtspiEvent.
+ */
+#define	ATSPI_TYPE_EVENT (atspi_event_get_type ())
+
 typedef void AtspiKeystrokeListener;
 
 /**
diff --git a/atspi/atspi-misc-private.h b/atspi/atspi-misc-private.h
index c65ee5d..5440d47 100644
--- a/atspi/atspi-misc-private.h
+++ b/atspi/atspi-misc-private.h
@@ -117,9 +117,9 @@ _atspi_dbus_return_accessible_from_iter (DBusMessageIter *iter);
 
 AtspiAccessible * _atspi_ref_related_accessible (AtspiAccessible *obj, const AtspiReference *ref);
 
-dbus_bool_t _atspi_dbus_call (AtspiAccessible *obj, const char *interface, const char *method, GError **error, const char *type, ...);
+dbus_bool_t _atspi_dbus_call (gpointer obj, const char *interface, const char *method, GError **error, const char *type, ...);
 
-DBusMessage *_atspi_dbus_call_partial (AtspiAccessible *obj, const char *interface, const char *method, GError **error, const char *type, ...);
+DBusMessage *_atspi_dbus_call_partial (gpointer obj, const char *interface, const char *method, GError **error, const char *type, ...);
 
 dbus_bool_t _atspi_dbus_get_property (AtspiAccessible *obj, const char *interface, const char *name, GError **error, const char *type, void *data);
 
diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c
index a36c402..2ae565d 100644
--- a/atspi/atspi-misc.c
+++ b/atspi/atspi-misc.c
@@ -266,10 +266,11 @@ send_children_changed (AtspiAccessible *parent, AtspiAccessible *child, gboolean
 {
   AtspiEvent e;
 
-  memset (&e, 0, sizeof(e));
   e.type = (add? "object:children-changed:add": "object:children-changed:remove");
   e.source = parent;
   e.detail1 = g_list_index (parent->children, child);
+  e.detail2 = 0;
+  g_value_unset (&e.any);
   _atspi_send_event (&e);
 }
 
@@ -630,8 +631,8 @@ spi_display_name (void)
             {
               gchar *display_p, *screen_p;
               canonical_display_name = g_strdup (display_env);
-              display_p = strrchr (canonical_display_name, ':');
-              screen_p = strrchr (canonical_display_name, '.');
+              display_p = g_utf8_strrchr (canonical_display_name, -1, ':');
+              screen_p = g_utf8_strrchr (canonical_display_name, -1, '.');
               if (screen_p && display_p && (screen_p > display_p))
                 {
                   *screen_p = '\0';
@@ -829,15 +830,16 @@ atspi_exit (void)
 }
 
 dbus_bool_t
-_atspi_dbus_call (AtspiAccessible *obj, const char *interface, const char *method, GError **error, const char *type, ...)
+_atspi_dbus_call (gpointer obj, const char *interface, const char *method, GError **error, const char *type, ...)
 {
   va_list args;
   dbus_bool_t retval;
   DBusError err;
+  AtspiAccessible *accessible = ATSPI_ACCESSIBLE (obj);
 
   dbus_error_init (&err);
   va_start (args, type);
-  retval = dbind_method_call_reentrant_va (_atspi_bus(), obj->app->bus_name, obj->path, interface, method, &err, type, args);
+  retval = dbind_method_call_reentrant_va (_atspi_bus(), accessible->app->bus_name, accessible->path, interface, method, &err, type, args);
   va_end (args);
   if (dbus_error_is_set (&err))
   {
@@ -848,8 +850,9 @@ _atspi_dbus_call (AtspiAccessible *obj, const char *interface, const char *metho
 }
 
 DBusMessage *
-_atspi_dbus_call_partial (AtspiAccessible *obj, const char *interface, const char *method, GError **error, const char *type, ...)
+_atspi_dbus_call_partial (gpointer obj, const char *interface, const char *method, GError **error, const char *type, ...)
 {
+  AtspiAccessible *accessible = ATSPI_ACCESSIBLE (obj);
   va_list args;
   dbus_bool_t retval;
   DBusError err;
@@ -860,7 +863,7 @@ _atspi_dbus_call_partial (AtspiAccessible *obj, const char *interface, const cha
   dbus_error_init (&err);
   va_start (args, type);
 
-    msg = dbus_message_new_method_call (obj->app->bus_name, obj->path, interface, method);
+    msg = dbus_message_new_method_call (accessible->app->bus_name, accessible->path, interface, method);
     if (!msg)
         goto out;
 
@@ -924,7 +927,7 @@ _atspi_dbus_send_with_reply_and_block (DBusMessage *message)
   DBusError err;
 
   dbus_error_init (&err);
-  g_warning ("TODO: Write _atspi_dbus_send_with_reply_and_block");
+  /* TODO: Write this function; allow reentrancy */
   reply = dbus_connection_send_with_reply_and_block (_atspi_bus(), message, 1000, &err);
   dbus_message_unref (message);
   return reply;



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