2001-12-10 Michael Meeks <michael@ximian.com>
[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
30 SpiImage *
31 spi_image_interface_new (AtkObject *obj)
32 {
33   SpiImage *new_image = g_object_new (SPI_IMAGE_TYPE, NULL);
34
35   spi_base_construct (SPI_BASE (new_image), obj);
36
37   return new_image;
38 }
39
40
41 static AtkImage *
42 get_image_from_servant (PortableServer_Servant servant)
43 {
44   SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
45
46   if (!object)
47     {
48       return NULL;
49     }
50
51   return ATK_IMAGE (object->atko);
52 }
53
54
55 static void 
56 impl_getImagePosition (PortableServer_Servant servant,
57                        CORBA_long * x, CORBA_long * y,
58                        const CORBA_short coordType,
59                        CORBA_Environment *ev)
60 {
61   AtkImage *image = get_image_from_servant (servant);
62
63   g_return_if_fail (image != NULL);
64
65   atk_image_get_image_position (image,
66                                 (gint *) x, (gint *) y,
67                                 (AtkCoordType) coordType);
68 }
69
70
71 static void 
72 impl_getImageSize (PortableServer_Servant servant,
73                    CORBA_long * width, CORBA_long * height,
74                    CORBA_Environment *ev)
75 {
76   AtkImage *image = get_image_from_servant (servant);
77
78   g_return_if_fail (image != NULL);
79
80   atk_image_get_image_size (image,
81                             (gint *) width, (gint *) height);
82 }
83
84
85 static CORBA_string 
86 impl__get_imageDescription (PortableServer_Servant servant,
87                             CORBA_Environment     *ev)
88 {
89   const char *rv;
90   AtkImage   *image = get_image_from_servant (servant);
91
92   g_return_val_if_fail (image != NULL, CORBA_string_dup (""));
93
94   rv = atk_image_get_image_description (image);
95
96   if (rv)
97     {
98       return CORBA_string_dup (rv);
99     }
100   else
101     {
102       return CORBA_string_dup ("");
103     }
104 }
105
106
107 static void
108 spi_image_class_init (SpiImageClass *klass)
109 {
110   POA_Accessibility_Image__epv *epv = &klass->epv;
111
112   /* Initialize epv table */
113
114   epv->getImagePosition = impl_getImagePosition;
115   epv->getImageSize = impl_getImageSize;
116   epv->_get_imageDescription = impl__get_imageDescription;
117 }
118
119 static void
120 spi_image_init (SpiImage *image)
121 {
122 }
123
124 BONOBO_TYPE_FUNC_FULL (SpiImage,
125                        Accessibility_Image,
126                        SPI_TYPE_BASE,
127                        spi_image);