Always emit children-changed, property-change, and state-changed events
[platform/core/uifw/at-spi2-atk.git] / cspi / spi-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 <cspi/spi-private.h>
25
26 /**
27  * AccessibleValue_ref:
28  * @obj: a pointer to the #AccessibleValue implementor on which to operate.
29  *
30  * Increment the reference count for an #AccessibleValue object.
31  **/
32 void
33 AccessibleValue_ref (AccessibleValue *obj)
34 {
35   cspi_object_ref (obj);
36 }
37
38 /**
39  * AccessibleValue_unref:
40  * @obj: a pointer to the #AccessibleValue implementor on which to operate. 
41  *
42  * Decrement the reference count for an #AccessibleValue object.
43  **/
44 void
45 AccessibleValue_unref (AccessibleValue *obj)
46 {
47   cspi_object_unref (obj);
48 }
49
50 /**
51  * AccessibleValue_getMinimumValue:
52  * @obj: a pointer to the #AccessibleValue implementor on which to operate. 
53  *
54  * Get the minimum allowed value for an #AccessibleValue.
55  *
56  * Returns: the minimum allowed value for this object.
57  *
58  **/
59 double
60 AccessibleValue_getMinimumValue (AccessibleValue *obj)
61 {
62   double retval;
63
64   cspi_return_val_if_fail (obj != NULL, 0.0);
65
66   cspi_dbus_get_property (obj, spi_interface_value, "minimumValue", NULL, "d", &retval);
67   
68   cspi_return_val_if_ev ("getMinimumValue", 0.0);
69
70   return retval;
71 }
72
73 /**
74  * AccessibleValue_getCurrentValue:
75  * @obj: a pointer to the #AccessibleValue implementor on which to operate. 
76  *
77  * Get the current value for an #AccessibleValue.
78  *
79  * Returns: the current value for this object.
80  **/
81 double
82 AccessibleValue_getCurrentValue (AccessibleValue *obj)
83 {
84   double retval;
85
86   cspi_return_val_if_fail (obj != NULL, 0.0);
87
88   cspi_dbus_get_property (obj, spi_interface_value, "currentValue", NULL, "d", &retval);
89
90   cspi_return_val_if_ev ("getCurrentValue", 0.0);
91
92   return retval;
93 }
94
95 /**
96  * AccessibleValue_getMaximumValue:
97  * @obj: a pointer to the #AccessibleValue implementor on which to operate. 
98  *
99  * Get the maximum allowed value for an #AccessibleValue.
100  *
101  * Returns: the maximum allowed value for this object.
102  **/
103 double
104 AccessibleValue_getMaximumValue (AccessibleValue *obj)
105 {
106   double retval;        
107   cspi_return_val_if_fail (obj != NULL, 0.0);
108
109   cspi_dbus_get_property (obj, spi_interface_value, "maximumValue", NULL, "d", &retval);
110
111   cspi_return_val_if_ev ("getMaximumValue", 0.0);
112
113   return retval;
114 }
115
116 /**
117  * AccessibleValue_setCurrentValue:
118  * @obj: a pointer to the #AccessibleValue implementor on which to operate.
119  * @newValue: a #float value which is the desired new value of the object.
120  *
121  * Set the current value of an #AccessibleValue.
122  *
123  * Returns: #TRUE if the value could be assigned the specified value,
124  *          #FALSE otherwise.
125  **/
126 SPIBoolean
127 AccessibleValue_setCurrentValue (AccessibleValue *obj,
128                                  double newValue)
129 {
130   cspi_return_val_if_fail (obj != NULL, FALSE);
131
132   cspi_dbus_call (obj, spi_interface_value, "setCurrentValue", NULL, "d", &newValue);
133
134   cspi_return_val_if_ev ("setCurrentValue", FALSE);
135
136   return TRUE;
137 }
138
139 /**
140  * AccessibleValue_getMinimumIncrement:
141  * @obj: a pointer to the #AccessibleValue implementor on which to operate. 
142  *
143  * Get the minimum increment by which an #AccessibleValue can be adjusted.
144  *
145  * Returns: the minimum increment by which the value may be changed, or
146  * zero if the minimum increment cannot be determined.
147  *
148  **/
149 double
150 AccessibleValue_getMinimumIncrement (AccessibleValue *obj)
151 {
152   double retval;
153
154   cspi_return_val_if_fail (obj != NULL, 0.0);
155
156   cspi_dbus_get_property (obj, spi_interface_value, "minimumIncrement", NULL, "d", &retval);
157   
158   cspi_return_val_if_ev ("getMinimumIncrement", 0.0);
159
160   return retval;
161 }
162