1 /* GAIL - The GNOME Accessibility Implementation Library
2 * Copyright 2001 Sun Microsystems Inc.
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.
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.
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.
22 #undef GTK_DISABLE_DEPRECATED
26 #include "gailpixmap.h"
28 static void gail_pixmap_class_init (GailPixmapClass *klass);
29 static void gail_pixmap_init (GailPixmap *pixmap);
30 static void gail_pixmap_initialize (AtkObject *accessible,
34 static void atk_image_interface_init (AtkImageIface *iface);
35 static G_CONST_RETURN gchar* gail_pixmap_get_image_description
37 static void gail_pixmap_get_image_position
41 AtkCoordType coord_type);
42 static void gail_pixmap_get_image_size (AtkImage *obj,
45 static gboolean gail_pixmap_set_image_description
47 const gchar *description);
48 static void gail_pixmap_finalize (GObject *object);
50 G_DEFINE_TYPE_WITH_CODE (GailPixmap, gail_pixmap, GAIL_TYPE_WIDGET,
51 G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init))
54 gail_pixmap_class_init (GailPixmapClass *klass)
56 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
57 AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
59 atk_object_class->initialize = gail_pixmap_initialize;
61 gobject_class->finalize = gail_pixmap_finalize;
65 gail_pixmap_init (GailPixmap *pixmap)
67 pixmap->image_description = NULL;
71 gail_pixmap_initialize (AtkObject *accessible,
74 ATK_OBJECT_CLASS (gail_pixmap_parent_class)->initialize (accessible, data);
76 accessible->role = ATK_ROLE_ICON;
80 atk_image_interface_init (AtkImageIface *iface)
82 iface->get_image_description = gail_pixmap_get_image_description;
83 iface->get_image_position = gail_pixmap_get_image_position;
84 iface->get_image_size = gail_pixmap_get_image_size;
85 iface->set_image_description = gail_pixmap_set_image_description;
88 static G_CONST_RETURN gchar*
89 gail_pixmap_get_image_description (AtkImage *obj)
93 g_return_val_if_fail (GAIL_IS_PIXMAP (obj), NULL);
95 pixmap = GAIL_PIXMAP (obj);
97 return pixmap->image_description;
101 gail_pixmap_get_image_position (AtkImage *obj,
104 AtkCoordType coord_type)
106 atk_component_get_position (ATK_COMPONENT (obj), x, y, coord_type);
110 gail_pixmap_get_image_size (AtkImage *obj,
120 g_return_if_fail (GAIL_IS_PIXMAP (obj));
122 widget = GTK_ACCESSIBLE (obj)->widget;
124 /* State is defunct */
127 g_return_if_fail (GTK_IS_PIXMAP (widget));
129 pixmap = GTK_PIXMAP (widget);
132 gdk_drawable_get_size (pixmap->pixmap, width, height);
136 gail_pixmap_set_image_description (AtkImage *obj,
137 const gchar *description)
141 g_return_val_if_fail (GAIL_IS_PIXMAP (obj), FALSE);
143 pixmap = GAIL_PIXMAP (obj);
144 g_free (pixmap->image_description);
146 pixmap->image_description = g_strdup (description);
152 gail_pixmap_finalize (GObject *object)
154 GailPixmap *pixmap = GAIL_PIXMAP (object);
156 g_free (pixmap->image_description);
157 G_OBJECT_CLASS (gail_pixmap_parent_class)->finalize (object);