X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=libspi%2Fcomponent.c;h=2b4e1488cde14706164fe827d4e181f4b31333a1;hb=f546ac72097fabd106a0cf277d4db389b811014c;hp=c035bed1735611553b5fa272c355c0340e16dbee;hpb=11518985294fd3a6847eac04c2dbde88f8e0d8b1;p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git diff --git a/libspi/component.c b/libspi/component.c index c035bed..2b4e148 100644 --- a/libspi/component.c +++ b/libspi/component.c @@ -20,35 +20,18 @@ * Boston, MA 02111-1307, USA. */ -/* - * component.c : bonobo wrapper for accessible component implementation - * - */ -#include -#include +/* component.c : implements the Component interface */ +#include #include +#include +#include -/* - * This pulls the CORBA definitions for the "Accessibility::Accessible" server - */ -#include - -/* - * This pulls the definition for the BonoboObject (Gtk Type) - */ -#include "component.h" -#include "accessible.h" - -/* - * Our parent Gtk object type - */ -#define PARENT_TYPE BONOBO_OBJECT_TYPE +/* Our parent Gtk object type */ +#define PARENT_TYPE BONOBO_TYPE_OBJECT -/* - * A pointer to our parent object class - */ -static GObjectClass *component_parent_class; +/* A pointer to our parent object class */ +static GObjectClass *spi_component_parent_class; /* * Implemented GObject::finalize @@ -56,13 +39,14 @@ static GObjectClass *component_parent_class; static void accessibility_component_object_finalize (GObject *object) { - Component *component = COMPONENT (object); + SpiComponent *component = SPI_COMPONENT (object); - printf("accessible_component_object_finalize called\n"); - component->atko = NULL; + printf("spi_accessible_component_object_finalize called\n"); + g_object_unref (component->atko); + component->atko = NULL; - printf("atko freed, calling parent finalize\n"); - component_parent_class->finalize (object); + printf("component atko freed, calling parent finalize\n"); + spi_component_parent_class->finalize (object); } /* @@ -76,10 +60,15 @@ impl_accessibility_component_contains (PortableServer_Servant servant, CORBA_Environment *ev) { CORBA_boolean retval; - Component *component = COMPONENT (bonobo_object_from_servant (servant)); + BonoboObject *obj; + SpiComponent *component; + + obj = bonobo_object_from_servant (servant); + g_return_val_if_fail (IS_SPI_COMPONENT(obj), FALSE); + component = SPI_COMPONENT (obj); + g_return_val_if_fail (ATK_IS_COMPONENT(component->atko), FALSE); retval = atk_component_contains (ATK_COMPONENT (component->atko), (gint) x, (gint) y, (AtkCoordType) coord_type); - fprintf (stderr, "Component contains() called: %s\n", retval ? "true" : "false" ); return retval; } @@ -93,14 +82,21 @@ impl_accessibility_component_get_accessible_at_point (PortableServer_Servant ser CORBA_short coord_type, CORBA_Environment *ev) { + BonoboObject *obj; + SpiComponent *component; Accessibility_Accessible retval; - Component *component = COMPONENT (bonobo_object_from_servant (servant)); AtkObject *child; + + obj = bonobo_object_from_servant (servant); + g_return_val_if_fail (IS_SPI_COMPONENT(obj), CORBA_OBJECT_NIL); + component = SPI_COMPONENT (obj); + g_return_val_if_fail (ATK_IS_COMPONENT(component->atko), CORBA_OBJECT_NIL); + child = atk_component_ref_accessible_at_point (ATK_COMPONENT (component->atko), (gint) x, (gint) y, (AtkCoordType) coord_type); - retval = bonobo_object_corba_objref (bonobo_object (accessible_new (child))); - return retval; + retval = bonobo_object_corba_objref (bonobo_object (spi_accessible_new (child))); + return CORBA_Object_duplicate (retval, ev); } /* @@ -115,8 +111,15 @@ impl_accessibility_component_get_extents (PortableServer_Servant servant, const CORBA_short coord_type, CORBA_Environment *ev) { - Component *component = COMPONENT (bonobo_object_from_servant (servant)); + BonoboObject *obj; + SpiComponent *component; gint ix, iy, iw, ih; + + obj = bonobo_object_from_servant (servant); + g_return_if_fail (IS_SPI_COMPONENT(obj)); + component = SPI_COMPONENT (obj); + g_return_if_fail (ATK_IS_COMPONENT (component->atko)); + atk_component_get_extents (ATK_COMPONENT (component->atko), &ix, &iy, &iw, &ih, (AtkCoordType) coord_type); *x = (CORBA_long) ix; @@ -135,8 +138,14 @@ impl_accessibility_component_get_position (PortableServer_Servant servant, const CORBA_short coord_type, CORBA_Environment *ev) { - Component *component = COMPONENT (bonobo_object_from_servant (servant)); + BonoboObject *obj = bonobo_object_from_servant (servant); + SpiComponent *component; gint ix, iy; + + g_return_if_fail (IS_SPI_COMPONENT(obj)); + component = SPI_COMPONENT(obj); + g_return_if_fail (ATK_IS_COMPONENT(component->atko)); + atk_component_get_position (ATK_COMPONENT (component->atko), &ix, &iy, (AtkCoordType) coord_type); *x = (CORBA_long) ix; @@ -152,19 +161,24 @@ impl_accessibility_component_get_size (PortableServer_Servant servant, CORBA_long * height, CORBA_Environment *ev) { - Component *component = COMPONENT (bonobo_object_from_servant (servant)); + SpiComponent *component; + BonoboObject *obj = bonobo_object_from_servant (servant); gint iw, ih; + + g_return_if_fail (IS_SPI_COMPONENT(obj)); + component = SPI_COMPONENT(obj); + g_return_if_fail (ATK_IS_COMPONENT(component->atko)); atk_component_get_size (ATK_COMPONENT (component->atko), &iw, &ih); *width = (CORBA_long) iw; *height = (CORBA_long) ih; } static void -accessibility_component_class_init (ComponentClass *klass) +spi_component_class_init (SpiComponentClass *klass) { GObjectClass * object_class = (GObjectClass *) klass; POA_Accessibility_Component__epv *epv = &klass->epv; - component_parent_class = g_type_class_peek_parent (klass); + spi_component_parent_class = g_type_class_peek_parent (klass); object_class->finalize = accessibility_component_object_finalize; @@ -176,51 +190,21 @@ accessibility_component_class_init (ComponentClass *klass) } static void -accessibility_component_init (Component *component) +spi_component_init (SpiComponent *component) { } -GType -accessibility_component_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo tinfo = { - sizeof (ComponentClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) accessibility_component_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class data */ - sizeof (Component), - 0, /* n preallocs */ - (GInstanceInitFunc) accessibility_component_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 ( - PARENT_TYPE, - POA_Accessibility_Component__init, - NULL, - G_STRUCT_OFFSET (ComponentClass, epv), - &tinfo, - "AccessibleComponent"); - } - - return type; -} +BONOBO_TYPE_FUNC_FULL (SpiComponent, + Accessibility_Component, + PARENT_TYPE, + spi_component); -Component * -component_interface_new (AtkObject *o) +SpiComponent * +spi_component_interface_new (AtkObject *o) { - Component *retval = - COMPONENT (g_object_new (accessibility_component_get_type (), NULL)); - /* don't increment AtkObject refcount, ref is held by containing Accessible instance */ - retval->atko = ATK_OBJECT (o); + SpiComponent *retval = + SPI_COMPONENT (g_object_new (SPI_COMPONENT_TYPE, NULL)); + retval->atko = o; + g_object_ref (o); return retval; }