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.
25 #include "accessible.h"
28 get_image (DBusMessage * message)
30 AtkObject *obj = atk_dbus_get_object (dbus_message_get_path (message));
33 return ATK_IMAGE (obj);
37 get_image_from_path (const char *path, void *user_data)
39 AtkObject *obj = atk_dbus_get_object (path);
40 if (!obj || !ATK_IS_IMAGE(obj))
42 return ATK_IMAGE (obj);
46 impl_get_imageDescription (const char *path, DBusMessageIter * iter,
49 AtkImage *image = get_image_from_path (path, user_data);
52 return droute_return_v_string (iter,
53 atk_image_get_image_description (image));
57 impl_get_imageLocale (const char *path, DBusMessageIter * iter,
60 AtkImage *image = get_image_from_path (path, user_data);
63 return droute_return_v_string (iter, atk_image_get_image_locale (image));
67 impl_getImageExtents (DBusConnection * bus, DBusMessage * message,
70 AtkImage *image = get_image (message);
72 dbus_int16_t coordType;
73 gint ix, iy, iwidth, iheight;
76 return spi_dbus_general_error (message);
77 dbus_error_init (&error);
78 if (!dbus_message_get_args
79 (message, &error, DBUS_TYPE_INT16, &coordType, DBUS_TYPE_INVALID))
81 return SPI_DBUS_RETURN_ERROR (message, &error);
83 atk_image_get_image_size (image, &iwidth, &iheight);
84 atk_image_get_image_position (image, &ix, &iy, (AtkCoordType) coordType);
85 return spi_dbus_return_rect (message, ix, iy, iwidth, iheight);
89 impl_getImagePosition (DBusConnection * bus, DBusMessage * message,
92 AtkImage *image = get_image (message);
94 dbus_int16_t coord_type;
100 return spi_dbus_general_error (message);
101 dbus_error_init (&error);
102 if (!dbus_message_get_args
103 (message, &error, DBUS_TYPE_INT16, &coord_type, DBUS_TYPE_INVALID))
105 return SPI_DBUS_RETURN_ERROR (message, &error);
107 atk_image_get_image_position (image, &ix, &iy, (AtkCoordType) coord_type);
110 reply = dbus_message_new_method_return (message);
113 dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32,
114 &y, DBUS_TYPE_INVALID);
120 impl_getImageSize (DBusConnection * bus, DBusMessage * message,
123 AtkImage *image = get_image (message);
124 gint iwidth = 0, iheight = 0;
125 dbus_int32_t width, height;
129 return spi_dbus_general_error (message);
130 atk_image_get_image_size (image, &iwidth, &iheight);
133 reply = dbus_message_new_method_return (message);
136 dbus_message_append_args (reply, DBUS_TYPE_INT32, &width,
137 DBUS_TYPE_INT32, &height, DBUS_TYPE_INVALID);
142 static DRouteMethod methods[] = {
143 {impl_getImageExtents, "getImageExtents"},
144 {impl_getImagePosition, "getImagePosition"},
145 {impl_getImageSize, "getImageSize"},
149 static DRouteProperty properties[] = {
150 {impl_get_imageDescription, NULL, "imageDescription"},
151 {impl_get_imageLocale, NULL, "imageLocale"},
156 spi_initialize_image (DRouteData * data)
158 droute_add_interface (data, SPI_DBUS_INTERFACE_IMAGE, methods,
160 (DRouteGetDatumFunction) get_image_from_path, NULL);