[at-spi2-core] Add setters for component extents/size/position



commit b803e747f23fa01c8848d0996cfe0353989241d6
Author: Mike Gorse <mgorse novell com>
Date:   Mon Jan 31 10:11:07 2011 -0600

    Add setters for component extents/size/position

 atspi/atspi-component.c |  118 ++++++++++++++++++++++++++++++++++++++++++++++-
 atspi/atspi-component.h |    6 ++
 xml/Component.xml       |   22 +++++++++
 3 files changed, 145 insertions(+), 1 deletions(-)
---
diff --git a/atspi/atspi-component.c b/atspi/atspi-component.c
index 42f0771..3c47ce1 100644
--- a/atspi/atspi-component.c
+++ b/atspi/atspi-component.c
@@ -166,7 +166,7 @@ atspi_component_get_position (AtspiComponent *obj,
                                  AtspiCoordType ctype, GError **error)
 {
   dbus_int32_t d_x, d_y;
-  dbus_uint16_t d_ctype = ctype;
+  dbus_uint32_t d_ctype = ctype;
   AtspiPoint ret;
 
   ret.x = ret.y = -1;
@@ -282,6 +282,122 @@ atspi_component_get_alpha    (AtspiComponent *obj, GError **error)
   return retval;
 }
 
+/**
+ * atspi_component_set_extents:
+ * @obj: a pointer to the #AtspiComponent to move.
+ * @x: the new vertical position to which the component should be moved.
+ * @y: the new horizontal position to which the component should be moved.
+ * @width: the width to which the component should be resized.
+ * @height: the height to which the component should be resized.
+ * @ctype: the coordinate system in which the position is specified.
+ *         (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
+ *
+ * Returns: #TRUE if successful; #FALSE otherwise.
+ *
+ * Move and resize the specified component.
+ *
+ **/
+gboolean
+atspi_component_set_extents (AtspiComponent *obj,
+                             gint x,
+                             gint y,
+                             gint width,
+                             gint height,
+                             AtspiCoordType ctype,
+                             GError **error)
+{
+  dbus_int32_t d_x = x, d_y = y, d_width = width, d_height = height;
+  dbus_uint32_t d_ctype = ctype;
+  DBusMessageIter iter, iter_struct;
+  DBusMessage *message, *reply;
+  dbus_bool_t retval;
+  AtspiAccessible *aobj = ATSPI_ACCESSIBLE (obj);
+
+  g_return_val_if_fail (obj != NULL, FALSE);
+
+  message = dbus_message_new_method_call (aobj->parent.app->bus_name,
+                                          aobj->parent.path,
+                                          atspi_interface_component,
+                                          "SetExtents");
+
+  dbus_message_iter_init_append (message, &iter);
+  if (!dbus_message_iter_open_container (&iter, DBUS_TYPE_STRUCT, NULL, &iter_struct))
+  {
+    dbus_message_unref (message);
+    return FALSE;
+  }
+  dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_INT32, &d_x);
+  dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_INT32, &d_y);
+  dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_INT32, &d_width);
+  dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_INT32, &d_height);
+  dbus_message_iter_close_container (&iter, &iter_struct);
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &d_ctype);
+
+  reply = _atspi_dbus_send_with_reply_and_block (message, error);
+  dbus_message_get_args (reply, NULL, DBUS_TYPE_BOOLEAN, &retval,
+                              DBUS_TYPE_INVALID);
+  dbus_message_unref (reply);
+  return retval;
+}
+
+/**
+ * atspi_component_set_position:
+ * @obj: a pointer to the #AtspiComponent to move.
+ * @x: the new vertical position to which the component should be moved.
+ * @y: the new horizontal position to which the component should be moved.
+ * @ctype: the coordinate system in which the position is specified.
+ *         (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
+ *
+ * Returns: #TRUE if successful; #FALSE otherwise.
+ *
+ * Moves the component to the specified position.
+ **/
+gboolean
+atspi_component_set_position (AtspiComponent *obj,
+                              gint x,
+                              gint y,
+                              AtspiCoordType ctype,
+                              GError **error)
+{
+  dbus_int32_t d_x = x, d_y = y;
+  dbus_uint32_t d_ctype = ctype;
+  dbus_bool_t ret = FALSE;
+
+  g_return_val_if_fail (obj != NULL, FALSE);
+
+  _atspi_dbus_call (obj, atspi_interface_component, "SetPosition", error,
+                    "iiu=>b", d_x, d_y, d_ctype, &ret);
+
+  return ret;
+}
+
+/**
+ * atspi_component_set_size:
+ * @obj: a pointer to the #AtspiComponent to query.
+ * @width: the width to which the component should be resized.
+ * @height: the height to which the component should be resized.
+ *
+ * Returns: #TRUE if successful; #FALSE otherwise.
+ *
+ * Resize the specified component to the given coordinates.
+ **/
+gboolean
+atspi_component_set_size (AtspiComponent *obj,
+                          gint width,
+                          gint height,
+                          GError **error)
+{
+  dbus_int32_t d_width = width, d_height = height;
+  dbus_bool_t ret = FALSE;
+
+  g_return_val_if_fail (obj != NULL, FALSE);
+
+  _atspi_dbus_call (obj, atspi_interface_component, "SetSize", error, "ii=>b",
+                    d_width, d_height, &ret);
+
+  return ret;
+}
+
 static void
 atspi_component_base_init (AtspiComponent *klass)
 {
diff --git a/atspi/atspi-component.h b/atspi/atspi-component.h
index 35ab84c..c94147c 100644
--- a/atspi/atspi-component.h
+++ b/atspi/atspi-component.h
@@ -98,4 +98,10 @@ gshort atspi_component_get_mdi_z_order (AtspiComponent *obj, GError **error);
 gboolean atspi_component_grab_focus (AtspiComponent *obj, GError **error);
 
 gdouble      atspi_component_get_alpha    (AtspiComponent *obj, GError **error);
+
+gboolean atspi_component_set_extents (AtspiComponent *obj, gint x, gint y, gint width, gint height, AtspiCoordType ctype, GError **error);
+
+gboolean atspi_component_set_position (AtspiComponent *obj, gint x, gint y, AtspiCoordType ctype, GError **error);
+
+gboolean atspi_component_set_size (AtspiComponent *obj, gint width, gint height, GError **error);
 #endif	/* _ATSPI_COMPONENT_H_ */
diff --git a/xml/Component.xml b/xml/Component.xml
index 2e8f19d..c67dde9 100644
--- a/xml/Component.xml
+++ b/xml/Component.xml
@@ -50,5 +50,27 @@
     <arg direction="out" type="d"/>
   </method>
 
+  <method name="SetExtents">
+    <arg direction="in" name="x" type="i"/>
+    <arg direction="in" name="y" type="i"/>
+    <arg direction="in" name="width" type="i"/>
+    <arg direction="in" name="height" type="i"/>
+    <arg direction="in" name="coord_type" type="u"/>
+    <arg direction="out" type="b"/>
+  </method>
+
+  <method name="SetPosition">
+    <arg direction="in" name="x" type="i"/>
+    <arg direction="in" name="y" type="i"/>
+    <arg direction="in" name="coord_type" type="u"/>
+    <arg direction="out" type="b"/>
+  </method>
+
+  <method name="SetSize">
+    <arg direction="in" name="width" type="i"/>
+    <arg direction="in" name="height" type="i"/>
+    <arg direction="out" type="b"/>
+  </method>
+
 </interface>
 </node>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]