Added spi-application.c and spi-image.c
authorMike Gorse <mgorse@boston.site>
Fri, 15 Aug 2008 21:34:41 +0000 (16:34 -0500)
committerMike Gorse <mgorse@boston.site>
Fri, 15 Aug 2008 21:34:41 +0000 (16:34 -0500)
cspi/Makefile.am
cspi/spi-application.c [new file with mode: 0644]
cspi/spi-image.c [new file with mode: 0644]

index 58a184c..1cb9033 100644 (file)
@@ -19,11 +19,13 @@ libcspi_la_SOURCES =                \
        cspi-lowlevel.h         \
        spi-accessible.c \
        spi-action.c \
+       spi-application.c \
        spi-component.c \
        spi-editabletext.c \
        spi-event.c \
        spi-hyperlink.c \
        spi-hypertext.c \
+       spi-image.c \
        spi-listener.c \
        spi-main.c              \
        spi-registry.c \
diff --git a/cspi/spi-application.c b/cspi/spi-application.c
new file mode 100644 (file)
index 0000000..7b219b0
--- /dev/null
@@ -0,0 +1,208 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+/*
+ *
+ * AccessibleApplication function prototypes
+ *
+ */
+
+#include <cspi/spi-private.h>
+#include <locale.h>
+
+/**
+ * AccessibleApplication_ref:
+ * @obj: a pointer to the #AccessibleApplication on which to operate.
+ *
+ * Increment the reference count for an #AccessibleApplication.
+ **/
+void
+AccessibleApplication_ref (AccessibleApplication *obj)
+{
+  cspi_object_ref (obj);
+}
+
+/**
+ * AccessibleApplication_unref:
+ * @obj: a pointer to the #AccessibleApplication object on which to operate.
+ *
+ * Decrement the reference count for an #AccessibleApplication.
+ **/
+void
+AccessibleApplication_unref (AccessibleApplication *obj)
+{
+  cspi_object_unref (obj);
+}
+
+/**
+ * AccessibleApplication_getToolkitName:
+ * @obj: a pointer to the #AccessibleApplication to query.
+ *
+ * Get the name of the UI toolkit used by an #AccessibleApplication.
+ *
+ * Returns: a UTF-8 string indicating which UI toolkit is
+ *          used by an application.
+ **/
+char *
+AccessibleApplication_getToolkitName (AccessibleApplication *obj)
+{
+  char *retval;
+
+  cspi_return_val_if_fail (obj != NULL, NULL);
+
+  cspi_dbus_get_property (obj, spi_interface_application, "tooklitName", NULL, "s", &retval);
+
+  cspi_return_val_if_ev ("toolkitName", NULL);
+
+  return retval;
+}
+
+/**
+ * AccessibleApplication_getVersion:
+ * @obj: a pointer to the #AccessibleApplication being queried.
+ *
+ * Get the version of the at-spi bridge exported by an
+ *      #AccessibleApplication instance.
+ *
+ * Returns: a UTF-8 string indicating the application's
+ *          at-spi version.
+ **/
+char *
+AccessibleApplication_getVersion (AccessibleApplication *obj)
+{
+  char *retval;
+
+  cspi_return_val_if_fail (obj != NULL, NULL);
+
+  cspi_dbus_get_property (obj, spi_interface_application, "version", NULL, "s", &retval);
+
+  cspi_return_val_if_ev ("version", NULL);
+
+  return retval;
+}
+
+/**
+ * AccessibleApplication_getID:
+ * @obj: a pointer to the #AccessibleApplication being queried.
+ *
+ * Get the unique ID assigned by the Registry to an
+ *      #AccessibleApplication instance.
+ * (Not Yet Implemented by the registry).
+ *
+ * Returns: a unique #long integer associated with the application
+ *          by the Registry, or 0 if the application is not registered.
+ **/
+long
+AccessibleApplication_getID (AccessibleApplication *obj)
+{
+  dbus_int32_t retval;
+
+  cspi_return_val_if_fail (obj != NULL, 0);
+
+  cspi_dbus_get_property (obj, spi_interface_application, "id", NULL, "u", &retval);
+
+  cspi_return_val_if_ev ("id", 0);
+
+  return retval;
+}
+
+/**
+ * AccessibleApplication_getLocale:
+ * @obj: a pointer to the #AccessibleApplication being queried.
+ * @lc_category: one of the POSIX LC_TYPE enumeration, for instance
+ * LC_MESSAGES.
+ *
+ * Get a POSIX-compliant string describing the application's current
+ * locale setting for a particular @lctype category.
+ *
+ * @Since: AT-SPI 1.4
+ *
+ * Returns: a POSIX-compliant locale string, e.g. "C", "pt_BR", "sr@latn", etc.
+ **/
+char *
+AccessibleApplication_getLocale (AccessibleApplication *obj, int lc_category)
+{
+  gchar *retval;
+  dbus_uint32_t lctype;
+
+  cspi_return_val_if_fail (obj != NULL, g_strdup (""));
+
+  switch (lc_category) 
+  {
+  case LC_COLLATE:
+    lctype = Accessibility_LOCALE_TYPE_COLLATE;
+    break;
+  case LC_CTYPE:
+    lctype = Accessibility_LOCALE_TYPE_CTYPE;
+    break;
+  case LC_NUMERIC:
+    lctype = Accessibility_LOCALE_TYPE_NUMERIC;
+    break;
+  case LC_MONETARY:
+    lctype = Accessibility_LOCALE_TYPE_MONETARY;
+    break;
+  case LC_MESSAGES:
+  default:
+    lctype = Accessibility_LOCALE_TYPE_MESSAGES;
+    break;
+  }
+
+  cspi_dbus_call (obj, spi_interface_application, "getLocale", NULL, "u=>s", lctype, &retval);
+
+  cspi_return_val_if_ev ("id", g_strdup (""));
+
+  return g_strdup (retval);
+}
+
+/**
+ * AccessibleApplication_pause:
+ * @obj: a pointer to the #Accessible object on which to operate.
+ *
+ * Attempt to pause the application (used when client event queue is
+ *  over-full).
+ * Not Yet Implemented.
+ *
+ * Returns: #TRUE if the application was paused successfully, #FALSE otherwise.
+ *
+ **/
+SPIBoolean
+AccessibleApplication_pause (AccessibleApplication *obj)
+{
+  return FALSE;
+}
+
+/**
+ * AccessibleApplication_resume:
+ * @obj: a pointer to the #Accessible object on which to operate.
+ *
+ * Attempt to resume the application (used after #AccessibleApplication_pause).
+ * Not Yet Implemented.
+ *
+ * Returns: #TRUE if application processing resumed successfully, #FALSE otherwise.
+ *
+ **/
+SPIBoolean
+AccessibleApplication_resume (AccessibleApplication *obj)
+{
+  return FALSE;
+}
diff --git a/cspi/spi-image.c b/cspi/spi-image.c
new file mode 100644 (file)
index 0000000..17c6d9f
--- /dev/null
@@ -0,0 +1,199 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+#include <cspi/spi-private.h>
+
+/**
+ * AccessibleImage_ref:
+ * @obj: a pointer to the #AccessibleImage implementor on which to operate.
+ *
+ * Increment the reference count for an #AccessibleImage object.
+ **/
+void
+AccessibleImage_ref (AccessibleImage *obj)
+{
+  cspi_object_ref (obj);
+}
+
+/**
+ * AccessibleImage_unref:
+ * @obj: a pointer to the #AccessibleImage implementor on which to operate.
+ *
+ * Decrement the reference count for an #AccessibleImage object.
+ **/
+void
+AccessibleImage_unref (AccessibleImage *obj)
+{
+  cspi_object_unref (obj);
+}
+
+/**
+ * AccessibleImage_getImageDescription:
+ * @obj: a pointer to the #AccessibleImage implementor on which to operate.
+ *
+ * Get the description of the image displayed in an #AccessibleImage object.
+ *
+ * Returns: a UTF-8 string describing the image.
+ **/
+char *
+AccessibleImage_getImageDescription (AccessibleImage *obj)
+{
+  char *retval;
+
+  cspi_return_val_if_fail (obj != NULL, NULL);
+
+  cspi_dbus_get_property (obj, spi_interface_image, "description", NULL, "s", &retval);
+
+  cspi_return_val_if_ev ("getImageDescription", NULL);
+
+  return retval;
+}
+
+/**
+ * AccessibleImage_getImageSize:
+ * @obj: a pointer to the #AccessibleImage to query.
+ * @width: a pointer to a #long into which the x extents (width) will be returned.
+ * @height: a pointer to a #long into which the y extents (height) will be returned.
+ *
+ * Get the size of the image displayed in a specified #AccessibleImage object.
+ **/
+void
+AccessibleImage_getImageSize (AccessibleImage *obj,
+                              long int *width,
+                              long int *height)
+{
+  dbus_int32_t w, h;
+
+  cspi_return_if_fail (obj != NULL);
+
+  cspi_dbus_call (obj, spi_interface_image, "getImageSize", NULL, "=>ii", &w, &h);
+
+  if (!cspi_check_ev ("getImageSize"))
+    {
+      *width = 0;
+      *height = 0;
+    }
+  else
+    {
+      *width = w;
+      *height = h;
+    }
+}
+
+/**
+ * AccessibleImage_getImagePosition:
+ * @obj: a pointer to the #AccessibleImage implementor to query.
+ * @x: a pointer to a #long into which the minimum x coordinate will be returned.
+ * @y: a pointer to a #long into which the minimum y coordinate will be returned.
+ * @ctype: the desired coordinate system into which to return the results,
+ *         (e.g. SPI_COORD_TYPE_WINDOW, SPI_COORD_TYPE_SCREEN).
+ *
+ * Get the minimum x and y coordinates of the image displayed in a
+ *         specified #AccessibleImage implementor.
+ **/
+void
+AccessibleImage_getImagePosition (AccessibleImage *obj,
+                                  long *x,
+                                  long *y,
+                                  AccessibleCoordType ctype)
+{
+  dbus_int32_t dx, dy;
+
+  cspi_return_if_fail (obj != NULL);
+
+  cspi_dbus_call (obj, spi_interface_image, "getImagePosition", NULL, "=>ii", &dx, &dy);
+
+  if (!cspi_check_ev ("getImagePosition"))
+    {
+      *x = 0;
+      *y = 0;
+    }
+  else
+    {
+      *x = dx;
+      *y = dy;
+    }
+}
+
+/**
+ * AccessibleImage_getImageExtents:
+ * @obj: a pointer to the #AccessibleImage implementor to query.
+ * @x: a pointer to a #long into which the minimum x coordinate will be returned.
+ * @y: a pointer to a #long into which the minimum y coordinate will be returned.
+ * @width: a pointer to a #long into which the image x extent will be returned.
+ * @height: a pointer to a #long into which the image y extent will be returned.
+ * @ctype: the desired coordinate system into which to return the results,
+ *         (e.g. SPI_COORD_TYPE_WINDOW, SPI_COORD_TYPE_SCREEN).
+ *
+ * Get the bounding box of the image displayed in a
+ *         specified #AccessibleImage implementor.
+ **/
+void
+AccessibleImage_getImageExtents (AccessibleImage *obj,
+                                long *x,
+                                long *y,
+                                long *width,
+                                long *height,
+                                AccessibleCoordType ctype)
+{
+  Accessibility_BoundingBox bbox;
+
+  cspi_return_if_fail (obj != NULL);
+
+  cspi_dbus_call (obj, spi_interface_image, "getImageExtents", NULL, "=>(iiii)", &bbox);
+
+  if (!cspi_check_ev ("getImageExtents"))
+    {
+      *x = *y = *width = *height = 0;
+    }
+  else
+    {
+      *x = bbox.x;
+      *y = bbox.y;
+      *width = bbox.width;
+      *height = bbox.height;
+    }
+}
+
+/**
+ * AccessibleImage_getImageLocale:
+ * @obj: The #AccessibleImage being queried.
+ *
+ * Get the locale associated with an image and its textual representation.
+ *
+ * Returns: A POSIX LC_MESSAGES-style Locale value for image description and text.
+ **/
+char *
+AccessibleImage_getImageLocale  (AccessibleImage *obj)
+{
+    char *retval = "C";
+
+    cspi_return_val_if_fail (obj != NULL, "C");
+
+  cspi_dbus_get_property (obj, spi_interface_image, "imageLocale", NULL, "=>s", &retval);
+
+    cspi_return_val_if_ev ("getImageLocale", NULL);
+
+    return retval;
+}
+