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.
24 * component.c : bonobo wrapper for accessible component implementation
28 #include <bonobo/Bonobo.h>
33 * This pulls the CORBA definitions for the "Accessibility::Accessible" server
35 #include <libspi/Accessibility.h>
38 * This pulls the definition of the SpiValue bonobo object
43 * Static function declarations
47 spi_value_class_init (SpiValueClass *klass);
49 spi_value_init (SpiValue *value);
51 spi_value_finalize (GObject *obj);
53 impl__get_minimumValue (PortableServer_Servant _servant,
54 CORBA_Environment * ev);
56 impl__get_maximumValue (PortableServer_Servant _servant,
57 CORBA_Environment * ev);
59 impl__get_currentValue (PortableServer_Servant _servant,
60 CORBA_Environment * ev);
62 impl__set_currentValue (PortableServer_Servant _servant,
63 const CORBA_float value,
64 CORBA_Environment * ev);
68 static GObjectClass *parent_class;
72 spi_value_get_type (void)
74 static GType type = 0;
77 static const GTypeInfo tinfo = {
78 sizeof (SpiValueClass),
80 (GBaseFinalizeFunc) NULL,
81 (GClassInitFunc) spi_value_class_init,
82 (GClassFinalizeFunc) NULL,
83 NULL, /* class data */
86 (GInstanceInitFunc) spi_value_init,
87 NULL /* value table */
91 * Bonobo_type_unique auto-generates a load of
92 * CORBA structures for us. All derived types must
93 * use bonobo_type_unique.
95 type = bonobo_type_unique (
97 POA_Accessibility_Value__init,
99 G_STRUCT_OFFSET (SpiValueClass, epv),
101 "SpiAccessibleValue");
108 spi_value_class_init (SpiValueClass *klass)
110 GObjectClass * object_class = (GObjectClass *) klass;
111 POA_Accessibility_Value__epv *epv = &klass->epv;
112 parent_class = g_type_class_peek_parent (klass);
114 object_class->finalize = spi_value_finalize;
117 /* Initialize epv table */
119 epv->_get_minimumValue = impl__get_minimumValue;
120 epv->_get_maximumValue = impl__get_maximumValue;
121 epv->_get_currentValue = impl__get_currentValue;
122 epv->_set_currentValue = impl__set_currentValue;
126 spi_value_init (SpiValue *value)
131 spi_value_finalize (GObject *obj)
133 SpiValue *value = SPI_VALUE (obj);
134 g_object_unref (value->atko);
136 parent_class->finalize (obj);
140 spi_value_interface_new (AtkObject *obj)
142 SpiValue *new_value =
143 SPI_VALUE(g_object_new (SPI_VALUE_TYPE, NULL));
144 new_value->atko = obj;
152 impl__get_minimumValue (PortableServer_Servant _servant,
153 CORBA_Environment * ev)
155 SpiValue *value = SPI_VALUE (bonobo_object_from_servant (_servant));
156 GValue gvalue = {0, };
158 g_value_init (&gvalue, G_TYPE_FLOAT);
159 atk_value_get_minimum_value (ATK_VALUE(value->atko), &gvalue);
160 return (CORBA_float) g_value_get_float (&gvalue);
166 impl__get_maximumValue (PortableServer_Servant _servant,
167 CORBA_Environment * ev)
169 SpiValue *value = SPI_VALUE (bonobo_object_from_servant (_servant));
170 GValue gvalue = {0, };
172 g_value_init (&gvalue, G_TYPE_FLOAT);
173 atk_value_get_maximum_value (ATK_VALUE(value->atko), &gvalue);
174 return (CORBA_float) g_value_get_float (&gvalue);
180 impl__get_currentValue (PortableServer_Servant _servant,
181 CORBA_Environment * ev)
183 SpiValue *value = SPI_VALUE (bonobo_object_from_servant (_servant));
184 GValue gvalue = {0, };
186 g_value_init (&gvalue, G_TYPE_FLOAT);
187 atk_value_get_current_value (ATK_VALUE(value->atko), &gvalue);
188 return (CORBA_float) g_value_get_float (&gvalue);
193 impl__set_currentValue (PortableServer_Servant _servant,
194 const CORBA_float value,
195 CORBA_Environment * ev)
197 SpiValue *val = SPI_VALUE (bonobo_object_from_servant (_servant));
198 GValue gvalue = {0, };
200 g_value_init (&gvalue, G_TYPE_FLOAT);
201 g_value_set_float (&gvalue, (gfloat) value);
202 atk_value_set_current_value (ATK_VALUE(val->atko), &gvalue);