[at-spi2-core/gi] Add Hypertext and Hyperlink and some refactoring to support them
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [at-spi2-core/gi] Add Hypertext and Hyperlink and some refactoring to support them
- Date: Sat, 20 Nov 2010 15:58:25 +0000 (UTC)
commit 585683c4e828aaa1dbb883df9274d14753a58088
Author: Mike Gorse <mgorse novell com>
Date: Sat Nov 20 10:59:06 2010 -0500
Add Hypertext and Hyperlink and some refactoring to support them
AtspiAccessible is now derived from a base class called AtspiObject which
defines the object's application and object path, since this is common with
AtspiHyperlink.
atspi/Makefile.am | 6 +
atspi/atspi-accessible.c | 22 ++---
atspi/atspi-accessible.h | 9 +-
atspi/atspi-hyperlink.c | 221 ++++++++++++++++++++++++++++++++++++++++++++
atspi/atspi-hyperlink.h | 73 +++++++++++++++
atspi/atspi-hypertext.c | 123 ++++++++++++++++++++++++
atspi/atspi-hypertext.h | 52 ++++++++++
atspi/atspi-misc-private.h | 6 +-
atspi/atspi-misc.c | 100 ++++++++++++--------
atspi/atspi-object.c | 50 ++++++++++
atspi/atspi-object.h | 55 +++++++++++
atspi/atspi-table.c | 12 +-
atspi/atspi-text.c | 2 +-
atspi/atspi-text.h | 3 +
atspi/atspi-types.h | 2 +-
atspi/atspi.h | 2 +
16 files changed, 673 insertions(+), 65 deletions(-)
---
diff --git a/atspi/Makefile.am b/atspi/Makefile.am
index 528f313..58f2d76 100644
--- a/atspi/Makefile.am
+++ b/atspi/Makefile.am
@@ -33,11 +33,17 @@ libatspi_la_SOURCES = \
atspi-event-listener.c \
atspi-event-listener.h \
atspi-event-listener-private.h \
+ atspi-hyperlink.c \
+ atspi-hyperlink.h \
+ atspi-hypertext.c \
+ atspi-hypertext.h \
atspi-image.c \
atspi-image.h \
atspi-misc.c \
atspi-misc.h \
atspi-misc-private.h \
+ atspi-object.c \
+ atspi-object.h \
atspi-private.h \
atspi-registry.c \
atspi-registry.h \
diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c
index 679491a..da2b53f 100644
--- a/atspi/atspi-accessible.c
+++ b/atspi/atspi-accessible.c
@@ -63,7 +63,7 @@ atspi_value_interface_init (AtspiValue *value)
{
}
-G_DEFINE_TYPE_WITH_CODE (AtspiAccessible, atspi_accessible, G_TYPE_OBJECT,
+G_DEFINE_TYPE_WITH_CODE (AtspiAccessible, atspi_accessible, ATSPI_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (ATSPI_TYPE_ACTION, atspi_action_interface_init)
G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COMPONENT, atspi_component_interface_init)
G_IMPLEMENT_INTERFACE (ATSPI_TYPE_EDITABLE_TEXT, atspi_editable_text_interface_init)
@@ -81,12 +81,9 @@ atspi_accessible_init (AtspiAccessible *accessible)
static void
atspi_accessible_finalize (GObject *obj)
{
- AtspiAccessible *accessible = ATSPI_ACCESSIBLE (obj);
+ /*AtspiAccessible *accessible = ATSPI_ACCESSIBLE (obj); */
- if (accessible->app)
- g_object_unref (accessible->app);
-
- g_free (accessible->path);
+ /* TODO: Unref parent/children, etc. */
}
static void
@@ -282,7 +279,8 @@ atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
{
DBusMessage *message, *reply;
DBusMessageIter iter, iter_variant;
- message = dbus_message_new_method_call (obj->app->bus_name, obj->path,
+ message = dbus_message_new_method_call (obj->parent.app->bus_name,
+ obj->parent.path,
DBUS_INTERFACE_PROPERTIES, "Get");
if (!message)
return NULL;
@@ -890,7 +888,6 @@ atspi_accessible_get_editable_text (AtspiAccessible *accessible)
g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
}
-#if 0
/**
* atspi_accessible_get_hypertext:
* @obj: a pointer to the #AtspiAccessible instance to query.
@@ -904,9 +901,8 @@ AtspiHypertext *
atspi_accessible_get_hypertext (AtspiAccessible *accessible)
{
return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
- accessible : NULL);
+ g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
}
-#endif
/**
* atspi_accessible_get_image:
@@ -1349,7 +1345,7 @@ cspi_object_destroyed (AtspiAccessible *accessible)
e.detail2 = 0;
_atspi_send_event (&e);
- g_free (accessible->path);
+ g_free (accessible->parent.path);
if (accessible->states)
g_object_unref (accessible->states);
@@ -1365,8 +1361,8 @@ atspi_accessible_new (AtspiApplication *app, const gchar *path)
accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
g_return_val_if_fail (accessible != NULL, NULL);
- accessible->app = g_object_ref (app);
- accessible->path = g_strdup (path);
+ accessible->parent.app = g_object_ref (app);
+ accessible->parent.path = g_strdup (path);
return accessible;
}
diff --git a/atspi/atspi-accessible.h b/atspi/atspi-accessible.h
index f4f4fdc..e2a95fe 100644
--- a/atspi/atspi-accessible.h
+++ b/atspi/atspi-accessible.h
@@ -29,6 +29,7 @@
#include "atspi-application.h"
#include "atspi-constants.h"
+#include "atspi-object.h"
#include "atspi-stateset.h"
#include "atspi-types.h"
@@ -41,11 +42,9 @@
struct _AtspiAccessible
{
- GObject parent;
+ AtspiObject parent;
AtspiAccessible *accessible_parent;
GList *children;
- AtspiApplication *app;
- char *path;
AtspiRole role;
gint interfaces;
char *name;
@@ -57,7 +56,7 @@ struct _AtspiAccessible
typedef struct _AtspiAccessibleClass AtspiAccessibleClass;
struct _AtspiAccessibleClass
{
- GObjectClass parent_class;
+ AtspiObjectClass parent_class;
};
GType atspi_accessible_get_type (void);
@@ -103,6 +102,8 @@ AtspiDocument * atspi_accessible_get_document (AtspiAccessible *obj);
AtspiEditableText * atspi_accessible_get_editable_text (AtspiAccessible *obj);
+AtspiHypertext * atspi_accessible_get_hypertext (AtspiAccessible *obj);
+
AtspiImage * atspi_accessible_get_image (AtspiAccessible *obj);
AtspiSelection * atspi_accessible_get_selection (AtspiAccessible *obj);
diff --git a/atspi/atspi-hyperlink.c b/atspi/atspi-hyperlink.c
new file mode 100644
index 0000000..0be7924
--- /dev/null
+++ b/atspi/atspi-hyperlink.c
@@ -0,0 +1,221 @@
+/*
+ * 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.
+ */
+
+#include "atspi-private.h"
+
+G_DEFINE_TYPE (AtspiHyperlink, atspi_hyperlink, ATSPI_TYPE_OBJECT)
+
+static void
+atspi_hyperlink_init (AtspiHyperlink *hyperlink)
+{
+}
+
+static void
+atspi_hyperlink_finalize (GObject *obj)
+{
+ /*AtspiHyperlink *hyperlink = ATSPI_HYPERLINK (obj); */
+
+ /* TODO: Unref parent/children, etc. */
+}
+
+static void
+atspi_hyperlink_class_init (AtspiHyperlinkClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = atspi_hyperlink_finalize;
+}
+
+AtspiHyperlink *
+atspi_hyperlink_new (AtspiApplication *app, const gchar *path)
+{
+ AtspiHyperlink *hyperlink;
+
+ hyperlink = g_object_new (ATSPI_TYPE_HYPERLINK, NULL);
+ g_return_val_if_fail (hyperlink != NULL, NULL);
+
+ hyperlink->parent.app = g_object_ref (app);
+ hyperlink->parent.path = g_strdup (path);
+
+ return hyperlink;
+}
+
+/**
+ * atspi_hyperlink_get_n_anchors:
+ * @obj: a pointer to the #AtspiHyperlink object on which to operate.
+ *
+ * Get the total number of anchors which an #AtspiHyperlink implementor has.
+ * Though typical hyperlinks have only one anchor, client-side image maps and
+ * other hypertext objects may potentially activate or refer to multiple
+ * URIs. For each anchor there is a corresponding URI and object.
+ * see atspi_hyperlink_get_uri() and atspi_hyperlink_get_object().
+ *
+ * Returns: a #gint indicating the number of anchors in this hyperlink.
+ **/
+gint
+atspi_hyperlink_get_n_anchors (AtspiHyperlink *obj, GError **error)
+{
+ dbus_int32_t retval;
+
+ g_return_val_if_fail (obj != NULL, -1);
+
+ _atspi_dbus_get_property (obj, atspi_interface_hyperlink, "NAnchors", error, "i", &retval);
+
+ return retval;
+}
+
+/**
+ * atspi_hyperlink_get_uri:
+ * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
+ * @i: a (zero-index) integer indicating which hyperlink anchor to query.
+ *
+ * Get the URI associated with a particular hyperlink anchor.
+ *
+ * Returns: a UTF-8 string giving the URI of the @ith hyperlink anchor.
+ **/
+gchar *
+atspi_hyperlink_get_uri (AtspiHyperlink *obj, int i, GError **error)
+{
+ dbus_int32_t d_i = i;
+ char *retval;
+
+ g_return_val_if_fail (obj != NULL, NULL);
+
+ _atspi_dbus_call (obj, atspi_interface_hyperlink, "GetURI", error, "i=>s", d_i, &retval);
+
+ return retval;
+}
+
+/**
+ * atspi_hyperlink_get_object:
+ * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
+ * @i: a (zero-index) long integer indicating which hyperlink anchor to query.
+ *
+ * Get the object associated with a particular hyperlink anchor, as an #Accessible.
+ *
+ * Returns: (transfer full): an #AtspiAccessible that represents the object
+ * associated with the @ith anchor of the specified #AtspiHyperlink.
+ **/
+AtspiAccessible*
+atspi_hyperlink_get_object (AtspiHyperlink *obj, gint i, GError **error)
+{
+ dbus_int32_t d_i = i;
+ DBusMessage *reply;
+
+ g_return_val_if_fail (obj != NULL, NULL);
+
+ reply = _atspi_dbus_call_partial (obj, atspi_interface_hyperlink, "GetObject", error, "i", d_i);
+
+ return _atspi_dbus_return_accessible_from_message (reply);
+}
+
+/**
+ * atspi_hyperlink_get_index_range:
+ * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
+ *
+ *
+ * Get the starting and ending character offsets of the text range associated with
+ * a #AtspiHyperlink, in its originating #AtspiHypertext.
+ **/
+AtspiRange *
+atspi_hyperlink_get_index_range (AtspiHyperlink *obj, GError **error)
+{
+ dbus_int32_t d_start_offset, d_end_offset;
+ AtspiRange *ret = g_new (AtspiRange, 1);
+
+ if (ret)
+ ret->start_offset = ret->end_offset = -1;
+
+ if (!obj || !ret)
+ return ret;
+
+ _atspi_dbus_call (obj, atspi_interface_hyperlink, "GetIndexRange", error, "=>ii", &d_start_offset, &d_end_offset);
+
+ ret->start_offset = d_start_offset;
+ ret->end_offset = d_end_offset;
+ return ret;
+}
+
+/**
+ * atspi_hyperlink_get_start_index:
+ * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
+ *
+ *
+ * Get the starting character offset of the text range associated with
+ * a #AtspiHyperlink, in its originating #AtspiHypertext.
+ **/
+gint
+atspi_hyperlink_get_start_index (AtspiHyperlink *obj, GError **error)
+{
+ dbus_int32_t d_start_offset = -1;
+
+ if (!obj)
+ return -1;
+
+ _atspi_dbus_call (obj, atspi_interface_hyperlink, "GetStartIndex", error, "=>i", &d_start_offset);
+
+ return d_start_offset;
+}
+/**
+ * atspi_hyperlink_get_end_index:
+ * @obj: a pointer to the #AtspiHyperlink implementor on which to operate.
+ *
+ *
+ * Get the ending character offset of the text range associated with
+ * a #AtspiHyperlink, in its originating #AtspiHypertext.
+ **/
+gint
+atspi_hyperlink_get_end_index (AtspiHyperlink *obj, GError **error)
+{
+ dbus_int32_t d_end_offset = -1;
+
+ if (!obj)
+ return -1;
+
+ _atspi_dbus_call (obj, atspi_interface_hyperlink, "GetEndIndex", error, "=>i", &d_end_offset);
+
+ return d_end_offset;
+}
+
+
+/**
+ * atspi_hyperlink_is_valid:
+ * @obj: a pointer to the #AtspiHyperlink on which to operate.
+ *
+ * Tell whether an #AtspiHyperlink object is still valid with respect to its
+ * originating hypertext object.
+ *
+ * Returns: #TRUE of the specified #AtspiHyperlink is still valid with respect
+ * to its originating #AtspiHypertext object, #FALSE otherwise.
+ **/
+gboolean
+atspi_hyperlink_is_valid (AtspiHyperlink *obj, GError **error)
+{
+ dbus_bool_t retval;
+
+ g_return_val_if_fail (obj != NULL, FALSE);
+
+ _atspi_dbus_call (obj, atspi_interface_hyperlink, "IsValid", error, "=>b", &retval);
+
+ return retval;
+}
diff --git a/atspi/atspi-hyperlink.h b/atspi/atspi-hyperlink.h
new file mode 100644
index 0000000..0af3f59
--- /dev/null
+++ b/atspi/atspi-hyperlink.h
@@ -0,0 +1,73 @@
+/*
+ * 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_HYPERLINK_H_
+#define _ATSPI_HYPERLINK_H_
+
+#include "glib-object.h"
+
+#include "atspi-constants.h"
+
+#include "atspi-text.h" /* for AtspiRange */
+#include "atspi-types.h"
+
+#define ATSPI_TYPE_HYPERLINK (atspi_hyperlink_get_type ())
+#define ATSPI_HYPERLINK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATSPI_TYPE_HYPERLINK, AtspiHyperlink))
+#define ATSPI_HYPERLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATSPI_TYPE_HYPERLINK, AtspiHyperlinkClass))
+#define ATSPI_IS_HYPERLINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATSPI_TYPE_HYPERLINK))
+#define ATSPI_IS_HYPERLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATSPI_TYPE_HYPERLINK))
+#define ATSPI_HYPERLINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATSPI_TYPE_HYPERLINK, AtspiHyperlinkClass))
+
+typedef struct _AtspiHyperlink AtspiHyperlink;
+struct _AtspiHyperlink
+{
+ AtspiObject parent;
+};
+
+typedef struct _AtspiHyperlinkClass AtspiHyperlinkClass;
+struct _AtspiHyperlinkClass
+{
+ AtspiObjectClass parent_class;
+};
+
+GType atspi_hyperlink_get_type (void);
+
+AtspiHyperlink *
+atspi_hyperlink_new (AtspiApplication *app, const gchar *path);
+
+gint atspi_hyperlink_get_n_anchors (AtspiHyperlink *obj, GError **error);
+
+gchar * atspi_hyperlink_get_uri (AtspiHyperlink *obj, int i, GError **error);
+
+AtspiAccessible* atspi_hyperlink_get_object (AtspiHyperlink *obj, gint i, GError **error);
+
+AtspiRange * atspi_hyperlink_get_index_range (AtspiHyperlink *obj, GError **error);
+
+gint atspi_hyperlink_get_start_index (AtspiHyperlink *obj, GError **error);
+
+gint atspi_hyperlink_get_end_index (AtspiHyperlink *obj, GError **error);
+
+gboolean atspi_hyperlink_is_valid (AtspiHyperlink *obj, GError **error);
+
+#endif /* _ATSPI_HYPERLINK_H_ */
diff --git a/atspi/atspi-hypertext.c b/atspi/atspi-hypertext.c
new file mode 100644
index 0000000..4b1814d
--- /dev/null
+++ b/atspi/atspi-hypertext.c
@@ -0,0 +1,123 @@
+/*
+ * 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.
+ */
+
+#include "atspi-private.h"
+
+/**
+ * atspi_hypertext_get_n_links:
+ * @obj: a pointer to the #AtspiHypertext implementor on which to operate.
+ *
+ * Get the total number of #AtspiHyperlinks which an
+ * #AtspiHypertext implementor has.
+ *
+ * Returns: a #gint indicating the number of #AtspiHyperlinks
+ * of the #AtspiHypertext implementor, or -1 if
+ * the number cannot be determined (for example, if the
+ * #AtspiHypertext object is so large that it is not
+ * all currently in the memory cache).
+ **/
+gint
+atspi_hypertext_get_n_links (AtspiHypertext *obj, GError **error)
+{
+ dbus_int32_t retval = 0;
+
+ g_return_val_if_fail (obj != NULL, FALSE);
+
+ _atspi_dbus_call (obj, atspi_interface_hypertext, "GetNLinks", error, "=>i", &retval);
+
+ return retval;
+}
+
+/**
+ * atspi_hypertext_get_link:
+ * @obj: a pointer to the #AtspiHypertext implementor on which to operate.
+ * @link_index: a (zero-index) integer indicating which hyperlink to query.
+ *
+ * Get the #AtspiHyperlink object at a specified index.
+ *
+ * Returns: (transfer full): the #AtspiHyperlink object specified by
+ * #link_index.
+ **/
+AtspiHyperlink *
+atspi_hypertext_get_link (AtspiHypertext *obj, gint link_index, GError **error)
+{
+ dbus_int32_t d_link_index = link_index;
+ DBusMessage *reply;
+
+ g_return_val_if_fail (obj != NULL, NULL);
+
+ reply = _atspi_dbus_call_partial (obj, atspi_interface_hypertext, "GetLink", error, "i", d_link_index);
+
+ return _atspi_dbus_return_hyperlink_from_message (reply);
+}
+
+/**
+ * atspi_hypertext_get_link_index:
+ * @obj: a pointer to the #AtspiHypertext implementor on which to operate.
+ * @character_offset: an integer specifying the character offset to query.
+ *
+ * Get the index of the #AtspiHyperlink object at a specified
+ * character offset.
+ *
+ * Returns: the linkIndex of the #AtspiHyperlink active at
+ * character offset @character_offset, or -1 if there is
+ * no hyperlink at the specified character offset.
+ **/
+int
+atspi_hypertext_get_link_index (AtspiHypertext *obj,
+ gint character_offset,
+ GError **error)
+{
+ dbus_int32_t d_character_offset = character_offset;
+ dbus_int32_t retval = -1;
+
+ g_return_val_if_fail (obj != NULL, -1);
+
+ _atspi_dbus_call (obj, atspi_interface_hypertext, "GetLinkIndex", error, "i=>i", d_character_offset, &retval);
+
+ return retval;
+}
+
+static void
+atspi_hypertext_base_init (AtspiHypertext *klass)
+{
+}
+
+GType
+atspi_hypertext_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ static const GTypeInfo tinfo =
+ {
+ sizeof (AtspiHypertext),
+ (GBaseInitFunc) atspi_hypertext_base_init,
+ (GBaseFinalizeFunc) NULL,
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE, "AtspiHypertext", &tinfo, 0);
+
+ }
+ return type;
+}
diff --git a/atspi/atspi-hypertext.h b/atspi/atspi-hypertext.h
new file mode 100644
index 0000000..10cbab5
--- /dev/null
+++ b/atspi/atspi-hypertext.h
@@ -0,0 +1,52 @@
+/*
+ * 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_HYPERTEXT_H_
+#define _ATSPI_HYPERTEXT_H_
+
+#include "glib-object.h"
+
+#include "atspi-constants.h"
+
+#include "atspi-types.h"
+
+#define ATSPI_TYPE_HYPERTEXT (atspi_hypertext_get_type ())
+#define ATSPI_IS_HYPERTEXT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATSPI_TYPE_HYPERTEXT)
+#define ATSPI_HYPERTEXT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATSPI_TYPE_HYPERTEXT, AtspiHypertext)
+#define ATSPI_HYPERTEXT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATSPI_TYPE_HYPERTEXT, AtspiHypertext))
+
+GType atspi_hypertext_get_type ();
+
+struct _AtspiHypertext
+{
+ GTypeInterface parent;
+};
+
+gint atspi_hypertext_get_n_links (AtspiHypertext *obj, GError **error);
+
+AtspiHyperlink * atspi_hypertext_get_link (AtspiHypertext *obj, gint link_index, GError **error);
+
+gint atspi_hypertext_get_link_index (AtspiHypertext *obj, gint character_offset, GError **error);
+
+#endif /* _ATSPI_HYPERTEXT_H_ */
diff --git a/atspi/atspi-misc-private.h b/atspi/atspi-misc-private.h
index c491029..d9ae868 100644
--- a/atspi/atspi-misc-private.h
+++ b/atspi/atspi-misc-private.h
@@ -115,7 +115,11 @@ _atspi_dbus_return_accessible_from_message (DBusMessage *message);
AtspiAccessible *
_atspi_dbus_return_accessible_from_iter (DBusMessageIter *iter);
-AtspiAccessible * _atspi_ref_related_accessible (AtspiAccessible *obj, const AtspiReference *ref);
+AtspiHyperlink *
+_atspi_dbus_return_hyperlink_from_message (DBusMessage *message);
+
+AtspiHyperlink *
+_atspi_dbus_return_hyperlink_from_iter (DBusMessageIter *iter);
dbus_bool_t _atspi_dbus_call (gpointer obj, const char *interface, const char *method, GError **error, const char *type, ...);
diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c
index f770b27..76479e1 100644
--- a/atspi/atspi-misc.c
+++ b/atspi/atspi-misc.c
@@ -183,11 +183,34 @@ ref_accessible (const char *app_name, const char *path)
a = atspi_accessible_new (app, path);
if (!a)
return NULL;
- g_hash_table_insert (app->hash, a->path, a);
+ g_hash_table_insert (app->hash, a->parent.path, a);
g_object_ref (a); /* for the hash */
return a;
}
+static AtspiHyperlink *
+ref_hyperlink (const char *app_name, const char *path)
+{
+ AtspiApplication *app = get_application (app_name);
+ AtspiHyperlink *hyperlink;
+
+ if (!strcmp (path, ATSPI_DBUS_PATH_NULL))
+ return NULL;
+
+ hyperlink = g_hash_table_lookup (app->hash, path);
+ if (hyperlink)
+ {
+ return g_object_ref (hyperlink);
+ }
+ hyperlink = atspi_hyperlink_new (app, path);
+ if (!hyperlink)
+ return NULL;
+ g_hash_table_insert (app->hash, hyperlink->parent.path, hyperlink);
+ /* TODO: This should be a weak ref */
+ g_object_ref (hyperlink); /* for the hash */
+ return hyperlink;
+}
+
typedef struct
{
char *path;
@@ -293,7 +316,7 @@ remove_app_from_desktop (AtspiAccessible *a, const char *bus_name)
for (l = a->children; l; l = l->next)
{
child = l->data;
- if (!strcmp (bus_name, child->app->bus_name)) break;
+ if (!strcmp (bus_name, child->parent.app->bus_name)) break;
}
if (!l)
{
@@ -465,7 +488,7 @@ ref_accessible_desktop (AtspiApplication *app)
{
return NULL;
}
- g_hash_table_insert (app->hash, desktop->path, desktop);
+ g_hash_table_insert (app->hash, desktop->parent.path, desktop);
g_object_ref (desktop); /* for the hash */
desktop->name = g_strdup ("main");
dbus_error_init (&error);
@@ -522,7 +545,7 @@ _atspi_dbus_return_accessible_from_message (DBusMessage *message)
}
else
{
- g_warning ("Atspi: Called __atspi_dbus_return_accessible_from_message with strange signature %s", signature);
+ g_warning ("Atspi: Called _atspi_dbus_return_accessible_from_message with strange signature %s", signature);
}
dbus_message_unref (message);
return retval;
@@ -537,14 +560,33 @@ _atspi_dbus_return_accessible_from_iter (DBusMessageIter *iter)
return ref_accessible (app_name, path);
}
-/* 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)
+AtspiHyperlink *
+_atspi_dbus_return_hyperlink_from_message (DBusMessage *message)
+{
+ DBusMessageIter iter;
+ AtspiHyperlink *retval = NULL;
+ const char *signature = dbus_message_get_signature (message);
+
+ if (!strcmp (signature, "(so)"))
+ {
+ dbus_message_iter_init (message, &iter);
+ retval = _atspi_dbus_return_hyperlink_from_iter (&iter);
+ }
+ else
+ {
+ g_warning ("Atspi: Called _atspi_dbus_return_hyperlink_from_message with strange signature %s", signature);
+ }
+ dbus_message_unref (message);
+ return retval;
+}
+
+AtspiHyperlink *
+_atspi_dbus_return_hyperlink_from_iter (DBusMessageIter *iter)
{
- const char *app = (ref->name && ref->name[0]? ref->name: obj->app->bus_name);
- return ref_accessible (app, obj->path);
+ const char *app_name, *path;
+
+ get_reference_from_iter (iter, &app_name, &path);
+ return ref_hyperlink (app_name, path);
}
const char *cache_signal_type = "((so)(so)(so)a(so)assusau)";
@@ -829,37 +871,17 @@ atspi_exit (void)
return leaked;
}
-static AtspiAccessible *
-_atspi_dbus_get_remote_object (gpointer obj,
- const char *interface,
- const char *method,
- GError **error,
- const char *type,
- va_list args)
-{
- DBusMessage *reply;
-
- reply = _atspi_dbus_call_partial_va (obj, interface, method, error, type, args);
- if (!reply)
- return NULL;
-
- return _atspi_dbus_return_accessible_from_message (reply);
-}
-
dbus_bool_t
_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);
+ AtspiObject *aobj = ATSPI_OBJECT (obj);
va_start (args, type);
- if (!strcmp (type + strcspn (type, "="), "=>(so)"))
- return _atspi_dbus_get_remote_object (obj, interface, method, error, type, args);
-
dbus_error_init (&err);
- retval = dbind_method_call_reentrant_va (_atspi_bus(), accessible->app->bus_name, accessible->path, interface, method, &err, type, args);
+ retval = dbind_method_call_reentrant_va (_atspi_bus(), aobj->app->bus_name, aobj->path, interface, method, &err, type, args);
va_end (args);
if (dbus_error_is_set (&err))
{
@@ -890,7 +912,7 @@ _atspi_dbus_call_partial_va (gpointer obj,
const char *type,
va_list args)
{
- AtspiAccessible *accessible = ATSPI_ACCESSIBLE (obj);
+ AtspiObject *aobj = ATSPI_OBJECT (obj);
dbus_bool_t retval;
DBusError err;
DBusMessage *msg = NULL, *reply = NULL;
@@ -899,7 +921,7 @@ _atspi_dbus_call_partial_va (gpointer obj,
dbus_error_init (&err);
- msg = dbus_message_new_method_call (accessible->app->bus_name, accessible->path, interface, method);
+ msg = dbus_message_new_method_call (aobj->app->bus_name, aobj->path, interface, method);
if (!msg)
goto out;
@@ -925,13 +947,13 @@ _atspi_dbus_get_property (gpointer obj, const char *interface, const char *name,
DBusMessageIter iter, iter_variant;
DBusError err;
dbus_bool_t retval = FALSE;
- AtspiAccessible *accessible = ATSPI_ACCESSIBLE (obj);
+ AtspiObject *aobj = ATSPI_OBJECT (obj);
- if (!accessible)
+ if (!aobj)
return NULL;
- message = dbus_message_new_method_call (accessible->app->bus_name,
- accessible->path,
+ message = dbus_message_new_method_call (aobj->app->bus_name,
+ aobj->path,
"org.freedesktop.DBus.Properties",
"Get");
if (!message)
diff --git a/atspi/atspi-object.c b/atspi/atspi-object.c
new file mode 100644
index 0000000..f69d350
--- /dev/null
+++ b/atspi/atspi-object.c
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+#include "atspi-private.h"
+
+G_DEFINE_TYPE (AtspiObject, atspi_object, G_TYPE_OBJECT)
+
+static void
+atspi_object_init (AtspiObject *obj)
+{
+}
+
+static void
+atspi_object_finalize (GObject *obj)
+{
+ AtspiObject *aobj = ATSPI_OBJECT (obj);
+
+ if (aobj->app)
+ g_object_unref (aobj->app);
+
+ g_free (aobj->path);
+}
+
+static void
+atspi_object_class_init (AtspiObjectClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = atspi_object_finalize;
+}
diff --git a/atspi/atspi-object.h b/atspi/atspi-object.h
new file mode 100644
index 0000000..b4dfa1f
--- /dev/null
+++ b/atspi/atspi-object.h
@@ -0,0 +1,55 @@
+/*
+ * 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_OBJECT_H_
+#define _ATSPI_OBJECT_H_
+
+#include "glib-object.h"
+
+#include "atspi-application.h"
+#include "atspi-types.h"
+
+#define ATSPI_TYPE_OBJECT (atspi_object_get_type ())
+#define ATSPI_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATSPI_TYPE_OBJECT, AtspiObject))
+#define ATSPI_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATSPI_TYPE_OBJECT, AtspiObjectClass))
+#define ATSPI_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATSPI_TYPE_OBJECT))
+#define ATSPI_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATSPI_TYPE_OBJECT))
+#define ATSPI_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATSPI_TYPE_OBJECT, AtspiObjectClass))
+
+typedef struct _AtspiObject AtspiObject;
+struct _AtspiObject
+{
+ GObject parent;
+ AtspiApplication *app;
+ char *path;
+};
+
+typedef struct _AtspiObjectClass AtspiObjectClass;
+struct _AtspiObjectClass
+{
+ GObjectClass parent_class;
+};
+
+GType atspi_object_get_type (void);
+#endif /* _ATSPI_OBJECT_H_ */
diff --git a/atspi/atspi-table.c b/atspi/atspi-table.c
index 08c6aef..03524a7 100644
--- a/atspi/atspi-table.c
+++ b/atspi/atspi-table.c
@@ -344,13 +344,13 @@ atspi_table_get_row_header (AtspiTable *obj,
GError **error)
{
dbus_int32_t d_row = row;
- AtspiAccessible *retval = NULL;
+ DBusMessage *reply;
g_return_val_if_fail (obj != NULL, NULL);
- !_atspi_dbus_call (obj, atspi_interface_table, "GetRowHeader", error, "i=>(so)", d_row, &retval);
+ reply = !_atspi_dbus_call (obj, atspi_interface_table, "GetRowHeader", error, "i", d_row);
- return retval;
+ return _atspi_dbus_return_accessible_from_message (reply);
}
/**
@@ -370,13 +370,13 @@ atspi_table_get_column_header (AtspiTable *obj,
GError **error)
{
dbus_int32_t d_column = column;
- AtspiAccessible *retval = NULL;
+ DBusMessage *reply;
g_return_val_if_fail (obj != NULL, NULL);
- !_atspi_dbus_call (obj, atspi_interface_table, "GetColumnHeader", error, "i=>(so)", d_column, &retval);
+ reply = !_atspi_dbus_call (obj, atspi_interface_table, "GetCoumnHeader", error, "i", d_column);
- return retval;
+ return _atspi_dbus_return_accessible_from_message (reply);
}
/**
diff --git a/atspi/atspi-text.c b/atspi/atspi-text.c
index 914bee9..dcc0009 100644
--- a/atspi/atspi-text.c
+++ b/atspi/atspi-text.c
@@ -23,7 +23,7 @@
#include "atspi-private.h"
-static AtspiRange *
+AtspiRange *
atspi_range_copy (AtspiRange *src)
{
AtspiRange *dst = g_new (AtspiRange, 1);
diff --git a/atspi/atspi-text.h b/atspi/atspi-text.h
index 25c2ae5..4062950 100644
--- a/atspi/atspi-text.h
+++ b/atspi/atspi-text.h
@@ -47,6 +47,9 @@ struct _AtspiRange
GType atspi_range_get_type ();
+AtspiRange *
+atspi_range_copy (AtspiRange *src);
+
typedef struct _AtspiRangedAttributeSet AtspiRangedAttributeSet;
struct _AtspiRangedAttributeSet
{
diff --git a/atspi/atspi-types.h b/atspi/atspi-types.h
index b34f264..6769935 100644
--- a/atspi/atspi-types.h
+++ b/atspi/atspi-types.h
@@ -35,7 +35,7 @@ typedef struct _AtspiAccessible AtspiCollection;
typedef struct _AtspiComponent AtspiComponent;
typedef struct _AtspiDocument AtspiDocument;
typedef struct _AtspiEditableText AtspiEditableText;
-typedef struct _AtspiAccessible AtspiHypertext;
+typedef struct _AtspiHypertext AtspiHypertext;
typedef struct _AtspiImage AtspiImage;
typedef struct _AtspiSelection AtspiSelection;
typedef struct _AtspiTable AtspiTable;
diff --git a/atspi/atspi.h b/atspi/atspi.h
index a306ed2..18cbdd7 100644
--- a/atspi/atspi.h
+++ b/atspi/atspi.h
@@ -35,6 +35,8 @@
#include "atspi-document.h"
#include "atspi-editabletext.h"
#include "atspi-event-listener.h"
+#include "atspi-hyperlink.h"
+#include "atspi-hypertext.h"
#include "atspi-image.h"
#include "atspi-misc.h"
#include "atspi-registry.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]