$(DBIND_CFLAGS) \
-I$(top_srcdir)
-libatspi_LDADD = $(DBUS_GLIB_LIBS) \
+libatspi_la_LIBADD = $(DBUS_GLIB_LIBS) \
$(top_builddir)/dbind/libdbind.la
libatspidir = $(includedir)/at-spi-1.0/atspi
atspi-accessible.h \
atspi-application.c \
atspi-application.h \
+ atspi-component.c \
+ atspi-component.h \
atspi-constants.h \
atspi-event-types.h \
atspi-listener.c \
atspi-registry.c \
atspi-registry.h \
atspi-stateset.c \
- atspi-stateset.h
-
-libatspi_la_LIBADD = \
- $(LIBATSPI_LIBS) \
- $(DBIND_LIBS) \
- $(X_LIBS) \
- $(DBUS_GLIB_LIBS)
+ atspi-stateset.h \
+ atspi-types.h
#BUILT_SOURCES = atspi-constants.h
* For typographic, textual, or textually-semantic attributes, see
* atspi_text_get_attributes instead.
*
- * Returns: (transfer full): The name-value-pair attributes assigned to this
- * object.
+ * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
+ * attributes assigned to this object.
*/
GHashTable *
atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
}
/**
+ * atspi_accessible_get_attributes_as_array:
+ * @obj: The #AtspiAccessible being queried.
+ *
+ * Get the #AttributeSet representing any assigned
+ * name-value pair attributes or annotations for this object.
+ * For typographic, textual, or textually-semantic attributes, see
+ * atspi_text_get_attributes_as_array instead.
+ *
+ * Returns: (element-type gchar*) (transfer full): The name-value-pair
+ * attributes assigned to this object.
+ */
+GArray *
+atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
+{
+ DBusMessage *message;
+ GHashTable *ret;
+
+ g_return_val_if_fail (obj != NULL, NULL);
+
+ message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
+ ret = _atspi_dbus_attribute_array_from_message (message);
+ dbus_message_unref (message);
+ return ret;
+}
+
+/**
* atspi_accessible_get_host_application:
* @obj: The #AtspiAccessible being queried.
*
* NULL if @obj does not implement #AtspiApplication.
**/
AtspiApplication *
-atspi_accessible_get_application (AtspiAccessible *obj)
+atspi_accessible_get_application (AtspiAccessible *accessible)
{
return (_atspi_accessible_is_a (accessible, atspi_interface_application) ?
- ATSPI_APPLICATION (accessible) : NULL);
+ accessible : NULL);
}
/**
* NULL if @obj does not implement #AtspiAction.
**/
AtspiAction *
-atspi_accessible_get_action (AtspiAccessible *obj)
+atspi_accessible_get_action (AtspiAccessible *accessible)
{
return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
- ATSPI_APPLICATION (accessible) : NULL);
+ accessible : NULL);
}
/**
* NULL if @obj does not implement #AtspiCollection.
**/
AtspiCollection *
-atspi_accessible_get_collection (AtspiAccessible *obj)
+atspi_accessible_get_collection (AtspiAccessible *accessible)
{
return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
- ATSPI_APPLICATION (accessible) : NULL);
+ accessible : NULL);
}
+#endif
/**
* atspi_accessible_get_component:
* NULL if @obj does not implement #AtspiComponent.
**/
AtspiComponent *
-atspi_accessible_get_component (AtspiAccessible *obj)
+atspi_accessible_get_component (AtspiAccessible *accessible)
{
return (_atspi_accessible_is_a (accessible, atspi_interface_component) ?
- ATSPI_APPLICATION (accessible) : NULL);
+ accessible : NULL);
}
+#if 0
/**
* atspi_accessible_get_document:
* @obj: a pointer to the #AtspiAccessible instance to query.
* NULL if @obj does not implement #AtspiDocument.
**/
AtspiDocument *
-atspi_accessible_get_document (AtspiAccessible *obj)
+atspi_accessible_get_document (AtspiAccessible *accessible)
{
return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
- ATSPI_APPLICATION (accessible) : NULL);
+ accessible : NULL);
}
/**
* NULL if @obj does not implement #AtspiEditableText.
**/
AtspiEditableText *
-atspi_accessible_get_editable_text (AtspiAccessible *obj)
+atspi_accessible_get_editable_text (AtspiAccessible *accessible)
{
return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
- ATSPI_APPLICATION (accessible) : NULL);
+ accessible : NULL);
}
/**
* NULL if @obj does not implement #AtspiHypertext.
**/
AtspiHypertext *
-atspi_accessible_get_hypertext (AtspiAccessible *obj)
+atspi_accessible_get_hypertext (AtspiAccessible *accessible)
{
return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
- ATSPI_APPLICATION (accessible) : NULL);
+ accessible : NULL);
}
/**
* NULL if @obj does not implement #AtspiImage.
**/
AtspiImage *
-atspi_accessible_get_image (AtspiAccessible *obj)
+atspi_accessible_get_image (AtspiAccessible *accessible)
{
return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
- ATSPI_APPLICATION (accessible) : NULL);
+ accessible : NULL);
}
/**
* NULL if @obj does not implement #AtspiSelection.
**/
AtspiSelection *
-atspi_accessible_get_selection (AtspiAccessible *obj)
+atspi_accessible_get_selection (AtspiAccessible *accessible)
{
return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
- ATSPI_APPLICATION (accessible) : NULL);
+ accessible : NULL);
}
/**
* NULL if @obj does not implement #AtspiStreamableContent.
**/
AtspiStreamableContent *
-atspi_accessible_get_streamable_content (AtspiAccessible *obj)
+atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
{
return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
- ATSPI_APPLICATION (accessible) : NULL);
+ accessible : NULL);
}
/**
* NULL if @obj does not implement #AtspiTable.
**/
AtspiTable *
-atspi_accessible_get_table (AtspiAccessible *obj)
+atspi_accessible_get_table (AtspiAccessible *accessible)
{
return (_atspi_accessible_is_a (accessible, atspi_interface_table) ?
- ATSPI_APPLICATION (accessible) : NULL);
+ accessible : NULL);
}
/**
* NULL if @obj does not implement #AtspiTable.
**/
AtspiTable *
-atspi_accessible_get_text (AtspiAccessible *obj)
+atspi_accessible_get_text (AtspiAccessible *accessible)
{
return (_atspi_accessible_is_a (accessible, atspi_interface_text) ?
- ATSPI_APPLICATION (accessible) : NULL);
+ accessible : NULL);
}
/**
* NULL if @obj does not implement #AtspiTable.
**/
AtspiTable *
-atspi_accessible_get_value (AtspiAccessible *obj)
+atspi_accessible_get_value (AtspiAccessible *accessible)
{
return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
- ATSPI_APPLICATION (accessible) : NULL);
+ accessible : NULL);
}
static gboolean
{
return spi_state_set_cache_is_empty (obj);
}
+#endif
gboolean
_atspi_accessible_is_a (AtspiAccessible *accessible,
return FALSE;
}
- n = get_iface_num (interface_name);
+ n = _atspi_get_iface_num (interface_name);
if (n == -1) return FALSE;
- return (gbooleanean)((accessible->interfaces & (1 << n))? TRUE: FALSE);
+ return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
}
-#endif
/* TODO: Move to a finalizer */
static void
#include "atspi-application.h"
#include "atspi-constants.h"
#include "atspi-stateset.h"
+#include "atspi-types.h"
#define ATSPI_TYPE_ACCESSIBLE (atspi_accessible_get_type ())
#define ATSPI_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATSPI_TYPE_ACCESSIBLE, AtspiAccessible))
GHashTable * atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error);
+GArray * atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error);
+
AtspiApplication * atspi_accessible_get_host_application (AtspiAccessible *obj, GError **error);
+AtspiComponent * atspi_accessible_get_component (AtspiAccessible *accessible);
#endif /* _ATSPI_ACCESSIBLE_H_ */
--- /dev/null
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, 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.
+ */
+
+/*
+ *
+ * AtspiComponent function implementations
+ *
+ */
+
+#include "atspi-private.h"
+
+/**
+ * atspi_component_contains:
+ * @obj: a pointer to the #AtspiComponent to query.
+ * @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. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN).
+ *
+ * Query whether a given #AtspiComponent contains a particular point.
+ *
+ * Returns: a #TRUE if the specified component contains the point (@x, @y),
+ * otherwise #FALSE.
+ **/
+gboolean
+atspi_component_contains (AtspiComponent *obj,
+ gint x,
+ gint y,
+ AtspiCoordType ctype, GError **error)
+{
+ dbus_bool_t retval = FALSE;
+ dbus_int32_t d_x = x, d_y = y;
+ dbus_uint16_t d_ctype = ctype;
+
+ g_return_val_if_fail (obj != NULL, FALSE);
+
+ _atspi_dbus_call (obj, atspi_interface_component, "Contains", error, "iin=>b", d_x, d_y, d_ctype, &retval);
+
+ return retval;
+}
+
+/**
+ * atspi_component_get_accessible_at_point:
+ * @obj: a pointer to the #AtspiComponent to query.
+ * @x: a #gint specifying the x coordinate of the point in question.
+ * @y: a #gint specifying the y coordinate of the point in question.
+ * @ctype: the coordinate system of the point (@x, @y)
+ * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
+ *
+ * Get the accessible child at a given coordinate within an #AtspiComponent.
+ *
+ * Returns: a pointer to an #AtspiAccessible child of the specified component
+ * which contains the point (@x, @y), or NULL of no child contains
+ * the point.
+ **/
+AtspiAccessible *
+atspi_component_get_accessible_at_point (AtspiComponent *obj,
+ gint x,
+ gint y,
+ AtspiCoordType ctype, GError **error)
+{
+ dbus_int32_t d_x = x, d_y = y;
+ dbus_uint16_t d_ctype = ctype;
+ DBusMessage *reply;
+ char *path = NULL;
+ AtspiAccessible *retval = NULL;
+
+ g_return_val_if_fail (obj != NULL, FALSE);
+
+ reply = _atspi_dbus_call_partial (obj, atspi_interface_component, "GetAccessibleAtPoint", error, "iin", d_x, d_y, d_ctype);
+
+ return _atspi_dbus_return_accessible_from_message (reply);
+}
+
+/**
+ * atspi_component_get_extents:
+ * @obj: a pointer to the #AtspiComponent to query.
+ * @x: a pointer to a #int into which the minimum x coordinate will be returned.
+ * @y: a pointer to a #int into which the minimum y coordinate will be returned.
+ * @width: a pointer to a #int into which the x extents (width) will be returned.
+ * @height: a pointer to a #int into which the y extents (height) will be returned.
+ * @ctype: the desired coordinate system into which to return the results,
+ * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
+ *
+ * Get the bounding box of the specified #AtspiComponent.
+ *
+ **/
+AtspiBoundingBox
+atspi_component_get_extents (AtspiComponent *obj,
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height,
+ AtspiCoordType ctype, GError **error)
+{
+ dbus_int16_t d_ctype = ctype;
+ AtspiBoundingBox bbox;
+
+ g_return_if_fail (obj != NULL);
+
+ _atspi_dbus_call (obj, atspi_interface_component, "GetExtents", error, "n=>(iiii)", d_ctype, &bbox);
+ return bbox;
+}
+
+/**
+ * atspi_component_get_position:
+ * @obj: a pointer to the #AtspiComponent to query.
+ * @ctype: the desired coordinate system into which to return the results,
+ * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
+ *
+ * returns: A #AtspiPoint giving the position.
+ * Get the minimum x and y coordinates of the specified #AtspiComponent.
+ *
+ **/
+AtspiPoint
+atspi_component_get_position (AtspiComponent *obj,
+ AtspiCoordType ctype, GError **error)
+{
+ dbus_int32_t d_x, d_y;
+ dbus_uint16_t d_ctype = ctype;
+ AtspiPoint ret;
+
+ ret.x = ret.y = 0;
+
+ if (!obj)
+ return ret;
+
+ _atspi_dbus_call (obj, atspi_interface_component, "GetPosition", error, "n=>ii", d_ctype, &d_x, &d_y);
+
+ ret.x = d_x;
+ ret.y = d_y;
+ return ret;
+}
+
+/**
+ * atspi_component_get_size:
+ * @obj: a pointer to the #AtspiComponent to query.
+ * returns: A #AtspiPoint giving the siize.
+ *
+ * Get the size of the specified #AtspiComponent.
+ *
+ **/
+AtspiPoint
+atspi_component_get_size (AtspiComponent *obj, GError **error)
+{
+ dbus_int32_t d_w, d_h;
+ AtspiPoint ret;
+
+ ret.x = ret.y = 0;
+ if (!obj)
+ return ret;
+
+ _atspi_dbus_call (obj, atspi_interface_component, "GetSize", error, "=>ii", &d_w, &d_h);
+ ret.x = d_w;
+ ret.y = d_h;
+ return ret;
+}
+
+/**
+ * atspi_component_get_layer:
+ * @obj: a pointer to the #AtspiComponent to query.
+ *
+ * Query which layer the component is painted into, to help determine its
+ * visibility in terms of stacking order.
+ *
+ * Returns: the #AtspiComponentLayer into which this component is painted.
+ **/
+AtspiComponentLayer
+atspi_component_get_layer (AtspiComponent *obj, GError **error)
+{
+ dbus_uint32_t zlayer = 0;
+
+ _atspi_dbus_call (obj, atspi_interface_component, "GetLayer", error, "=>u", &zlayer);
+
+ return zlayer;
+}
+
+/**
+ * atspi_component_get_mdi_z_order:
+ * @obj: a pointer to the #AtspiComponent to query.
+ *
+ * Query the z stacking order of a component which is in the MDI or window
+ * layer. (Bigger z-order numbers mean nearer the top)
+ *
+ * Returns: a short integer indicating the stacking order of the component
+ * in the MDI layer, or -1 if the component is not in the MDI layer.
+ **/
+gshort
+atspi_component_get_mdi_z_order (AtspiComponent *obj, GError **error)
+{
+ dbus_uint16_t retval = -1;
+
+ _atspi_dbus_call (obj, atspi_interface_component, "GetMDIZOrder", error, "=>n", &retval);
+
+ return retval;
+}
+
+/**
+ * atspi_component_grab_focus:
+ * @obj: a pointer to the #AtspiComponent on which to operate.
+ *
+ * Attempt to set the keyboard input focus to the specified
+ * #AtspiComponent.
+ *
+ * Returns: #TRUE if successful, #FALSE otherwise.
+ *
+ **/
+gboolean
+atspi_component_grab_focus (AtspiComponent *obj, GError **error)
+{
+ dbus_bool_t retval = FALSE;
+
+ _atspi_dbus_call (obj, atspi_interface_component, "GrabFocus", error, "=>b", &retval);
+
+ return retval;
+}
+
+/**
+ * atspi_component_get_alpha:
+ * @obj: The #AtspiComponent to be queried.
+ *
+ * Get the opacity/alpha value of a component, if alpha blending is in use.
+ *
+ * Returns: the opacity value of a component, as a double between 0.0 and 1.0.
+ **/
+gdouble
+atspi_component_get_alpha (AtspiComponent *obj, GError **error)
+{
+ double retval = 1;
+
+ _atspi_dbus_call (obj, atspi_interface_component, "GetAlpha", error, "=>d", &retval);
+
+ return retval;
+}
extern const char *atspi_interface_value;
/* function prototypes */
+gint _atspi_get_iface_num (const char *iface);
+
DBusConnection * _atspi_bus ();
AtspiAccessible * _atspi_ref_accessible (const char *app, const char *path);
+AtspiAccessible *
+_atspi_dbus_return_accessible_from_message (DBusMessage *message);
+
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, ...);
DBusMessage * _atspi_dbus_send_with_reply_and_block (DBusMessage *message);
-GHashTable *
-_atspi_dbus_hash_from_message (DBusMessage *message);
+GHashTable *_atspi_dbus_hash_from_message (DBusMessage *message);
+
+GArray *_atspi_dbus_attribute_array_from_message (DBusMessage *message);
#endif /* _ATSPI_MISC_PRIVATE_H_ */
NULL
};
-static gint get_iface_num (const char *iface)
+gint
+_atspi_get_iface_num (const char *iface)
{
/* TODO: Use a binary search or hash to improve performance */
int i;
gint n;
dbus_message_iter_get_basic (&iter_array, &iface);
if (!strcmp (iface, "org.freedesktop.DBus.Introspectable")) continue;
- n = get_iface_num (iface);
+ n = _atspi_get_iface_num (iface);
if (n == -1)
{
g_warning ("Unknown interface %s", iface);
}
AtspiAccessible *
+_atspi_dbus_return_accessible_from_message (DBusMessage *message)
+{
+ DBusMessageIter iter;
+ const char *app_name, *path;
+ AtspiAccessible *retval = NULL;
+ const char *signature = dbus_message_get_signature (message);
+
+ if (!strcmp (signature, "(so)"))
+ {
+ dbus_message_iter_init (message, &iter);
+ get_reference_from_iter (&iter, &app_name, &path);
+ retval = _atspi_ref_accessible (app_name, path);
+ }
+ else
+ {
+ g_warning ("Atspi: Called __atspi_dbus_return_accessible_from_message with strange signature %s", signature);
+ }
+ dbus_message_unref (message);
+ return retval;
+}
+
+/* TODO: Remove this function. We should not need it anymore.
+ * If we do, it's a bug.
+ */
+AtspiAccessible *
_atspi_ref_related_accessible (AtspiAccessible *obj, const AtspiReference *ref)
{
const char *app = (ref->name && ref->name[0]? ref->name: obj->app->bus_name);
dbus_message_iter_init (message, &iter);
dbus_message_iter_recurse (&iter, &iter_array);
- do
+ while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
{
const char *name, *value;
dbus_message_iter_recurse (&iter_array, &iter_dict);
dbus_message_iter_get_basic (&iter_dict, &name);
dbus_message_iter_get_basic (&iter_dict, &value);
g_hash_table_insert (hash, g_strdup (name), g_strdup (value));
- } while (dbus_message_iter_next (&iter_array));
+ dbus_message_iter_next (&iter_array);
+ }
return hash;
}
+GArray *
+_atspi_dbus_attribute_array_from_message (DBusMessage *message)
+{
+ GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
+ DBusMessageIter iter, iter_array, iter_dict;
+ const char *signature;
+ gint count = 0;
+
+ signature = dbus_message_get_signature (message);
+
+ if (strcmp (signature, "a{ss}") != 0)
+ {
+ g_warning ("Trying to get hash from message of unexpected type %s\n", signature);
+ return NULL;
+ }
+
+ dbus_message_iter_init (message, &iter);
+
+ dbus_message_iter_recurse (&iter, &iter_array);
+ while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
+ {
+ const char *name, *value;
+ gchar *str;
+ GArray *new_array;
+ dbus_message_iter_recurse (&iter_array, &iter_dict);
+ dbus_message_iter_get_basic (&iter_dict, &name);
+ dbus_message_iter_get_basic (&iter_dict, &value);
+ str = g_strdup_printf ("%s:;%s", name, value);
+ new_array = g_array_append_val (array, str);
+ if (new_array)
+ array = new_array;
+ dbus_message_iter_next (&iter);;
+ }
+ return array;
+}
+
--- /dev/null
+/*
+ * 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_TYPES_H_
+#define _ATSPI_TYPES_H_
+
+#include "glib-object.h"
+
+#include "atspi-event-types.h"
+
+typedef struct _AtspiAccessible AtspiAction;
+typedef struct _AtspiAccessible AtspiCollection;
+typedef struct _AtspiAccessible AtspiComponent;
+typedef struct _AtspiAccessible AtspiDocument;
+typedef struct _AtspiAccessible AtspiEditableText;
+typedef struct _AtspiAccessible AtspiHypertext;
+typedef struct _AtspiAccessible AtspiSelection;
+typedef struct _AtspiAccessible AtspiTable;
+typedef struct _AtspiAccessible AtspiText;
+typedef struct _AtspiAccessible AtspiValue;
+#endif /* _ATSPI_TYPES_H_ */
#include "glib.h"
#include "atspi-constants.h"
-#include "atspi-event-types.h"
+#include "atspi-types.h"
#include "atspi-accessible.h"
+#include "atspi-component.h"
#include "atspi-listener.h"
#include "atspi-misc.h"
#include "atspi-registry.h"