* 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 GObjectClass *parent_class;
-
-static void
-spi_hypertext_finalize (GObject *obj)
-{
- parent_class->finalize (obj);
-}
+#define PARENT_TYPE SPI_TYPE_BASE
SpiHypertext *
spi_hypertext_interface_new (AtkObject *obj)
{
SpiHypertext *new_hypertext = g_object_new (SPI_HYPERTEXT_TYPE, NULL);
- (SPI_TEXT (new_hypertext))->atko = obj;
- g_object_ref (obj);
+
+ spi_base_construct (SPI_BASE (new_hypertext), G_OBJECT (obj));
+
return new_hypertext;
}
+static AtkHypertext *
+get_hypertext_from_servant (PortableServer_Servant servant)
+{
+ SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
+
+ g_return_val_if_fail (object, NULL);
+ g_return_val_if_fail (ATK_IS_OBJECT(object->gobj), NULL);
+ return ATK_HYPERTEXT (object->gobj);
+}
+
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 ((SPI_TEXT (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 ((SPI_TEXT (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 ((SPI_TEXT (hypertext))->atko),
+ atk_hypertext_get_link_index (hypertext,
(gint) characterIndex);
}
+
static void
spi_hypertext_class_init (SpiHypertextClass *klass)
{
- GObjectClass * object_class = (GObjectClass *) klass;
POA_Accessibility_Hypertext__epv *epv = &klass->epv;
- parent_class = g_type_class_peek_parent (klass);
-
- object_class->finalize = spi_hypertext_finalize;
/* Initialize epv table */
epv->getLinkIndex = impl_getLinkIndex;
}
+
static void
spi_hypertext_init (SpiHypertext *hypertext)
{
}
+
BONOBO_TYPE_FUNC_FULL (SpiHypertext,
Accessibility_Hypertext,
- BONOBO_TYPE_OBJECT,
+ PARENT_TYPE,
spi_hypertext);