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>
31 #include "introspection.h"
34 impl_get_MinimumValue (DBusMessageIter * iter, void *user_data)
36 AtkValue *value = (AtkValue *) user_data;
41 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
43 atk_value_get_minimum_value (value, &src);
44 g_value_init (&dest, G_TYPE_DOUBLE);
46 if (g_value_transform (&src, &dest))
48 dub = g_value_get_double (&dest);
49 return droute_return_v_double (iter, dub);
58 impl_get_MaximumValue (DBusMessageIter * iter, void *user_data)
60 AtkValue *value = (AtkValue *) user_data;
65 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
67 atk_value_get_maximum_value (value, &src);
68 g_value_init (&dest, G_TYPE_DOUBLE);
70 if (g_value_transform (&src, &dest))
72 dub = g_value_get_double (&dest);
74 return droute_return_v_double (iter, dub);
78 impl_get_MinimumIncrement (DBusMessageIter * iter, void *user_data)
80 AtkValue *value = (AtkValue *) user_data;
85 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
87 atk_value_get_minimum_increment (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_CurrentValue (DBusMessageIter * iter, void *user_data)
100 AtkValue *value = (AtkValue *) user_data;
105 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
107 atk_value_get_current_value (value, &src);
108 g_value_init (&dest, G_TYPE_DOUBLE);
110 if (g_value_transform (&src, &dest))
112 dub = g_value_get_double (&dest);
114 return droute_return_v_double (iter, dub);
118 impl_set_CurrentValue (DBusMessageIter * iter, void *user_data)
120 AtkValue *value = (AtkValue *) user_data;
124 DBusMessageIter iter_variant;
126 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
128 dbus_message_iter_recurse (iter, &iter_variant);
129 if (dbus_message_iter_get_arg_type (&iter_variant) != DBUS_TYPE_DOUBLE)
131 g_warning ("TODO: Support setting value from a non-double");
134 dbus_message_iter_get_basic (&iter_variant, &dub);
135 g_value_init (&src, G_TYPE_DOUBLE);
136 g_value_set_double (&src, dub);
138 atk_value_get_current_value (value, &dest);
140 if (g_value_transform (&src, &dest))
142 atk_value_set_current_value (value, &dest);
151 /* keeping this method around for backwards-compatibility for now; see
154 impl_SetCurrentValue (DBusConnection * bus, DBusMessage * message,
157 AtkValue *value = (AtkValue *) user_data;
162 GValue new_value = { 0 };
164 g_return_val_if_fail (ATK_IS_VALUE (value),
165 droute_not_yet_handled_error (message));
167 dbus_error_init (&error);
168 if (!dbus_message_get_args
169 (message, &error, DBUS_TYPE_DOUBLE, &dub, DBUS_TYPE_INVALID))
171 return droute_invalid_arguments_error (message);
174 g_value_init (&new_value, G_TYPE_DOUBLE);
175 g_value_set_double (&new_value, dub);
176 rv = atk_value_set_current_value (value, &new_value);
178 reply = dbus_message_new_method_return (message);
181 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
187 static DRouteMethod methods[] = {
188 {impl_SetCurrentValue, "SetCurrentValue"},
192 static DRouteProperty properties[] = {
193 {impl_get_MinimumValue, NULL, "MinimumValue"},
194 {impl_get_MaximumValue, NULL, "MaximumValue"},
195 {impl_get_MinimumIncrement, NULL, "MinimumIncrement"},
196 {impl_get_CurrentValue, impl_set_CurrentValue, "CurrentValue"},
201 spi_initialize_value (DRoutePath * path)
203 droute_path_add_interface (path,
204 ATSPI_DBUS_INTERFACE_VALUE, spi_org_a11y_atspi_Value, methods, properties);