2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2008 Novell, Inc.
6 * Copyright 2001, 2002 Sun Microsystems Inc.,
7 * Copyright 2001, 2002 Ximian, Inc.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
28 #include <droute/droute.h>
32 #include "introspection.h"
35 impl_get_MinimumValue (DBusMessageIter * iter, void *user_data)
37 AtkValue *value = (AtkValue *) user_data;
42 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
43 AtkValueIface *iface = ATK_VALUE_GET_IFACE (value);
46 AtkRange *range = atk_value_get_range (value);
47 dub = atk_range_get_lower_limit (range);
48 atk_range_free (range);
49 return droute_return_v_double (iter, dub);
52 g_value_init (&src, G_TYPE_DOUBLE);
53 atk_value_get_minimum_value (value, &src);
54 g_value_init (&dest, G_TYPE_DOUBLE);
56 if (g_value_transform (&src, &dest))
58 dub = g_value_get_double (&dest);
59 return droute_return_v_double (iter, dub);
68 impl_get_MaximumValue (DBusMessageIter * iter, void *user_data)
70 AtkValue *value = (AtkValue *) user_data;
75 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
77 AtkValueIface *iface = ATK_VALUE_GET_IFACE (value);
80 AtkRange *range = atk_value_get_range (value);
81 dub = atk_range_get_upper_limit (range);
82 atk_range_free (range);
83 return droute_return_v_double (iter, dub);
86 g_value_init (&src, G_TYPE_DOUBLE);
87 atk_value_get_maximum_value (value, &src);
88 g_value_init (&dest, G_TYPE_DOUBLE);
90 if (g_value_transform (&src, &dest))
92 dub = g_value_get_double (&dest);
94 return droute_return_v_double (iter, dub);
98 impl_get_MinimumIncrement (DBusMessageIter * iter, void *user_data)
100 AtkValue *value = (AtkValue *) user_data;
105 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
107 AtkValueIface *iface = ATK_VALUE_GET_IFACE (value);
108 if (iface->get_increment)
110 dub = atk_value_get_increment (value);
111 return droute_return_v_double (iter, dub);
114 g_value_init (&src, G_TYPE_DOUBLE);
115 atk_value_get_minimum_increment (value, &src);
116 g_value_init (&dest, G_TYPE_DOUBLE);
118 if (g_value_transform (&src, &dest))
120 dub = g_value_get_double (&dest);
122 return droute_return_v_double (iter, dub);
126 impl_get_CurrentValue (DBusMessageIter * iter, void *user_data)
128 AtkValue *value = (AtkValue *) user_data;
133 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
135 AtkValueIface *iface = ATK_VALUE_GET_IFACE (value);
136 if (iface->get_value_and_text)
139 atk_value_get_value_and_text (value, &dub, &text);
141 return droute_return_v_double (iter, dub);
144 g_value_init (&src, G_TYPE_DOUBLE);
145 atk_value_get_current_value (value, &src);
146 g_value_init (&dest, G_TYPE_DOUBLE);
148 if (g_value_transform (&src, &dest))
150 dub = g_value_get_double (&dest);
152 return droute_return_v_double (iter, dub);
156 impl_set_CurrentValue (DBusMessageIter * iter, void *user_data)
158 AtkValue *value = (AtkValue *) user_data;
162 DBusMessageIter iter_variant;
164 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
166 dbus_message_iter_recurse (iter, &iter_variant);
167 if (dbus_message_iter_get_arg_type (&iter_variant) != DBUS_TYPE_DOUBLE)
169 g_warning ("TODO: Support setting value from a non-double");
172 dbus_message_iter_get_basic (&iter_variant, &dub);
174 AtkValueIface *iface = ATK_VALUE_GET_IFACE (value);
175 if (iface->set_value)
177 atk_value_set_value (value, dub);
181 g_value_init (&src, G_TYPE_DOUBLE);
182 g_value_set_double (&src, dub);
184 atk_value_get_current_value (value, &dest);
186 if (g_value_transform (&src, &dest))
188 atk_value_set_current_value (value, &dest);
197 /* keeping this method around for backwards-compatibility for now; see
200 impl_SetCurrentValue (DBusConnection * bus, DBusMessage * message,
203 AtkValue *value = (AtkValue *) user_data;
207 GValue new_value = { 0 };
209 g_return_val_if_fail (ATK_IS_VALUE (value),
210 droute_not_yet_handled_error (message));
212 if (!dbus_message_get_args
213 (message, NULL, DBUS_TYPE_DOUBLE, &dub, DBUS_TYPE_INVALID))
215 return droute_invalid_arguments_error (message);
218 g_value_init (&new_value, G_TYPE_DOUBLE);
219 g_value_set_double (&new_value, dub);
220 rv = atk_value_set_current_value (value, &new_value);
222 reply = dbus_message_new_method_return (message);
225 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
231 static DRouteMethod methods[] = {
232 {impl_SetCurrentValue, "SetCurrentValue"},
236 static DRouteProperty properties[] = {
237 {impl_get_MinimumValue, NULL, "MinimumValue"},
238 {impl_get_MaximumValue, NULL, "MaximumValue"},
239 {impl_get_MinimumIncrement, NULL, "MinimumIncrement"},
240 {impl_get_CurrentValue, impl_set_CurrentValue, "CurrentValue"},
245 spi_initialize_value (DRoutePath * path)
247 spi_atk_add_interface (path,
248 ATSPI_DBUS_INTERFACE_VALUE, spi_org_a11y_atspi_Value, methods, properties);