* AT-SPI - Assistive Technology Service Provider Interface
* (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
*
- * Copyright 2001 Sun Microsystems Inc.
+ * Copyright 2001 Sun Microsystems Inc, Ximian Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
#include <config.h>
#include <stdio.h>
+#include <atk/atkhypertext.h>
#include <libspi/hyperlink.h>
#include <libspi/hypertext.h>
-/* Static function declarations */
-
-static void
-spi_hypertext_class_init (SpiHypertextClass *klass);
-static void
-spi_hypertext_init (SpiHypertext *hypertext);
-static void
-spi_hypertext_finalize (GObject *obj);
-static CORBA_short
-impl__get_n_anchors (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static CORBA_string
-impl__get_uri (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static CORBA_long
-impl__get_startIndex (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static CORBA_long
-impl__get_endIndex (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static Accessibility_Accessible
-impl_getAnchor (PortableServer_Servant _servant,
- const CORBA_long i,
- CORBA_Environment * ev);
-static Accessibility_Accessible
-impl_getObject (PortableServer_Servant _servant,
- const CORBA_long i,
- CORBA_Environment * ev);
-static CORBA_long
-impl_getNLinks (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static Accessibility_Hyperlink
-impl_getLink (PortableServer_Servant _servant,
- const CORBA_long linkIndex,
- CORBA_Environment * ev);
-static CORBA_long
-impl_getLinkIndex (PortableServer_Servant _servant,
- const CORBA_long characterIndex,
- CORBA_Environment * ev);
-
-static GObjectClass *parent_class;
-
-GType
-spi_hypertext_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo tinfo = {
- sizeof (SpiHypertextClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) spi_hypertext_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class data */
- sizeof (SpiHypertext),
- 0, /* n preallocs */
- (GInstanceInitFunc) spi_hypertext_init,
- NULL /* value table */
- };
-
- /*
- * Bonobo_type_unique auto-generates a load of
- * CORBA structures for us. All derived types must
- * use bonobo_type_unique.
- */
- type = bonobo_type_unique (
- BONOBO_TYPE_OBJECT,
- POA_Accessibility_Hypertext__init,
- NULL,
- G_STRUCT_OFFSET (SpiHypertextClass, epv),
- &tinfo,
- "SpiAccessibleHypertext");
- }
-
- return type;
-}
-
-static void
-spi_hypertext_class_init (SpiHypertextClass *klass)
+SpiHypertext *
+spi_hypertext_interface_new (AtkObject *obj)
{
- GObjectClass * object_class = (GObjectClass *) klass;
- POA_Accessibility_Hypertext__epv *epv = &klass->epv;
- parent_class = g_type_class_peek_parent (klass);
+ SpiHypertext *new_hypertext = g_object_new (SPI_HYPERTEXT_TYPE, NULL);
- object_class->finalize = spi_hypertext_finalize;
-
- /* Initialize epv table */
+ spi_text_construct (SPI_TEXT (new_hypertext), obj);
- epv->getNLinks = impl_getNLinks;
- epv->getLink = impl_getLink;
- epv->getLinkIndex = impl_getLinkIndex;
+ return new_hypertext;
}
-static void
-spi_hypertext_init (SpiHypertext *hypertext)
-{
-}
-static void
-spi_hypertext_finalize (GObject *obj)
+static AtkHypertext *
+get_hypertext_from_servant (PortableServer_Servant servant)
{
- SpiHypertext *hypertext = SPI_HYPERTEXT(obj);
- g_object_unref (hypertext->atko);
- hypertext->atko = NULL;
- parent_class->finalize (obj);
-}
+ SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
-SpiHypertext *
-spi_hypertext_interface_new (AtkObject *obj)
-{
- SpiHypertext *new_hypertext =
- SPI_HYPERTEXT(g_object_new (SPI_HYPERTEXT_TYPE, NULL));
- new_hypertext->atko = obj;
- g_object_ref (obj);
- return new_hypertext;
-}
+ if (!object)
+ {
+ return NULL;
+ }
+ return ATK_HYPERTEXT (object->atko);
+}
static CORBA_long
-impl_getNLinks (PortableServer_Servant _servant,
- CORBA_Environment * ev)
+impl_getNLinks (PortableServer_Servant servant,
+ CORBA_Environment *ev)
{
- SpiHypertext *hypertext = SPI_HYPERTEXT(bonobo_object_from_servant(_servant));
- return (CORBA_long)
- atk_hypertext_get_n_links (ATK_HYPERTEXT(hypertext->atko));
-}
+ AtkHypertext *hypertext = get_hypertext_from_servant (servant);
+
+ g_return_val_if_fail (hypertext != NULL, 0);
+ return (CORBA_long) atk_hypertext_get_n_links (hypertext);
+}
static Accessibility_Hyperlink
CORBA_Environment *ev)
{
AtkHyperlink *link;
- SpiHypertext *hypertext;
Accessibility_Hyperlink rv;
-
- hypertext = SPI_HYPERTEXT (bonobo_object_from_servant (servant));
+ AtkHypertext *hypertext = get_hypertext_from_servant (servant);
- link = atk_hypertext_get_link (
- ATK_HYPERTEXT (hypertext->atko), linkIndex);
+ g_return_val_if_fail (hypertext != NULL, CORBA_OBJECT_NIL);
+
+ link = atk_hypertext_get_link (hypertext, linkIndex);
+ g_return_val_if_fail (link != NULL, CORBA_OBJECT_NIL);
- rv = bonobo_object_corba_objref (BONOBO_OBJECT (
- spi_hyperlink_new (ATK_OBJECT (link))));
+ rv = BONOBO_OBJREF (spi_hyperlink_new (ATK_OBJECT (link)));
- return rv;
+ return CORBA_Object_duplicate (rv, ev);
}
-
static CORBA_long
-impl_getLinkIndex (PortableServer_Servant _servant,
- const CORBA_long characterIndex,
- CORBA_Environment * ev)
+impl_getLinkIndex (PortableServer_Servant servant,
+ const CORBA_long characterIndex,
+ CORBA_Environment *ev)
{
- SpiHypertext *hypertext = SPI_HYPERTEXT(bonobo_object_from_servant(_servant));
+ AtkHypertext *hypertext = get_hypertext_from_servant (servant);
+
+ g_return_val_if_fail (hypertext != NULL, 0);
+
return (CORBA_long)
- atk_hypertext_get_link_index (ATK_HYPERTEXT(hypertext->atko),
+ atk_hypertext_get_link_index (hypertext,
(gint) characterIndex);
}
+
+static void
+spi_hypertext_class_init (SpiHypertextClass *klass)
+{
+ POA_Accessibility_Hypertext__epv *epv = &klass->epv;
+
+ /* Initialize epv table */
+
+ epv->getNLinks = impl_getNLinks;
+ epv->getLink = impl_getLink;
+ epv->getLinkIndex = impl_getLinkIndex;
+}
+
+
+static void
+spi_hypertext_init (SpiHypertext *hypertext)
+{
+}
+
+
+BONOBO_TYPE_FUNC_FULL (SpiHypertext,
+ Accessibility_Hypertext,
+ BONOBO_TYPE_OBJECT,
+ spi_hypertext);