6428ff82ac8eba92cbaf97dd37aa727277b77245
[platform/core/uifw/at-spi2-atk.git] / libspi / 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 Sun Microsystems Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 /*
24  * component.c : bonobo wrapper for accessible component implementation
25  *
26  */
27 #include <config.h>
28 #include <bonobo/Bonobo.h>
29
30 #include <stdio.h>
31
32 /*
33  * This pulls the CORBA definitions for the "Accessibility::Accessible" server
34  */
35 #include <libspi/Accessibility.h>
36
37 /*
38  * This pulls the definition of the image bonobo object
39  */
40 #include "image.h"
41
42 /*
43  * Static function declarations
44  */
45
46 static void
47 image_class_init (ImageClass *klass);
48 static void
49 image_init (Image *image);
50 static void
51 image_finalize (GObject *obj);
52 static void 
53 impl_getImagePosition (PortableServer_Servant _servant,
54                        CORBA_long * x, CORBA_long * y,
55                        const CORBA_short coordType,
56                        CORBA_Environment * ev);
57 static void 
58 impl_getImageSize (PortableServer_Servant _servant,
59                    CORBA_long * width, CORBA_long * height,
60                    CORBA_Environment * ev);
61 static CORBA_string 
62 impl__get_imageDescription (PortableServer_Servant _servant,
63                           CORBA_Environment * ev);
64
65
66 static GObjectClass *parent_class;
67
68 GType
69 image_get_type (void)
70 {
71   static GType type = 0;
72
73   if (!type) {
74     static const GTypeInfo tinfo = {
75       sizeof (ImageClass),
76       (GBaseInitFunc) NULL,
77       (GBaseFinalizeFunc) NULL,
78       (GClassInitFunc) image_class_init,
79       (GClassFinalizeFunc) NULL,
80       NULL, /* class data */
81       sizeof (Image),
82       0, /* n preallocs */
83       (GInstanceInitFunc) image_init,
84                         NULL /* value table */
85     };
86
87     /*
88      * Bonobo_type_unique auto-generates a load of
89      * CORBA structures for us. All derived types must
90      * use bonobo_type_unique.
91      */
92     type = bonobo_type_unique (
93                                BONOBO_OBJECT_TYPE,
94                                POA_Accessibility_Image__init,
95                                NULL,
96                                G_STRUCT_OFFSET (ImageClass, epv),
97                                &tinfo,
98                                "AccessibleImage");
99   }
100
101   return type;
102 }
103
104 static void
105 image_class_init (ImageClass *klass)
106 {
107   GObjectClass * object_class = (GObjectClass *) klass;
108   POA_Accessibility_Image__epv *epv = &klass->epv;
109   parent_class = g_type_class_peek_parent (klass);
110
111   object_class->finalize = image_finalize;
112
113
114   /* Initialize epv table */
115
116   epv->getImagePosition = impl_getImagePosition;
117   epv->getImageSize = impl_getImageSize;
118   epv->_get_imageDescription = impl__get_imageDescription;
119 }
120
121 static void
122 image_init (Image *image)
123 {
124 }
125
126 static void
127 image_finalize (GObject *obj)
128 {
129   Image *image = IMAGE (obj);
130   image->atk_image = NULL;
131   parent_class->finalize (obj);
132 }
133
134 Image *
135 image_new (AtkImage *image)
136 {
137   Image *new_image = 
138     IMAGE(g_object_new (IMAGE_TYPE, NULL));
139   new_image->atk_image = image;
140   return new_image;
141 }
142
143
144
145 static void 
146 impl_getImagePosition (PortableServer_Servant _servant,
147                        CORBA_long * x, CORBA_long * y,
148                        const CORBA_short coordType,
149                        CORBA_Environment * ev)
150 {
151   Image *image = IMAGE (bonobo_object_from_servant(_servant));
152   atk_image_get_image_position (image->atk_image,
153                                 (gint *) x, (gint *) y,
154                                 (AtkCoordType) coordType);
155 }
156
157
158
159 static void 
160 impl_getImageSize (PortableServer_Servant _servant,
161                    CORBA_long * width, CORBA_long * height,
162                             CORBA_Environment * ev)
163 {
164   Image *image = IMAGE (bonobo_object_from_servant(_servant));
165   atk_image_get_image_size (image->atk_image,
166                             (gint *) width, (gint *) height);
167 }
168
169
170
171 static CORBA_string 
172 impl__get_imageDescription (PortableServer_Servant _servant,
173                           CORBA_Environment * ev)
174 {
175   Image *image = IMAGE (bonobo_object_from_servant(_servant));
176   return CORBA_string_dup (
177                            atk_image_get_image_description (image->atk_image));
178 }
179
180
181