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);
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_sink (cell->renderer);
92 gail_image_cell_init (GailImageCell *image_cell)
94 image_cell->image_description = NULL;
99 gail_image_cell_finalize (GObject *object)
101 GailImageCell *image_cell = GAIL_IMAGE_CELL (object);
103 g_free (image_cell->image_description);
104 G_OBJECT_CLASS (gail_image_cell_parent_class)->finalize (object);
108 gail_image_cell_update_cache (GailRendererCell *cell,
109 gboolean emit_change_signal)
115 atk_image_interface_init (AtkImageIface *iface)
117 iface->get_image_description = gail_image_cell_get_image_description;
118 iface->set_image_description = gail_image_cell_set_image_description;
119 iface->get_image_position = gail_image_cell_get_image_position;
120 iface->get_image_size = gail_image_cell_get_image_size;
124 gail_image_cell_get_image_description (AtkImage *image)
126 GailImageCell *image_cell;
128 image_cell = GAIL_IMAGE_CELL (image);
129 return image_cell->image_description;
133 gail_image_cell_set_image_description (AtkImage *image,
134 const gchar *description)
136 GailImageCell *image_cell;
138 image_cell = GAIL_IMAGE_CELL (image);
139 g_free (image_cell->image_description);
140 image_cell->image_description = g_strdup (description);
141 if (image_cell->image_description)
148 gail_image_cell_get_image_position (AtkImage *image,
151 AtkCoordType coord_type)
153 atk_component_get_position (ATK_COMPONENT (image), x, y, coord_type);
157 gail_image_cell_get_image_size (AtkImage *image,
161 GailImageCell *cell = GAIL_IMAGE_CELL (image);
162 GtkCellRenderer *cell_renderer;
165 cell_renderer = GAIL_RENDERER_CELL (cell)->renderer;
166 g_object_get (GTK_CELL_RENDERER_PIXBUF (cell_renderer), "pixbuf", &pixbuf, NULL);
168 *width = gdk_pixbuf_get_width (pixbuf);
169 *height = gdk_pixbuf_get_height (pixbuf);