2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001 Sun Microsystems Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 /* value.c : implements the Value interface */
26 #include <libspi/value.h>
28 #define PARENT_TYPE SPI_TYPE_BASE
30 /* Static function declarations */
33 spi_value_class_init (SpiValueClass *klass);
35 spi_value_init (SpiValue *value);
37 impl__get_minimumValue (PortableServer_Servant _servant,
38 CORBA_Environment * ev);
40 impl__get_maximumValue (PortableServer_Servant _servant,
41 CORBA_Environment * ev);
43 impl__get_currentValue (PortableServer_Servant _servant,
44 CORBA_Environment * ev);
46 impl__set_currentValue (PortableServer_Servant _servant,
47 const CORBA_float value,
48 CORBA_Environment * ev);
51 BONOBO_TYPE_FUNC_FULL (SpiValue,
58 spi_value_class_init (SpiValueClass *klass)
60 POA_Accessibility_Value__epv *epv = &klass->epv;
62 /* Initialize epv table */
64 epv->_get_minimumValue = impl__get_minimumValue;
65 epv->_get_maximumValue = impl__get_maximumValue;
66 epv->_get_currentValue = impl__get_currentValue;
67 epv->_set_currentValue = impl__set_currentValue;
72 spi_value_init (SpiValue *value)
78 spi_value_interface_new (AtkObject *obj)
80 SpiValue *new_value = g_object_new (SPI_VALUE_TYPE, NULL);
82 spi_base_construct (SPI_BASE (new_value), obj);
89 get_value_from_servant (PortableServer_Servant servant)
91 SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
98 return ATK_VALUE (object->atko);
103 impl__get_minimumValue (PortableServer_Servant servant,
104 CORBA_Environment *ev)
106 GValue gvalue = {0, };
107 AtkValue *value = get_value_from_servant (servant);
109 g_return_val_if_fail (value != NULL, 0.0);
112 * FIXME: ahem, there's no guarantee that
113 * atk_value_get_minimum_value returns a float.
114 * What we really need is a generic value API here
117 g_value_init (&gvalue, G_TYPE_DOUBLE);
118 atk_value_get_minimum_value (value, &gvalue);
120 return (CORBA_float) g_value_get_double (&gvalue);
125 impl__get_maximumValue (PortableServer_Servant servant,
126 CORBA_Environment *ev)
128 GValue gvalue = {0, };
129 AtkValue *value = get_value_from_servant (servant);
131 g_return_val_if_fail (value != NULL, 0.0);
133 g_value_init (&gvalue, G_TYPE_DOUBLE);
134 atk_value_get_maximum_value (value, &gvalue);
136 return (CORBA_float) g_value_get_double (&gvalue);
141 impl__get_currentValue (PortableServer_Servant servant,
142 CORBA_Environment *ev)
144 GValue gvalue = {0, };
145 AtkValue *value = get_value_from_servant (servant);
147 g_return_val_if_fail (value != NULL, 0.0);
149 g_value_init (&gvalue, G_TYPE_DOUBLE);
150 atk_value_get_current_value (value, &gvalue);
152 return (CORBA_float) g_value_get_double (&gvalue);
157 impl__set_currentValue (PortableServer_Servant servant,
158 const CORBA_float value,
159 CORBA_Environment *ev)
161 GValue gvalue = {0, };
162 AtkValue *avalue = get_value_from_servant (servant);
164 g_return_if_fail (avalue != NULL);
166 g_value_init (&gvalue, G_TYPE_DOUBLE);
167 g_value_set_float (&gvalue, (gdouble) value);
169 atk_value_set_current_value (avalue, &gvalue);