Started fixing IDL docs.
[platform/core/uifw/at-spi2-atk.git] / libspi / value.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001 Sun Microsystems Inc.
6  *
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.
11  *
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.
16  *
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.
21  */
22
23 /* value.c : implements the Value interface */
24 #include <config.h>
25 #include <stdio.h>
26 #include <libspi/value.h>
27
28 /* Static function declarations */
29
30 static void
31 spi_value_class_init (SpiValueClass *klass);
32 static void
33 spi_value_init (SpiValue *value);
34 static void
35 spi_value_finalize (GObject *obj);
36 static CORBA_float
37 impl__get_minimumValue (PortableServer_Servant _servant,
38                         CORBA_Environment * ev);
39 static        CORBA_float
40 impl__get_maximumValue (PortableServer_Servant _servant,
41                         CORBA_Environment * ev);
42 static CORBA_float
43 impl__get_currentValue (PortableServer_Servant _servant,
44                         CORBA_Environment * ev);
45 static void 
46 impl__set_currentValue (PortableServer_Servant _servant,
47                         const CORBA_float value,
48                         CORBA_Environment * ev);
49
50
51
52 static GObjectClass *parent_class;
53
54
55 BONOBO_TYPE_FUNC_FULL (SpiValue,
56                        Accessibility_Value,
57                        BONOBO_TYPE_OBJECT,
58                        spi_value);
59
60 static void
61 spi_value_class_init (SpiValueClass *klass)
62 {
63   GObjectClass * object_class = (GObjectClass *) klass;
64   POA_Accessibility_Value__epv *epv = &klass->epv;
65   parent_class = g_type_class_peek_parent (klass);
66
67   object_class->finalize = spi_value_finalize;
68
69
70   /* Initialize epv table */
71
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;
76 }
77
78 static void
79 spi_value_init (SpiValue *value)
80 {
81 }
82
83 static void
84 spi_value_finalize (GObject *obj)
85 {
86   SpiValue *value = SPI_VALUE (obj);
87   g_object_unref (value->atko);
88   value->atko = NULL;
89   parent_class->finalize (obj);
90 }
91
92 SpiValue *
93 spi_value_interface_new (AtkObject *obj)
94 {
95   SpiValue *new_value = g_object_new (SPI_VALUE_TYPE, NULL);
96   new_value->atko = obj;
97   g_object_ref (obj);
98   return new_value;
99 }
100
101
102
103 static CORBA_float
104 impl__get_minimumValue (PortableServer_Servant _servant,
105                        CORBA_Environment * ev)
106 {
107   SpiValue *value = SPI_VALUE (bonobo_object_from_servant (_servant));
108   GValue gvalue = {0, };
109
110   g_value_init (&gvalue, G_TYPE_FLOAT);
111   atk_value_get_minimum_value (ATK_VALUE(value->atko), &gvalue);
112   return (CORBA_float) g_value_get_float (&gvalue);
113 }
114
115
116
117 static        CORBA_float
118 impl__get_maximumValue (PortableServer_Servant _servant,
119                         CORBA_Environment * ev)
120 {
121   SpiValue *value = SPI_VALUE (bonobo_object_from_servant (_servant));
122   GValue gvalue = {0, };
123
124   g_value_init (&gvalue, G_TYPE_FLOAT);
125   atk_value_get_maximum_value (ATK_VALUE(value->atko), &gvalue);
126   return (CORBA_float) g_value_get_float (&gvalue);
127 }
128
129
130
131 static CORBA_float
132 impl__get_currentValue (PortableServer_Servant _servant,
133                         CORBA_Environment * ev)
134 {
135   SpiValue *value = SPI_VALUE (bonobo_object_from_servant (_servant));
136   GValue gvalue = {0, };
137
138   g_value_init (&gvalue, G_TYPE_FLOAT);
139   atk_value_get_current_value (ATK_VALUE(value->atko), &gvalue);
140   return (CORBA_float) g_value_get_float (&gvalue);
141 }
142
143
144 static void 
145 impl__set_currentValue (PortableServer_Servant _servant,
146                         const CORBA_float value,
147                         CORBA_Environment * ev)
148 {
149   SpiValue *val = SPI_VALUE (bonobo_object_from_servant (_servant));
150   GValue gvalue = {0, };
151
152   g_value_init (&gvalue, G_TYPE_FLOAT);
153   g_value_set_float (&gvalue, (gfloat) value);
154   atk_value_set_current_value (ATK_VALUE(val->atko), &gvalue);
155 }
156
157