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);
44 g_value_init (&src, G_TYPE_DOUBLE);
45 atk_value_get_minimum_value (value, &src);
46 g_value_init (&dest, G_TYPE_DOUBLE);
48 if (g_value_transform (&src, &dest))
50 dub = g_value_get_double (&dest);
51 return droute_return_v_double (iter, dub);
60 impl_get_MaximumValue (DBusMessageIter * iter, void *user_data)
62 AtkValue *value = (AtkValue *) user_data;
67 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
69 g_value_init (&src, G_TYPE_DOUBLE);
70 atk_value_get_maximum_value (value, &src);
71 g_value_init (&dest, G_TYPE_DOUBLE);
73 if (g_value_transform (&src, &dest))
75 dub = g_value_get_double (&dest);
77 return droute_return_v_double (iter, dub);
81 impl_get_MinimumIncrement (DBusMessageIter * iter, void *user_data)
83 AtkValue *value = (AtkValue *) user_data;
88 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
90 g_value_init (&src, G_TYPE_DOUBLE);
91 atk_value_get_minimum_increment (value, &src);
92 g_value_init (&dest, G_TYPE_DOUBLE);
94 if (g_value_transform (&src, &dest))
96 dub = g_value_get_double (&dest);
98 return droute_return_v_double (iter, dub);
102 impl_get_CurrentValue (DBusMessageIter * iter, void *user_data)
104 AtkValue *value = (AtkValue *) user_data;
109 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
111 g_value_init (&src, G_TYPE_DOUBLE);
112 atk_value_get_current_value (value, &src);
113 g_value_init (&dest, G_TYPE_DOUBLE);
115 if (g_value_transform (&src, &dest))
117 dub = g_value_get_double (&dest);
119 return droute_return_v_double (iter, dub);
123 impl_set_CurrentValue (DBusMessageIter * iter, void *user_data)
125 AtkValue *value = (AtkValue *) user_data;
129 DBusMessageIter iter_variant;
131 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
133 dbus_message_iter_recurse (iter, &iter_variant);
134 if (dbus_message_iter_get_arg_type (&iter_variant) != DBUS_TYPE_DOUBLE)
136 g_warning ("TODO: Support setting value from a non-double");
139 dbus_message_iter_get_basic (&iter_variant, &dub);
140 g_value_init (&src, G_TYPE_DOUBLE);
141 g_value_set_double (&src, dub);
143 atk_value_get_current_value (value, &dest);
145 if (g_value_transform (&src, &dest))
147 atk_value_set_current_value (value, &dest);
156 /* keeping this method around for backwards-compatibility for now; see
159 impl_SetCurrentValue (DBusConnection * bus, DBusMessage * message,
162 AtkValue *value = (AtkValue *) user_data;
166 GValue new_value = { 0 };
168 g_return_val_if_fail (ATK_IS_VALUE (value),
169 droute_not_yet_handled_error (message));
171 if (!dbus_message_get_args
172 (message, NULL, DBUS_TYPE_DOUBLE, &dub, DBUS_TYPE_INVALID))
174 return droute_invalid_arguments_error (message);
177 g_value_init (&new_value, G_TYPE_DOUBLE);
178 g_value_set_double (&new_value, dub);
179 rv = atk_value_set_current_value (value, &new_value);
181 reply = dbus_message_new_method_return (message);
184 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
190 static DRouteMethod methods[] = {
191 {impl_SetCurrentValue, "SetCurrentValue"},
195 static DRouteProperty properties[] = {
196 {impl_get_MinimumValue, NULL, "MinimumValue"},
197 {impl_get_MaximumValue, NULL, "MaximumValue"},
198 {impl_get_MinimumIncrement, NULL, "MinimumIncrement"},
199 {impl_get_CurrentValue, impl_set_CurrentValue, "CurrentValue"},
204 spi_initialize_value (DRoutePath * path)
206 spi_atk_add_interface (path,
207 ATSPI_DBUS_INTERFACE_VALUE, spi_org_a11y_atspi_Value, methods, properties);