X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=libspi%2Fhypertext.c;h=c1861350dc5277eb6d57e8fdc55f6b4a22b71549;hb=ebd9b297363b8b3bd6708e6f0c6c7673e5cc32d6;hp=82f58a7f9e5b6029d3532efafc828b3d81ce689f;hpb=e07aeb10fff4c7802393f5cbe8460d1097cbec18;p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git diff --git a/libspi/hypertext.c b/libspi/hypertext.c index 82f58a7..c186135 100644 --- a/libspi/hypertext.c +++ b/libspi/hypertext.c @@ -2,7 +2,7 @@ * 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 @@ -20,181 +20,105 @@ * Boston, MA 02111-1307, USA. */ -/* - * component.c : bonobo wrapper for accessible component implementation - * - */ -#include -#include +/* hypertext.c : implements the HyperText interface */ +#include #include +#include +#include +#include -/* - * This pulls the CORBA definitions for the "Accessibility::Accessible" server - */ -#include +#define PARENT_TYPE SPI_TYPE_BASE -/* - * This pulls the definition of the hypertext bonobo object - */ -#include "hypertext.h" +SpiHypertext * +spi_hypertext_interface_new (AtkObject *obj) +{ + SpiHypertext *new_hypertext = g_object_new (SPI_HYPERTEXT_TYPE, NULL); -/* - * Static function declarations - */ + spi_base_construct (SPI_BASE (new_hypertext), G_OBJECT (obj)); -static void -hypertext_class_init (HypertextClass *klass); -static void -hypertext_init (Hypertext *hypertext); -static void -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); + return new_hypertext; +} -static GObjectClass *parent_class; -GType -hypertext_get_type (void) +static AtkHypertext * +get_hypertext_from_servant (PortableServer_Servant servant) { - static GType type = 0; - - if (!type) { - static const GTypeInfo tinfo = { - sizeof (HypertextClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) hypertext_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class data */ - sizeof (Hypertext), - 0, /* n preallocs */ - (GInstanceInitFunc) 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_OBJECT_TYPE, - POA_Accessibility_Hypertext__init, - NULL, - G_STRUCT_OFFSET (HypertextClass, epv), - &tinfo, - "AccessibleHypertext"); - } - - return type; + 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 void -hypertext_class_init (HypertextClass *klass) -{ - GObjectClass * object_class = (GObjectClass *) klass; - POA_Accessibility_Hypertext__epv *epv = &klass->epv; - parent_class = g_type_class_peek_parent (klass); - object_class->finalize = hypertext_finalize; +static CORBA_long +impl_getNLinks (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + AtkHypertext *hypertext = get_hypertext_from_servant (servant); - /* Initialize epv table */ + g_return_val_if_fail (hypertext != NULL, 0); - epv->getNLinks = impl_getNLinks; - epv->getLink = impl_getLink; - epv->getLinkIndex = impl_getLinkIndex; + return (CORBA_long) atk_hypertext_get_n_links (hypertext); } -static void -hypertext_init (Hypertext *hypertext) -{ -} -static void -hypertext_finalize (GObject *obj) +static Accessibility_Hyperlink +impl_getLink (PortableServer_Servant servant, + const CORBA_long linkIndex, + CORBA_Environment *ev) { - Hypertext *hypertext = HYPERTEXT(obj); - hypertext->atk_hypertext = NULL; - parent_class->finalize (obj); -} + AtkHyperlink *link; + Accessibility_Hyperlink rv; + AtkHypertext *hypertext = get_hypertext_from_servant (servant); -Hypertext * -hypertext_new (AtkHypertext *hypertext) -{ - Hypertext *new_hypertext = - HYPERTEXT(g_object_new (HYPERTEXT_TYPE, NULL)); - new_hypertext->atk_hypertext = hypertext; - return new_hypertext; -} + 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_OBJREF (spi_hyperlink_new (ATK_OBJECT (link))); + return CORBA_Object_duplicate (rv, ev); +} static CORBA_long -impl_getNLinks (PortableServer_Servant _servant, - CORBA_Environment * ev) +impl_getLinkIndex (PortableServer_Servant servant, + const CORBA_long characterIndex, + CORBA_Environment *ev) { - Hypertext *hypertext = 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_n_links (hypertext->atk_hypertext); + atk_hypertext_get_link_index (hypertext, + (gint) characterIndex); } - -static Accessibility_Hyperlink -impl_getLink (PortableServer_Servant _servant, - const CORBA_long linkIndex, - CORBA_Environment * ev) +static void +spi_hypertext_class_init (SpiHypertextClass *klass) { - AtkHyperlink *link; - Hypertext *hypertext = HYPERTEXT(bonobo_object_from_servant(_servant)); - Accessibility_Hyperlink rv; - - link = atk_hypertext_get_link (hypertext->atk_hypertext, - (gint) linkIndex); - rv = bonobo_object_corba_objref (BONOBO_OBJECT(hyperlink_new(link))); - return rv; -} + POA_Accessibility_Hypertext__epv *epv = &klass->epv; + /* Initialize epv table */ + epv->getNLinks = impl_getNLinks; + epv->getLink = impl_getLink; + epv->getLinkIndex = impl_getLinkIndex; +} -static CORBA_long -impl_getLinkIndex (PortableServer_Servant _servant, - const CORBA_long characterIndex, - CORBA_Environment * ev) + +static void +spi_hypertext_init (SpiHypertext *hypertext) { - Hypertext *hypertext = HYPERTEXT(bonobo_object_from_servant(_servant)); - return (CORBA_long) - atk_hypertext_get_link_index (hypertext->atk_hypertext, - (gint) characterIndex); } + +BONOBO_TYPE_FUNC_FULL (SpiHypertext, + Accessibility_Hypertext, + PARENT_TYPE, + spi_hypertext);