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 spi_value_finalize (GObject *obj);
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);
52 static GObjectClass *parent_class;
55 BONOBO_TYPE_FUNC_FULL (SpiValue,
61 spi_value_class_init (SpiValueClass *klass)
63 GObjectClass * object_class = (GObjectClass *) klass;
64 POA_Accessibility_Value__epv *epv = &klass->epv;
65 parent_class = g_type_class_peek_parent (klass);
67 object_class->finalize = spi_value_finalize;
70 /* Initialize epv table */
72 epv->_get_minimumValue = impl__get_minimumValue;
73 epv->_get_maximumValue = impl__get_maximumValue;
74 epv->_get_currentValue = impl__get_currentValue;
75 epv->_set_currentValue = impl__set_currentValue;
79 spi_value_init (SpiValue *value)
84 spi_value_finalize (GObject *obj)
86 SpiValue *value = SPI_VALUE (obj);
87 g_object_unref (value->atko);
89 parent_class->finalize (obj);
93 spi_value_interface_new (AtkObject *obj)
96 SPI_VALUE(g_object_new (SPI_VALUE_TYPE, NULL));
97 new_value->atko = obj;
105 impl__get_minimumValue (PortableServer_Servant _servant,
106 CORBA_Environment * ev)
108 SpiValue *value = SPI_VALUE (bonobo_object_from_servant (_servant));
109 GValue gvalue = {0, };
111 g_value_init (&gvalue, G_TYPE_FLOAT);
112 atk_value_get_minimum_value (ATK_VALUE(value->atko), &gvalue);
113 return (CORBA_float) g_value_get_float (&gvalue);
119 impl__get_maximumValue (PortableServer_Servant _servant,
120 CORBA_Environment * ev)
122 SpiValue *value = SPI_VALUE (bonobo_object_from_servant (_servant));
123 GValue gvalue = {0, };
125 g_value_init (&gvalue, G_TYPE_FLOAT);
126 atk_value_get_maximum_value (ATK_VALUE(value->atko), &gvalue);
127 return (CORBA_float) g_value_get_float (&gvalue);
133 impl__get_currentValue (PortableServer_Servant _servant,
134 CORBA_Environment * ev)
136 SpiValue *value = SPI_VALUE (bonobo_object_from_servant (_servant));
137 GValue gvalue = {0, };
139 g_value_init (&gvalue, G_TYPE_FLOAT);
140 atk_value_get_current_value (ATK_VALUE(value->atko), &gvalue);
141 return (CORBA_float) g_value_get_float (&gvalue);
146 impl__set_currentValue (PortableServer_Servant _servant,
147 const CORBA_float value,
148 CORBA_Environment * ev)
150 SpiValue *val = SPI_VALUE (bonobo_object_from_servant (_servant));
151 GValue gvalue = {0, };
153 g_value_init (&gvalue, G_TYPE_FLOAT);
154 g_value_set_float (&gvalue, (gfloat) value);
155 atk_value_set_current_value (ATK_VALUE(val->atko), &gvalue);