* Boston, MA 02111-1307, USA.
*/
-/*
- * component.c : bonobo wrapper for accessible component implementation
- *
- */
+/* value.c : implements the Value interface */
#include <config.h>
-#include <bonobo/Bonobo.h>
-
#include <stdio.h>
+#include <libspi/value.h>
-/*
- * This pulls the CORBA definitions for the "Accessibility::Accessible" server
- */
-#include <libspi/Accessibility.h>
-
-/*
- * This pulls the definition of the Value bonobo object
- */
-#include "value.h"
+#define PARENT_TYPE SPI_TYPE_BASE
-/*
- * Static function declarations
- */
+/* Static function declarations */
static void
-value_class_init (ValueClass *klass);
-static void
-value_init (Value *value);
+spi_value_class_init (SpiValueClass *klass);
static void
-value_finalize (GObject *obj);
+spi_value_init (SpiValue *value);
static CORBA_float
impl__get_minimumValue (PortableServer_Servant _servant,
CORBA_Environment * ev);
CORBA_Environment * ev);
+BONOBO_TYPE_FUNC_FULL (SpiValue,
+ Accessibility_Value,
+ PARENT_TYPE,
+ spi_value);
-static GObjectClass *parent_class;
-
-
-GType
-value_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo tinfo = {
- sizeof (ValueClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) value_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class data */
- sizeof (Value),
- 0, /* n preallocs */
- (GInstanceInitFunc) 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 (ValueClass, epv),
- &tinfo,
- "AccessibleValue");
- }
-
- return type;
-}
static void
-value_class_init (ValueClass *klass)
+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 = value_finalize;
-
/* Initialize epv table */
epv->_set_currentValue = impl__set_currentValue;
}
-static void
-value_init (Value *value)
-{
-}
static void
-value_finalize (GObject *obj)
+spi_value_init (SpiValue *value)
{
- Value *value = VALUE (obj);
- value->atk_value = NULL;
- parent_class->finalize (obj);
}
-Value *
-value_new (AtkValue *value)
+
+SpiValue *
+spi_value_interface_new (AtkObject *obj)
{
- Value *new_value =
- VALUE(g_object_new (VALUE_TYPE, NULL));
- new_value->atk_value = value;
+ 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)
{
- Value *value = VALUE (bonobo_object_from_servant (_servant));
- GValue gvalue = {0, };
+ GValue gvalue = {0, };
+ AtkValue *value = get_value_from_servant (servant);
- g_value_init (&gvalue, G_TYPE_FLOAT);
- atk_value_get_minimum_value (value->atk_value, &gvalue);
- return (CORBA_float) g_value_get_float (&gvalue);
-}
+ 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_DOUBLE);
+ atk_value_get_minimum_value (value, &gvalue);
-static CORBA_float
-impl__get_maximumValue (PortableServer_Servant _servant,
- CORBA_Environment * ev)
+ return (CORBA_float) g_value_get_double (&gvalue);
+}
+
+
+static CORBA_float
+impl__get_maximumValue (PortableServer_Servant servant,
+ CORBA_Environment *ev)
{
- Value *value = VALUE (bonobo_object_from_servant (_servant));
- GValue gvalue = {0, };
+ GValue gvalue = {0, };
+ AtkValue *value = get_value_from_servant (servant);
- g_value_init (&gvalue, G_TYPE_FLOAT);
- atk_value_get_maximum_value (value->atk_value, &gvalue);
- return (CORBA_float) g_value_get_float (&gvalue);
-}
+ g_return_val_if_fail (value != NULL, 0.0);
+
+ g_value_init (&gvalue, G_TYPE_DOUBLE);
+ atk_value_get_maximum_value (value, &gvalue);
+ return (CORBA_float) g_value_get_double (&gvalue);
+}
static CORBA_float
-impl__get_currentValue (PortableServer_Servant _servant,
- CORBA_Environment * ev)
+impl__get_currentValue (PortableServer_Servant servant,
+ CORBA_Environment *ev)
{
- Value *value = 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 (value->atk_value, &gvalue);
- return (CORBA_float) g_value_get_float (&gvalue);
+ g_value_init (&gvalue, G_TYPE_DOUBLE);
+ atk_value_get_current_value (value, &gvalue);
+
+ return (CORBA_float) g_value_get_double (&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)
{
- Value *val = 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_DOUBLE);
+ g_value_set_float (&gvalue, (gdouble) value);
- g_value_init (&gvalue, G_TYPE_FLOAT);
- g_value_set_float (&gvalue, (gfloat) value);
- atk_value_set_current_value (val->atk_value, &gvalue);
+ atk_value_set_current_value (avalue, &gvalue);
}