Update copyright and add some missing license info
[platform/upstream/at-spi2-core.git] / atspi / atspi-image.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001, 2002 Sun Microsystems Inc.,
6  * Copyright 2001, 2002 Ximian, Inc.
7  * Copyright 2010, 2011 Novell, Inc.
8  *
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.
13  *
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.
18  *
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.
23  */
24
25 #include "atspi-private.h"
26
27 /**
28  * atspi_image_get_image_description:
29  * @obj: a pointer to the #AtspiImage implementor on which to operate.
30  *
31  * Get the description of the image displayed in an #AtspiImage object.
32  *
33  * Returns: a UTF-8 string describing the image.
34  **/
35 gchar *
36 atspi_image_get_image_description (AtspiImage *obj, GError **error)
37 {
38   char *retval = NULL;
39
40   g_return_val_if_fail (obj != NULL, NULL);
41
42   _atspi_dbus_get_property (obj, atspi_interface_image, "ImageDescription", error, "s", &retval);
43
44   return retval;
45 }
46
47 /**
48  * atspi_image_get_image_size:
49  * @obj: a pointer to the #AtspiImage to query.
50  *
51  * Get the size of the image displayed in a specified #AtspiImage object.
52  **/
53 AtspiPoint *
54 atspi_image_get_image_size (AtspiImage *obj, GError **error)
55 {
56   dbus_int32_t d_w, d_h;
57   AtspiPoint ret;
58
59   ret.x = ret.y = -1;
60   if (!obj)
61     return atspi_point_copy (&ret);
62
63   _atspi_dbus_call (obj, atspi_interface_image, "GetImageSize", error, "=>ii", &d_w, &d_h);
64   ret.x = d_w;
65   ret.y = d_h;
66   return atspi_point_copy (&ret);
67 }
68
69 /**
70  * atspi_image_get_image_position:
71  * @obj: a pointer to the #AtspiImage implementor to query.
72  * @ctype: the desired coordinate system into which to return the results,
73  *         (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
74  *
75  * Get the minimum x and y coordinates of the image displayed in a
76  *         specified #AtspiImage implementor.
77  **/
78 AtspiPoint *
79 atspi_image_get_image_position (AtspiImage *obj,
80                                 AtspiCoordType ctype,
81                                 GError **error)
82 {
83   dbus_int32_t d_x, d_y;
84   dbus_uint16_t d_ctype = ctype;
85   AtspiPoint ret;
86
87   ret.x = ret.y = 0;
88
89   if (!obj)
90     return atspi_point_copy (&ret);
91
92   _atspi_dbus_call (obj, atspi_interface_image, "GetImagePosition", error, "u=>ii", d_ctype, &d_x, &d_y);
93
94   ret.x = d_x;
95   ret.y = d_y;
96   return atspi_point_copy (&ret);
97 }
98
99 /**
100  * atspi_image_get_image_extents:
101  * @obj: a pointer to the #AtspiImage implementor to query.
102  * @ctype: the desired coordinate system into which to return the results,
103  *         (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
104  *
105  * Get the bounding box of the image displayed in a
106  *         specified #AtspiImage implementor.
107  **/
108 AtspiRect *
109 atspi_image_get_image_extents (AtspiImage *obj,
110                                AtspiCoordType ctype,
111                                GError **error)
112 {
113   dbus_uint32_t d_ctype = ctype;
114   AtspiRect bbox;
115
116   bbox.x = bbox.y = bbox.width = bbox.height = -1;
117   g_return_val_if_fail (obj != NULL, atspi_rect_copy (&bbox));
118
119   _atspi_dbus_call (obj, atspi_interface_image, "GetImageExtents", error, "u=>(iiii)", d_ctype, &bbox);
120
121   return atspi_rect_copy (&bbox);
122 }
123
124 /**
125  * atspi_image_get_image_locale:
126  * @obj: The #AtspiImage being queried.
127  *
128  * Get the locale associated with an image and its textual representation.
129  *
130  * Returns: A POSIX LC_MESSAGES-style Locale value for image description and text.
131  **/
132 gchar *
133 atspi_image_get_image_locale  (AtspiImage *obj, GError **error)
134 {
135   gchar *retval = NULL;
136
137   g_return_val_if_fail (obj != NULL, g_strdup ("C"));
138
139   _atspi_dbus_get_property (obj, atspi_interface_image, "ImageLocale", error, "s", &retval);
140
141   return retval;
142 }
143
144 static void
145 atspi_image_base_init (AtspiImage *klass)
146 {
147 }
148
149 GType
150 atspi_image_get_type (void)
151 {
152   static GType type = 0;
153
154   if (!type) {
155     static const GTypeInfo tinfo =
156     {
157       sizeof (AtspiImage),
158       (GBaseInitFunc) atspi_image_base_init,
159       (GBaseFinalizeFunc) NULL,
160     };
161
162     type = g_type_register_static (G_TYPE_INTERFACE, "AtspiImage", &tinfo, 0);
163
164   }
165   return type;
166 }