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 Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 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 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, 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);
140 return droute_return_v_double (iter, dub);
143 g_value_init (&src, G_TYPE_DOUBLE);
144 atk_value_get_current_value (value, &src);
145 g_value_init (&dest, G_TYPE_DOUBLE);
147 if (g_value_transform (&src, &dest))
149 dub = g_value_get_double (&dest);
151 return droute_return_v_double (iter, dub);
155 impl_set_CurrentValue (DBusMessageIter * iter, void *user_data)
157 AtkValue *value = (AtkValue *) user_data;
161 DBusMessageIter iter_variant;
163 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
165 dbus_message_iter_recurse (iter, &iter_variant);
166 if (dbus_message_iter_get_arg_type (&iter_variant) != DBUS_TYPE_DOUBLE)
168 g_warning ("TODO: Support setting value from a non-double");
171 dbus_message_iter_get_basic (&iter_variant, &dub);
173 AtkValueIface *iface = ATK_VALUE_GET_IFACE (value);
174 if (iface->set_value)
176 atk_value_set_value (value, dub);
180 g_value_init (&src, G_TYPE_DOUBLE);
181 g_value_set_double (&src, dub);
183 atk_value_get_current_value (value, &dest);
185 if (g_value_transform (&src, &dest))
187 atk_value_set_current_value (value, &dest);
196 /* keeping this method around for backwards-compatibility for now; see
199 impl_SetCurrentValue (DBusConnection * bus, DBusMessage * message,
202 AtkValue *value = (AtkValue *) user_data;
206 GValue new_value = { 0 };
208 g_return_val_if_fail (ATK_IS_VALUE (value),
209 droute_not_yet_handled_error (message));
211 if (!dbus_message_get_args
212 (message, NULL, DBUS_TYPE_DOUBLE, &dub, DBUS_TYPE_INVALID))
214 return droute_invalid_arguments_error (message);
217 g_value_init (&new_value, G_TYPE_DOUBLE);
218 g_value_set_double (&new_value, dub);
219 rv = atk_value_set_current_value (value, &new_value);
221 reply = dbus_message_new_method_return (message);
224 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
230 static DRouteMethod methods[] = {
231 {impl_SetCurrentValue, "SetCurrentValue"},
235 static DRouteProperty properties[] = {
236 {impl_get_MinimumValue, NULL, "MinimumValue"},
237 {impl_get_MaximumValue, NULL, "MaximumValue"},
238 {impl_get_MinimumIncrement, NULL, "MinimumIncrement"},
239 {impl_get_CurrentValue, impl_set_CurrentValue, "CurrentValue"},
244 spi_initialize_value (DRoutePath * path)
246 spi_atk_add_interface (path,
247 ATSPI_DBUS_INTERFACE_VALUE, spi_org_a11y_atspi_Value, methods, properties);