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 /* Static function declarations */
31 spi_value_class_init (SpiValueClass *klass);
33 spi_value_init (SpiValue *value);
35 impl__get_minimumValue (PortableServer_Servant _servant,
36 CORBA_Environment * ev);
38 impl__get_maximumValue (PortableServer_Servant _servant,
39 CORBA_Environment * ev);
41 impl__get_currentValue (PortableServer_Servant _servant,
42 CORBA_Environment * ev);
44 impl__set_currentValue (PortableServer_Servant _servant,
45 const CORBA_float value,
46 CORBA_Environment * ev);
49 BONOBO_TYPE_FUNC_FULL (SpiValue,
56 spi_value_class_init (SpiValueClass *klass)
58 POA_Accessibility_Value__epv *epv = &klass->epv;
60 /* Initialize epv table */
62 epv->_get_minimumValue = impl__get_minimumValue;
63 epv->_get_maximumValue = impl__get_maximumValue;
64 epv->_get_currentValue = impl__get_currentValue;
65 epv->_set_currentValue = impl__set_currentValue;
70 spi_value_init (SpiValue *value)
76 spi_value_interface_new (AtkObject *obj)
78 SpiValue *new_value = g_object_new (SPI_VALUE_TYPE, NULL);
80 spi_base_construct (SPI_BASE (new_value), obj);
87 get_value_from_servant (PortableServer_Servant servant)
89 SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
96 return ATK_VALUE (object->atko);
101 impl__get_minimumValue (PortableServer_Servant servant,
102 CORBA_Environment *ev)
104 GValue gvalue = {0, };
105 AtkValue *value = get_value_from_servant (servant);
107 g_return_val_if_fail (value != NULL, 0.0);
109 g_value_init (&gvalue, G_TYPE_FLOAT);
110 atk_value_get_minimum_value (value, &gvalue);
112 return (CORBA_float) g_value_get_float (&gvalue);
117 impl__get_maximumValue (PortableServer_Servant servant,
118 CORBA_Environment *ev)
120 GValue gvalue = {0, };
121 AtkValue *value = get_value_from_servant (servant);
123 g_return_val_if_fail (value != NULL, 0.0);
125 g_value_init (&gvalue, G_TYPE_FLOAT);
126 atk_value_get_maximum_value (value, &gvalue);
128 return (CORBA_float) g_value_get_float (&gvalue);
133 impl__get_currentValue (PortableServer_Servant servant,
134 CORBA_Environment *ev)
136 GValue gvalue = {0, };
137 AtkValue *value = get_value_from_servant (servant);
139 g_return_val_if_fail (value != NULL, 0.0);
141 g_value_init (&gvalue, G_TYPE_FLOAT);
142 atk_value_get_current_value (value, &gvalue);
144 return (CORBA_float) g_value_get_float (&gvalue);
149 impl__set_currentValue (PortableServer_Servant servant,
150 const CORBA_float value,
151 CORBA_Environment *ev)
153 GValue gvalue = {0, };
154 AtkValue *avalue = get_value_from_servant (servant);
156 g_return_if_fail (avalue != NULL);
158 g_value_init (&gvalue, G_TYPE_FLOAT);
159 g_value_set_float (&gvalue, (gfloat) value);
161 atk_value_set_current_value (avalue, &gvalue);