1 /* GAIL - The GNOME Accessibility Enabling 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 "gailimagecell.h"
25 static void gail_image_cell_class_init (GailImageCellClass *klass);
26 static void gail_image_cell_init (GailImageCell *image_cell);
28 static void gail_image_cell_finalize (GObject *object);
31 static void atk_image_interface_init (AtkImageIface *iface);
32 static G_CONST_RETURN gchar *
33 gail_image_cell_get_image_description (AtkImage *image);
34 static gboolean gail_image_cell_set_image_description (AtkImage *image,
35 const gchar *description);
36 static void gail_image_cell_get_image_position (AtkImage *image,
39 AtkCoordType coord_type);
40 static void gail_image_cell_get_image_size (AtkImage *image,
46 static gboolean gail_image_cell_update_cache (GailRendererCell *cell,
47 gboolean emit_change_signal);
49 // FIXMEchpe static!!!
50 gchar *gail_image_cell_property_list[] = {
55 G_DEFINE_TYPE_WITH_CODE (GailImageCell, gail_image_cell, GAIL_TYPE_RENDERER_CELL,
56 G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init))
59 gail_image_cell_class_init (GailImageCellClass *klass)
61 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
62 GailRendererCellClass *renderer_cell_class = GAIL_RENDERER_CELL_CLASS(klass);
64 gobject_class->finalize = gail_image_cell_finalize;
66 renderer_cell_class->update_cache = gail_image_cell_update_cache;
67 renderer_cell_class->property_list = gail_image_cell_property_list;
71 gail_image_cell_new (void)
74 AtkObject *atk_object;
75 GailRendererCell *cell;
77 object = g_object_new (GAIL_TYPE_IMAGE_CELL, NULL);
79 g_return_val_if_fail (object != NULL, NULL);
81 atk_object = ATK_OBJECT (object);
82 atk_object->role = ATK_ROLE_TABLE_CELL;
84 cell = GAIL_RENDERER_CELL(object);
86 cell->renderer = gtk_cell_renderer_pixbuf_new ();
87 g_object_ref (cell->renderer);
88 gtk_object_sink (GTK_OBJECT (cell->renderer));
93 gail_image_cell_init (GailImageCell *image_cell)
95 image_cell->image_description = NULL;
100 gail_image_cell_finalize (GObject *object)
102 GailImageCell *image_cell = GAIL_IMAGE_CELL (object);
104 g_free (image_cell->image_description);
105 G_OBJECT_CLASS (gail_image_cell_parent_class)->finalize (object);
109 gail_image_cell_update_cache (GailRendererCell *cell,
110 gboolean emit_change_signal)
116 atk_image_interface_init (AtkImageIface *iface)
118 iface->get_image_description = gail_image_cell_get_image_description;
119 iface->set_image_description = gail_image_cell_set_image_description;
120 iface->get_image_position = gail_image_cell_get_image_position;
121 iface->get_image_size = gail_image_cell_get_image_size;
124 static G_CONST_RETURN gchar *
125 gail_image_cell_get_image_description (AtkImage *image)
127 GailImageCell *image_cell;
129 image_cell = GAIL_IMAGE_CELL (image);
130 return image_cell->image_description;
134 gail_image_cell_set_image_description (AtkImage *image,
135 const gchar *description)
137 GailImageCell *image_cell;
139 image_cell = GAIL_IMAGE_CELL (image);
140 g_free (image_cell->image_description);
141 image_cell->image_description = g_strdup (description);
142 if (image_cell->image_description)
149 gail_image_cell_get_image_position (AtkImage *image,
152 AtkCoordType coord_type)
154 atk_component_get_position (ATK_COMPONENT (image), x, y, coord_type);
158 gail_image_cell_get_image_size (AtkImage *image,
162 GailImageCell *cell = GAIL_IMAGE_CELL (image);
163 GtkCellRenderer *cell_renderer;
166 cell_renderer = GAIL_RENDERER_CELL (cell)->renderer;
167 pixbuf = GTK_CELL_RENDERER_PIXBUF (cell_renderer)->pixbuf;
169 *width = gdk_pixbuf_get_width (pixbuf);
170 *height = gdk_pixbuf_get_height (pixbuf);