atk/atkaction.c, atk/atkcomponent.c, atk/atkeditabletext.c,
[platform/upstream/atk.git] / atk / atkimage.c
1 /* ATK -  Accessibility Toolkit
2  * Copyright 2001 Sun Microsystems Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include "atkimage.h"
21
22 GType
23 atk_image_get_type ()
24 {
25   static GType type = 0;
26
27   if (!type) {
28     static const GTypeInfo tinfo =
29     {
30       sizeof (AtkImageIface),
31       (GBaseInitFunc) NULL,
32       (GBaseFinalizeFunc) NULL,
33
34     };
35
36     type = g_type_register_static (G_TYPE_INTERFACE, "AtkImage", &tinfo, 0);
37   }
38
39   return type;
40 }
41
42 /**
43  * atk_image_get_storage_type:
44  * @image: a #GObject instance that implements AtkImageIface
45  *
46  * Gets the type of representation being used to store image data
47  *
48  * Returns: an #AtkStorageType representing the image storage type
49  **/
50 AtkImageType
51 atk_image_get_storage_type (AtkImage *obj)
52 {
53   AtkImageIface *iface;
54
55   g_return_val_if_fail (obj != NULL, 0);
56   g_return_val_if_fail (ATK_IS_IMAGE (obj), 0);
57
58   iface = ATK_IMAGE_GET_IFACE (obj);
59
60   if (iface->get_storage_type)
61     {
62       return (iface->get_storage_type) (obj);
63     }
64   else
65     {
66       return 0;
67     }
68 }
69
70 /**
71  * atk_image_get_image_description:
72  * @image: a #GObject instance that implements AtkImageIface
73  *
74  * Get a textual description of this image.
75  *
76  * Returns: a string representing the image description
77  **/
78 G_CONST_RETURN gchar*
79 atk_image_get_image_description (AtkImage *obj)
80 {
81   AtkImageIface *iface;
82
83   g_return_val_if_fail (obj != NULL, NULL);
84   g_return_val_if_fail (ATK_IS_IMAGE (obj), NULL);
85
86   iface = ATK_IMAGE_GET_IFACE (obj);
87
88   if (iface->get_image_description)
89     {
90       return (iface->get_image_description) (obj);
91     }
92   else
93     {
94       return NULL;
95     }
96 }
97
98 /**
99  * atk_image_get_image_height:
100  * @image: a #GObject instance that implements AtkImageIface
101  *
102  * Get the height, in pixels/screen coords, of this image.
103  *
104  * Returns: an integer representing the image height in pixel coords
105  **/
106 gint
107 atk_image_get_image_height (AtkImage *obj)
108 {
109   AtkImageIface *iface;
110
111   g_return_val_if_fail (obj != NULL, 0);
112   g_return_val_if_fail (ATK_IS_IMAGE (obj), 0);
113
114   iface = ATK_IMAGE_GET_IFACE (obj);
115
116   if (iface->get_image_height)
117     {
118       return (iface->get_image_height) (obj);
119     }
120   else
121     {
122       return 0;
123     }
124 }
125
126 /**
127  * atk_image_get_image_width:
128  * @image: a #GObject instance that implements AtkImageIface
129  *
130  * Get the width, in pixel/screen coords, of this image.
131  *
132  * Returns: an integer representing the image width
133  **/
134 gint
135 atk_image_get_image_width (AtkImage *obj)
136 {
137   AtkImageIface *iface;
138
139   g_return_val_if_fail (obj != NULL, 0);
140   g_return_val_if_fail (ATK_IS_IMAGE (obj), 0);
141
142   iface = ATK_IMAGE_GET_IFACE (obj);
143
144   if (iface->get_image_width)
145     {
146       return (iface->get_image_width) (obj);
147     }
148   else
149     {
150       return 0;
151     }
152 }
153
154 /**
155  * atk_image_set_image_description:
156  * @image: a #GObject instance that implements AtkImageIface
157  * @description: a string desciption to set for @image
158  *
159  * Sets the textual description for this image.
160  *
161  * Returns: boolean TRUE, or FALSE if operation could
162  * not be completed.
163  **/
164 gboolean
165 atk_image_set_image_description (AtkImage        *obj,
166                               const gchar     *description)
167 {
168   AtkImageIface *iface;
169
170   g_return_val_if_fail (obj != NULL, FALSE);
171   g_return_val_if_fail (ATK_IS_IMAGE (obj), FALSE);
172
173   iface = ATK_IMAGE_GET_IFACE (obj);
174
175   if (iface->set_image_description)
176     {
177       return (iface->set_image_description) (obj, description);
178     }
179   else
180     {
181       return FALSE;
182     }
183 }