Remove all instances of g_return_if_fail (foo != NULL); that are
[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_image_description:
44  * @image: a #GObject instance that implements AtkImageIface
45  *
46  * Get a textual description of this image.
47  *
48  * Returns: a string representing the image description
49  **/
50 G_CONST_RETURN gchar*
51 atk_image_get_image_description (AtkImage *image)
52 {
53   AtkImageIface *iface;
54
55   g_return_val_if_fail (ATK_IS_IMAGE (image), NULL);
56
57   iface = ATK_IMAGE_GET_IFACE (image);
58
59   if (iface->get_image_description)
60     {
61       return (iface->get_image_description) (image);
62     }
63   else
64     {
65       return NULL;
66     }
67 }
68
69 /**
70  * atk_image_get_image_size:
71  * @image: a #GObject instance that implements AtkImageIface
72  * @height: filled with the image height
73  * @width: filled with the image width
74  *
75  * Get the height and width in pixels for the specified image.
76  **/
77 void
78 atk_image_get_image_size (AtkImage *image, int *height, int *width)
79 {
80   AtkImageIface *iface;
81
82   g_return_if_fail (ATK_IS_IMAGE (image));
83
84   iface = ATK_IMAGE_GET_IFACE (image);
85
86   if (iface->get_image_size)
87     iface->get_image_size (image, height, width);
88 }
89
90 /**
91  * atk_image_set_image_description:
92  * @image: a #GObject instance that implements AtkImageIface
93  * @description: a string description to set for @image
94  *
95  * Sets the textual description for this image.
96  *
97  * Returns: boolean TRUE, or FALSE if operation could
98  * not be completed.
99  **/
100 gboolean
101 atk_image_set_image_description (AtkImage        *image,
102                               const gchar     *description)
103 {
104   AtkImageIface *iface;
105
106   g_return_val_if_fail (ATK_IS_IMAGE (image), FALSE);
107
108   iface = ATK_IMAGE_GET_IFACE (image);
109
110   if (iface->set_image_description)
111     {
112       return (iface->set_image_description) (image, description);
113     }
114   else
115     {
116       return FALSE;
117     }
118 }
119
120 /**
121  * atk_image_get_position:
122  * @image: a #GObject instance that implements AtkImageIface
123  * @x: address of #gint to put x coordinate position
124  * @y: address of #gint to put y coordinate position
125  * @coord_type: specifies whether the coordinates are relative to the screen
126  * or to the components top level window
127  * 
128  * Gets the position of the image in the form of a point specifying the
129  * images top-left corner
130  **/
131 void     
132 atk_image_get_position (AtkImage *image,
133                         gint *x,
134                         gint *y,
135                         AtkCoordType coord_type)
136 {
137   AtkImageIface *iface;
138
139   g_return_if_fail (ATK_IS_IMAGE (image));
140
141   iface = ATK_IMAGE_GET_IFACE (image);
142
143   if (iface->get_position)
144     (iface->get_position) (image, x, y, coord_type);
145 }
146
147
148
149
150
151