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"
33 impl_get_MinimumValue (DBusMessageIter * iter, void *user_data)
35 AtkValue *value = (AtkValue *) user_data;
40 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
42 atk_value_get_minimum_value (value, &src);
43 g_value_init (&dest, G_TYPE_DOUBLE);
45 if (g_value_transform (&src, &dest))
47 dub = g_value_get_double (&dest);
48 return droute_return_v_double (iter, dub);
57 impl_get_MaximumValue (DBusMessageIter * iter, void *user_data)
59 AtkValue *value = (AtkValue *) user_data;
64 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
66 atk_value_get_maximum_value (value, &src);
67 g_value_init (&dest, G_TYPE_DOUBLE);
69 if (g_value_transform (&src, &dest))
71 dub = g_value_get_double (&dest);
72 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 atk_value_get_minimum_increment (value, &src);
91 g_value_init (&dest, G_TYPE_DOUBLE);
93 if (g_value_transform (&src, &dest))
95 dub = g_value_get_double (&dest);
96 return droute_return_v_double (iter, dub);
105 impl_get_CurrentValue (DBusMessageIter * iter, void *user_data)
107 AtkValue *value = (AtkValue *) user_data;
112 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
114 atk_value_get_current_value (value, &src);
115 g_value_init (&dest, G_TYPE_DOUBLE);
117 if (g_value_transform (&src, &dest))
119 dub = g_value_get_double (&dest);
120 return droute_return_v_double (iter, dub);
129 impl_set_currentValue (DBusMessageIter * iter, void *user_data)
131 AtkValue *value = (AtkValue *) user_data;
135 DBusMessageIter iter_variant;
137 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
139 dbus_message_iter_recurse (iter, &iter_variant);
140 if (dbus_message_iter_get_arg_type (&iter_variant) != DBUS_TYPE_DOUBLE)
142 g_warning ("TODO: Support setting value from a non-double");
145 dbus_message_iter_get_basic (&iter_variant, &dub);
146 g_value_init (&src, G_TYPE_DOUBLE);
147 g_value_set_double (&src, dub);
149 atk_value_get_current_value (value, &dest);
151 if (g_value_transform (&src, &dest))
153 atk_value_set_current_value (value, &dest);
162 static DRouteProperty properties[] = {
163 {impl_get_MinimumValue, NULL, "MinimumValue"},
164 {impl_get_MaximumValue, NULL, "MaximumValue"},
165 {impl_get_MinimumIncrement, NULL, "MinimumIncrement"},
166 {impl_get_CurrentValue, impl_set_currentValue, "CurrentValue"},
171 spi_initialize_value (DRoutePath * path)
173 droute_path_add_interface (path,
174 SPI_DBUS_INTERFACE_VALUE, NULL, properties);