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>
30 #include "common/spi-dbus.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);
73 return droute_return_v_double (iter, dub);
82 impl_get_MinimumIncrement (DBusMessageIter * iter, void *user_data)
84 AtkValue *value = (AtkValue *) user_data;
89 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
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);
97 return droute_return_v_double (iter, dub);
106 impl_get_CurrentValue (DBusMessageIter * iter, void *user_data)
108 AtkValue *value = (AtkValue *) user_data;
113 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
115 atk_value_get_current_value (value, &src);
116 g_value_init (&dest, G_TYPE_DOUBLE);
118 if (g_value_transform (&src, &dest))
120 dub = g_value_get_double (&dest);
121 return droute_return_v_double (iter, dub);
130 impl_set_currentValue (DBusMessageIter * iter, void *user_data)
132 AtkValue *value = (AtkValue *) user_data;
136 DBusMessageIter iter_variant;
138 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
140 dbus_message_iter_recurse (iter, &iter_variant);
141 if (dbus_message_iter_get_arg_type (&iter_variant) != DBUS_TYPE_DOUBLE)
143 g_warning ("TODO: Support setting value from a non-double");
146 dbus_message_iter_get_basic (&iter_variant, &dub);
147 g_value_init (&src, G_TYPE_DOUBLE);
148 g_value_set_double (&src, dub);
150 atk_value_get_current_value (value, &dest);
152 if (g_value_transform (&src, &dest))
154 atk_value_set_current_value (value, &dest);
163 static DRouteProperty properties[] = {
164 {impl_get_MinimumValue, NULL, "MinimumValue"},
165 {impl_get_MaximumValue, NULL, "MaximumValue"},
166 {impl_get_MinimumIncrement, NULL, "MinimumIncrement"},
167 {impl_get_CurrentValue, impl_set_currentValue, "CurrentValue"},
172 spi_initialize_value (DRoutePath * path)
174 droute_path_add_interface (path,
175 SPI_DBUS_INTERFACE_VALUE, spi_org_a11y_atspi_Value, NULL, properties);