X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=libspi%2Fvalue.c;h=16e64fba8398be4485b2d72e438e10b763230d97;hb=68b558bcef701bc71b1b7e53f68935f9c632fcdb;hp=9610701f6229ad730d0665acd82add5b189bc2d8;hpb=66c4375c7cd9a0a01e79f562e1bb0326fc4dcd21;p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git diff --git a/libspi/value.c b/libspi/value.c index 9610701..16e64fb 100644 --- a/libspi/value.c +++ b/libspi/value.c @@ -20,35 +20,19 @@ * Boston, MA 02111-1307, USA. */ -/* - * component.c : bonobo wrapper for accessible component implementation - * - */ +/* value.c : implements the Value interface */ #include -#include - #include +#include -/* - * This pulls the CORBA definitions for the "Accessibility::Accessible" server - */ -#include - -/* - * This pulls the definition of the SpiValue bonobo object - */ -#include "value.h" +#define PARENT_TYPE SPI_TYPE_BASE -/* - * Static function declarations - */ +/* Static function declarations */ static void spi_value_class_init (SpiValueClass *klass); static void spi_value_init (SpiValue *value); -static void -spi_value_finalize (GObject *obj); static CORBA_float impl__get_minimumValue (PortableServer_Servant _servant, CORBA_Environment * ev); @@ -64,55 +48,16 @@ impl__set_currentValue (PortableServer_Servant _servant, CORBA_Environment * ev); +BONOBO_TYPE_FUNC_FULL (SpiValue, + Accessibility_Value, + PARENT_TYPE, + spi_value); -static GObjectClass *parent_class; - - -GType -spi_value_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo tinfo = { - sizeof (SpiValueClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) spi_value_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class data */ - sizeof (SpiValue), - 0, /* n preallocs */ - (GInstanceInitFunc) spi_value_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_Value__init, - NULL, - G_STRUCT_OFFSET (SpiValueClass, epv), - &tinfo, - "SpiAccessibleValue"); - } - - return type; -} static void spi_value_class_init (SpiValueClass *klass) { - GObjectClass * object_class = (GObjectClass *) klass; POA_Accessibility_Value__epv *epv = &klass->epv; - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = spi_value_finalize; - /* Initialize epv table */ @@ -122,84 +67,106 @@ spi_value_class_init (SpiValueClass *klass) epv->_set_currentValue = impl__set_currentValue; } + static void spi_value_init (SpiValue *value) { } -static void -spi_value_finalize (GObject *obj) -{ - SpiValue *value = SPI_VALUE (obj); - g_object_unref (value->atko); - value->atko = NULL; - parent_class->finalize (obj); -} SpiValue * spi_value_interface_new (AtkObject *obj) { - SpiValue *new_value = - SPI_VALUE(g_object_new (SPI_VALUE_TYPE, NULL)); - new_value->atko = obj; - g_object_ref (obj); + SpiValue *new_value = g_object_new (SPI_VALUE_TYPE, NULL); + + spi_base_construct (SPI_BASE (new_value), obj); + return new_value; } +static AtkValue * +get_value_from_servant (PortableServer_Servant servant) +{ + SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant)); + + if (!object) + { + return NULL; + } + + return ATK_VALUE (object->atko); +} + static CORBA_float -impl__get_minimumValue (PortableServer_Servant _servant, - CORBA_Environment * ev) +impl__get_minimumValue (PortableServer_Servant servant, + CORBA_Environment *ev) { - SpiValue *value = SPI_VALUE (bonobo_object_from_servant (_servant)); - GValue gvalue = {0, }; + GValue gvalue = {0, }; + AtkValue *value = get_value_from_servant (servant); + + g_return_val_if_fail (value != NULL, 0.0); + + /* + * FIXME: ahem, there's no guarantee that + * atk_value_get_minimum_value returns a float. + * What we really need is a generic value API here + */ g_value_init (&gvalue, G_TYPE_FLOAT); - atk_value_get_minimum_value (ATK_VALUE(value->atko), &gvalue); + atk_value_get_minimum_value (value, &gvalue); + return (CORBA_float) g_value_get_float (&gvalue); } - -static CORBA_float -impl__get_maximumValue (PortableServer_Servant _servant, - CORBA_Environment * ev) +static CORBA_float +impl__get_maximumValue (PortableServer_Servant servant, + CORBA_Environment *ev) { - SpiValue *value = SPI_VALUE (bonobo_object_from_servant (_servant)); - GValue gvalue = {0, }; + GValue gvalue = {0, }; + AtkValue *value = get_value_from_servant (servant); + + g_return_val_if_fail (value != NULL, 0.0); g_value_init (&gvalue, G_TYPE_FLOAT); - atk_value_get_maximum_value (ATK_VALUE(value->atko), &gvalue); + atk_value_get_maximum_value (value, &gvalue); + return (CORBA_float) g_value_get_float (&gvalue); } - static CORBA_float -impl__get_currentValue (PortableServer_Servant _servant, - CORBA_Environment * ev) +impl__get_currentValue (PortableServer_Servant servant, + CORBA_Environment *ev) { - SpiValue *value = SPI_VALUE (bonobo_object_from_servant (_servant)); - GValue gvalue = {0, }; + GValue gvalue = {0, }; + AtkValue *value = get_value_from_servant (servant); + + g_return_val_if_fail (value != NULL, 0.0); g_value_init (&gvalue, G_TYPE_FLOAT); - atk_value_get_current_value (ATK_VALUE(value->atko), &gvalue); + atk_value_get_current_value (value, &gvalue); + return (CORBA_float) g_value_get_float (&gvalue); } static void -impl__set_currentValue (PortableServer_Servant _servant, - const CORBA_float value, - CORBA_Environment * ev) +impl__set_currentValue (PortableServer_Servant servant, + const CORBA_float value, + CORBA_Environment *ev) { - SpiValue *val = SPI_VALUE (bonobo_object_from_servant (_servant)); - GValue gvalue = {0, }; + GValue gvalue = {0, }; + AtkValue *avalue = get_value_from_servant (servant); + + g_return_if_fail (avalue != NULL); g_value_init (&gvalue, G_TYPE_FLOAT); g_value_set_float (&gvalue, (gfloat) value); - atk_value_set_current_value (ATK_VALUE(val->atko), &gvalue); + + atk_value_set_current_value (avalue, &gvalue); }