2.34.0
[platform/upstream/at-spi2-core.git] / atspi / atspi-value.c
index 32071b3..28acade 100644 (file)
@@ -4,21 +4,22 @@
  *
  * Copyright 2001, 2002 Sun Microsystems Inc.,
  * Copyright 2001, 2002 Ximian, Inc.
+ * Copyright 2010, 2011 Novell, Inc.
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 #include "atspi-private.h"
@@ -27,7 +28,7 @@
  * atspi_value_get_minimum_value:
  * @obj: a pointer to the #AtspiValue implementor on which to operate. 
  *
- * Get the minimum allowed value for an #AtspiValue.
+ * Gets the minimum allowed value for an #AtspiValue.
  *
  * Returns: the minimum allowed value for this object.
  *
@@ -47,7 +48,7 @@ atspi_value_get_minimum_value (AtspiValue *obj, GError **error)
  * atspi_value_get_current_value:
  * @obj: a pointer to the #AtspiValue implementor on which to operate. 
  *
- * Get the current value for an #AtspiValue.
+ * Gets the current value for an #AtspiValue.
  *
  * Returns: the current value for this object.
  **/
@@ -67,7 +68,7 @@ atspi_value_get_current_value (AtspiValue *obj, GError **error)
  * atspi_value_get_maximum_value:
  * @obj: a pointer to the #AtspiValue implementor on which to operate. 
  *
- * Get the maximum allowed value for an #AtspiValue.
+ * Gets the maximum allowed value for an #AtspiValue.
  *
  * Returns: the maximum allowed value for this object.
  **/
@@ -86,9 +87,9 @@ atspi_value_get_maximum_value (AtspiValue *obj, GError **error)
 /**
  * atspi_value_set_current_value:
  * @obj: a pointer to the #AtspiValue implementor on which to operate.
- * @new_value: a #float value which is the desired new value of the object.
+ * @new_value: a #gdouble value which is the desired new value of the object.
  *
- * Set the current value of an #AtspiValue.
+ * Sets the current value of an #AtspiValue.
  *
  * Returns: #TRUE if the value could be assigned the specified value,
  *          #FALSE otherwise.
@@ -97,10 +98,34 @@ gboolean
 atspi_value_set_current_value (AtspiValue *obj, gdouble new_value, GError **error)
 {
   double d_new_value = new_value;
+  DBusMessage *message, *reply;
+  DBusMessageIter iter, iter_variant;
+  static const char *str_curval = "CurrentValue";
+  AtspiAccessible *accessible = ATSPI_ACCESSIBLE (obj);
 
-  g_return_val_if_fail (obj != NULL, FALSE);
+  g_return_val_if_fail (accessible != NULL, FALSE);
 
-  _atspi_dbus_call (obj, atspi_interface_value, "SetCurrentValue", error, "d", &d_new_value);
+  if (!accessible->parent.app || !accessible->parent.app->bus_name)
+{
+    g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_APPLICATION_GONE,
+                          _("The application no longer exists"));
+    return FALSE;
+  }
+
+    message = dbus_message_new_method_call (accessible->parent.app->bus_name,
+                                            accessible->parent.path,
+                                            DBUS_INTERFACE_PROPERTIES, "Set");
+    if (!message)
+      return FALSE;
+    dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_value,
+                               DBUS_TYPE_STRING, &str_curval,
+                              DBUS_TYPE_INVALID);
+  dbus_message_iter_init_append (message, &iter);
+  dbus_message_iter_open_container (&iter, DBUS_TYPE_VARIANT, "d", &iter_variant);
+  dbus_message_iter_append_basic (&iter_variant, DBUS_TYPE_DOUBLE, &d_new_value);
+  dbus_message_iter_close_container (&iter, &iter_variant);
+    reply = _atspi_dbus_send_with_reply_and_block (message, error);
+  dbus_message_unref (reply);
 
   return TRUE;
 }
@@ -109,7 +134,7 @@ atspi_value_set_current_value (AtspiValue *obj, gdouble new_value, GError **erro
  * atspi_value_get_minimum_increment:
  * @obj: a pointer to the #AtspiValue implementor on which to operate. 
  *
- * Get the minimum increment by which an #AtspiValue can be adjusted.
+ * Gets the minimum increment by which an #AtspiValue can be adjusted.
  *
  * Returns: the minimum increment by which the value may be changed, or
  * zero if the minimum increment cannot be determined.