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 Lesser General Public
11
 * License as published by the Free Software Foundation; either
12
 * version 2.1 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
 * Lesser General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public
20
 * License along with this library; if not, write to the
21
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22
 * Boston, MA 02110-1301, 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
 * Gets the description of the image displayed in an #AtspiImage object.
32
 *
33
 * Returns: a UTF-8 string describing the image.
34
 **/
35
gchar *
36
1
atspi_image_get_image_description (AtspiImage *obj, GError **error)
37
{
38
1
  char *retval = NULL;
39

            
40
1
  g_return_val_if_fail (obj != NULL, NULL);
41

            
42
1
  _atspi_dbus_get_property (obj, atspi_interface_image, "ImageDescription", error, "s", &retval);
43

            
44
1
  return retval;
45
}
46

            
47
/**
48
 * atspi_image_get_image_size:
49
 * @obj: a pointer to the #AtspiImage to query.
50
 *
51
 * Gets the size of the image displayed in a specified #AtspiImage object.
52
 * The returned values are meaningful only if the Image has both
53
 * STATE_VISIBLE and STATE_SHOWING.
54
 *
55
 * Returns: a pointer to an #AtspiPoint where x corresponds to
56
 * the image's width and y corresponds to the image's height.
57
 *
58
 **/
59
AtspiPoint *
60
1
atspi_image_get_image_size (AtspiImage *obj, GError **error)
61
{
62
  dbus_int32_t d_w, d_h;
63
  AtspiPoint ret;
64

            
65
1
  ret.x = ret.y = -1;
66
1
  if (!obj)
67
    return atspi_point_copy (&ret);
68

            
69
1
  _atspi_dbus_call (obj, atspi_interface_image, "GetImageSize", error, "=>ii", &d_w, &d_h);
70
1
  ret.x = d_w;
71
1
  ret.y = d_h;
72
1
  return atspi_point_copy (&ret);
73
}
74

            
75
/**
76
 * atspi_image_get_image_position:
77
 * @obj: a pointer to the #AtspiImage implementor to query.
78
 * @ctype: the desired coordinate system into which to return the results,
79
 *         (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
80
 *
81
 * Gets the minimum x and y coordinates of the image displayed in a
82
 *         specified #AtspiImage implementor.
83
 * The returned values are meaningful only if the Image has both
84
 * STATE_VISIBLE and STATE_SHOWING.
85
 *
86
 * Returns: a pointer to an #AtspiPoint where x and y correspond to the
87
 * minimum coordinates of the displayed image.
88
 *
89
 **/
90
AtspiPoint *
91
1
atspi_image_get_image_position (AtspiImage *obj,
92
                                AtspiCoordType ctype,
93
                                GError **error)
94
{
95
  dbus_int32_t d_x, d_y;
96
1
  dbus_uint32_t d_ctype = ctype;
97
  AtspiPoint ret;
98

            
99
1
  ret.x = ret.y = 0;
100

            
101
1
  if (!obj)
102
    return atspi_point_copy (&ret);
103

            
104
1
  _atspi_dbus_call (obj, atspi_interface_image, "GetImagePosition", error, "u=>ii", d_ctype, &d_x, &d_y);
105

            
106
1
  ret.x = d_x;
107
1
  ret.y = d_y;
108
1
  return atspi_point_copy (&ret);
109
}
110

            
111
/**
112
 * atspi_image_get_image_extents:
113
 * @obj: a pointer to the #AtspiImage implementor to query.
114
 * @ctype: the desired coordinate system into which to return the results,
115
 *         (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
116
 *
117
 * Gets the bounding box of the image displayed in a
118
 *         specified #AtspiImage implementor.
119
 * The returned values are meaningful only if the Image has both
120
 * STATE_VISIBLE and STATE_SHOWING.
121
 *
122
 * Returns: a pointer to an #AtspiRect corresponding to the image's bounding box. The minimum x and y coordinates,
123
 * width, and height are specified.
124
 **/
125
AtspiRect *
126
1
atspi_image_get_image_extents (AtspiImage *obj,
127
                               AtspiCoordType ctype,
128
                               GError **error)
129
{
130
1
  dbus_uint32_t d_ctype = ctype;
131
  AtspiRect bbox;
132

            
133
1
  bbox.x = bbox.y = bbox.width = bbox.height = -1;
134
1
  g_return_val_if_fail (obj != NULL, atspi_rect_copy (&bbox));
135

            
136
1
  _atspi_dbus_call (obj, atspi_interface_image, "GetImageExtents", error, "u=>(iiii)", d_ctype, &bbox);
137

            
138
1
  return atspi_rect_copy (&bbox);
139
}
140

            
141
/**
142
 * atspi_image_get_image_locale:
143
 * @obj: a pointer to the #AtspiImage to query.
144
 *
145
 * Gets the locale associated with an image and its textual representation.
146
 *
147
 * Returns: A POSIX LC_MESSAGES-style locale value for image description and text.
148
 **/
149
gchar *
150
1
atspi_image_get_image_locale (AtspiImage *obj, GError **error)
151
{
152
1
  gchar *retval = NULL;
153

            
154
1
  g_return_val_if_fail (obj != NULL, g_strdup ("C"));
155

            
156
1
  _atspi_dbus_get_property (obj, atspi_interface_image, "ImageLocale", error, "s", &retval);
157

            
158
1
  return retval;
159
}
160

            
161
static void
162
4
atspi_image_base_init (AtspiImage *klass)
163
{
164
4
}
165

            
166
GType
167
8
atspi_image_get_type (void)
168
{
169
  static GType type = 0;
170

            
171
8
  if (!type)
172
    {
173
      static const GTypeInfo tinfo = {
174
        sizeof (AtspiImage),
175
        (GBaseInitFunc) atspi_image_base_init,
176
        (GBaseFinalizeFunc) NULL,
177
      };
178

            
179
2
      type = g_type_register_static (G_TYPE_INTERFACE, "AtspiImage", &tinfo, 0);
180
    }
181
8
  return type;
182
}