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.
23 #include "gailpixmap.h"
25 static void gail_pixmap_class_init (GailPixmapClass *klass);
26 static void gail_pixmap_init (GailPixmap *pixmap);
29 static void atk_image_interface_init (AtkImageIface *iface);
30 static G_CONST_RETURN gchar* gail_pixmap_get_image_description
32 static void gail_pixmap_get_image_position
36 AtkCoordType coord_type);
37 static void gail_pixmap_get_image_size (AtkImage *obj,
40 static gboolean gail_pixmap_set_image_description
42 const gchar *description);
43 static void gail_pixmap_finalize (GObject *object);
45 G_DEFINE_TYPE_WITH_CODE (GailPixmap, gail_pixmap, GAIL_TYPE_WIDGET,
46 G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init))
49 gail_pixmap_class_init (GailPixmapClass *klass)
51 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
53 gobject_class->finalize = gail_pixmap_finalize;
57 gail_pixmap_init (GailPixmap *pixmap)
59 pixmap->image_description = NULL;
63 gail_pixmap_new (GtkWidget *widget)
66 AtkObject *accessible;
68 g_assert (GTK_IS_PIXMAP (widget));
69 g_return_val_if_fail (GTK_IS_PIXMAP (widget), NULL);
71 object = g_object_new (GAIL_TYPE_PIXMAP, NULL);
73 accessible = ATK_OBJECT (object);
74 atk_object_initialize (accessible, widget);
76 accessible->role = ATK_ROLE_ICON;
82 atk_image_interface_init (AtkImageIface *iface)
84 iface->get_image_description = gail_pixmap_get_image_description;
85 iface->get_image_position = gail_pixmap_get_image_position;
86 iface->get_image_size = gail_pixmap_get_image_size;
87 iface->set_image_description = gail_pixmap_set_image_description;
90 static G_CONST_RETURN gchar*
91 gail_pixmap_get_image_description (AtkImage *obj)
95 g_return_val_if_fail (GAIL_IS_PIXMAP (obj), NULL);
97 pixmap = GAIL_PIXMAP (obj);
99 return pixmap->image_description;
103 gail_pixmap_get_image_position (AtkImage *obj,
106 AtkCoordType coord_type)
108 atk_component_get_position (ATK_COMPONENT (obj), x, y, coord_type);
112 gail_pixmap_get_image_size (AtkImage *obj,
122 g_return_if_fail (GAIL_IS_PIXMAP (obj));
124 widget = GTK_ACCESSIBLE (obj)->widget;
126 /* State is defunct */
129 g_return_if_fail (GTK_IS_PIXMAP (widget));
131 pixmap = GTK_PIXMAP (widget);
134 gdk_window_get_size (pixmap->pixmap, width, height);
138 gail_pixmap_set_image_description (AtkImage *obj,
139 const gchar *description)
143 g_return_val_if_fail (GAIL_IS_PIXMAP (obj), FALSE);
145 pixmap = GAIL_PIXMAP (obj);
146 g_free (pixmap->image_description);
148 pixmap->image_description = g_strdup (description);
154 gail_pixmap_finalize (GObject *object)
156 GailPixmap *pixmap = GAIL_PIXMAP (object);
158 g_free (pixmap->image_description);
159 G_OBJECT_CLASS (gail_pixmap_parent_class)->finalize (object);