Add Action, Document, EditableText, Image, and Value interfaces
[platform/upstream/at-spi2-core.git] / atspi / atspi-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, 2002 Sun Microsystems Inc.,
6  * Copyright 2001, 2002 Ximian, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 #include "atspi-private.h"
25
26 /**
27  * atspi_value_get_minimum_value:
28  * @obj: a pointer to the #AtspiValue implementor on which to operate. 
29  *
30  * Get the minimum allowed value for an #AtspiValue.
31  *
32  * Returns: the minimum allowed value for this object.
33  *
34  **/
35 gdouble
36 atspi_value_get_minimum_value (AtspiValue *obj, GError **error)
37 {
38   double retval;
39
40   g_return_val_if_fail (obj != NULL, 0.0);
41   _atspi_dbus_get_property (obj, atspi_interface_value, "MinimumValue", error, "d", &retval);
42   
43   return retval;
44 }
45
46 /**
47  * atspi_value_get_current_value:
48  * @obj: a pointer to the #AtspiValue implementor on which to operate. 
49  *
50  * Get the current value for an #AtspiValue.
51  *
52  * Returns: the current value for this object.
53  **/
54 gdouble
55 atspi_value_get_current_value (AtspiValue *obj, GError **error)
56 {
57   double retval;
58
59   g_return_val_if_fail (obj != NULL, 0.0);
60
61   _atspi_dbus_get_property (obj, atspi_interface_value, "CurrentValue", error, "d", &retval);
62
63   return retval;
64 }
65
66 /**
67  * atspi_value_get_maximum_value:
68  * @obj: a pointer to the #AtspiValue implementor on which to operate. 
69  *
70  * Get the maximum allowed value for an #AtspiValue.
71  *
72  * Returns: the maximum allowed value for this object.
73  **/
74 gdouble
75 atspi_value_get_maximum_value (AtspiValue *obj, GError **error)
76 {
77   double retval;        
78
79   g_return_val_if_fail (obj != NULL, 0.0);
80
81   _atspi_dbus_get_property (obj, atspi_interface_value, "MaximumValue", error, "d", &retval);
82
83   return retval;
84 }
85
86 /**
87  * atspi_value_set_current_value:
88  * @obj: a pointer to the #AtspiValue implementor on which to operate.
89  * @new_value: a #float value which is the desired new value of the object.
90  *
91  * Set the current value of an #AtspiValue.
92  *
93  * Returns: #TRUE if the value could be assigned the specified value,
94  *          #FALSE otherwise.
95  **/
96 gboolean
97 atspi_value_set_current_value (AtspiValue *obj, gdouble new_value, GError **error)
98 {
99   double d_new_value = new_value;
100
101   g_return_val_if_fail (obj != NULL, FALSE);
102
103   _atspi_dbus_call (obj, atspi_interface_value, "SetCurrentValue", error, "d", &d_new_value);
104
105   return TRUE;
106 }
107
108 /**
109  * atspi_value_get_minimum_increment:
110  * @obj: a pointer to the #AtspiValue implementor on which to operate. 
111  *
112  * Get the minimum increment by which an #AtspiValue can be adjusted.
113  *
114  * Returns: the minimum increment by which the value may be changed, or
115  * zero if the minimum increment cannot be determined.
116  *
117  **/
118 gdouble
119 atspi_value_get_minimum_increment (AtspiValue *obj, GError **error)
120 {
121   double retval;
122
123   g_return_val_if_fail (obj != NULL, 0.0);
124
125   _atspi_dbus_get_property (obj, atspi_interface_value, "MinimumIncrement", error, "d", &retval);
126   
127   return retval;
128 }
129
130 static void
131 atspi_value_base_init (AtspiValue *klass)
132 {
133 }
134
135 GType
136 atspi_value_get_type (void)
137 {
138   static GType type = 0;
139
140   if (!type) {
141     static const GTypeInfo tinfo =
142     {
143       sizeof (AtspiValue),
144       (GBaseInitFunc) atspi_value_base_init,
145       (GBaseFinalizeFunc) NULL,
146     };
147
148     type = g_type_register_static (G_TYPE_INTERFACE, "AtspiValue", &tinfo, 0);
149
150   }
151   return type;
152 }