Started fixing IDL docs.
[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 /* image.c : implements the Image interface */
24
25 #include <config.h>
26 #include <stdio.h>
27 #include <libspi/image.h>
28
29 /* A pointer to our parent object class */
30 static GObjectClass *parent_class;
31
32 static void
33 spi_image_finalize (GObject *obj)
34 {
35   SpiImage *image = SPI_IMAGE (obj);
36   g_object_unref (image->atko);
37   image->atko = NULL;
38   parent_class->finalize (obj);
39 }
40
41 SpiImage *
42 spi_image_interface_new (AtkObject *obj)
43 {
44   SpiImage *new_image = g_object_new (SPI_IMAGE_TYPE, NULL);
45   new_image->atko = obj;
46   g_object_ref (obj);
47   return new_image;
48 }
49
50
51
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 {
58   SpiImage *image = SPI_IMAGE (bonobo_object_from_servant(_servant));
59   atk_image_get_image_position (ATK_IMAGE(image->atko),
60                                 (gint *) x, (gint *) y,
61                                 (AtkCoordType) coordType);
62 }
63
64
65
66 static void 
67 impl_getImageSize (PortableServer_Servant _servant,
68                    CORBA_long * width, CORBA_long * height,
69                             CORBA_Environment * ev)
70 {
71   SpiImage *image = SPI_IMAGE (bonobo_object_from_servant(_servant));
72   atk_image_get_image_size (ATK_IMAGE(image->atko),
73                             (gint *) width, (gint *) height);
74 }
75
76
77
78 static CORBA_string 
79 impl__get_imageDescription (PortableServer_Servant servant,
80                             CORBA_Environment     *ev)
81 {
82   SpiImage *image;
83   const char *rv;
84
85   image = SPI_IMAGE (bonobo_object_from_servant (servant));
86
87   rv = atk_image_get_image_description (ATK_IMAGE (image->atko));
88   if (rv)
89     return CORBA_string_dup (rv);
90   else
91     return CORBA_string_dup ("");
92 }
93
94
95 static void
96 spi_image_class_init (SpiImageClass *klass)
97 {
98   GObjectClass * object_class = (GObjectClass *) klass;
99   POA_Accessibility_Image__epv *epv = &klass->epv;
100   parent_class = g_type_class_peek_parent (klass);
101
102   object_class->finalize = spi_image_finalize;
103
104
105   /* Initialize epv table */
106
107   epv->getImagePosition = impl_getImagePosition;
108   epv->getImageSize = impl_getImageSize;
109   epv->_get_imageDescription = impl__get_imageDescription;
110 }
111
112 static void
113 spi_image_init (SpiImage *image)
114 {
115 }
116
117 BONOBO_TYPE_FUNC_FULL (SpiImage,
118                        Accessibility_Image,
119                        BONOBO_TYPE_OBJECT,
120                        spi_image);