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 "gtkcontainercellaccessible.h"
26 G_DEFINE_TYPE (GtkContainerCellAccessible, _gtk_container_cell_accessible, GTK_TYPE_CELL_ACCESSIBLE)
30 gtk_container_cell_accessible_finalize (GObject *obj)
32 GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
34 g_list_free_full (container->children, g_object_unref);
36 G_OBJECT_CLASS (_gtk_container_cell_accessible_parent_class)->finalize (obj);
41 gtk_container_cell_accessible_get_n_children (AtkObject *obj)
43 GtkContainerCellAccessible *cell = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
45 return cell->NChildren;
49 gtk_container_cell_accessible_ref_child (AtkObject *obj,
52 GtkContainerCellAccessible *cell = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
55 l = g_list_nth (cell->children, child);
59 return g_object_ref (ATK_OBJECT (l->data));
63 _gtk_container_cell_accessible_class_init (GtkContainerCellAccessibleClass *klass)
65 AtkObjectClass *class = ATK_OBJECT_CLASS(klass);
66 GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
68 g_object_class->finalize = gtk_container_cell_accessible_finalize;
70 class->get_n_children = gtk_container_cell_accessible_get_n_children;
71 class->ref_child = gtk_container_cell_accessible_ref_child;
75 _gtk_container_cell_accessible_init (GtkContainerCellAccessible *cell)
79 GtkContainerCellAccessible *
80 _gtk_container_cell_accessible_new (void)
83 AtkObject *atk_object;
84 GtkContainerCellAccessible *container;
86 object = g_object_new (GTK_TYPE_CONTAINER_CELL_ACCESSIBLE, NULL);
88 g_return_val_if_fail (object != NULL, NULL);
90 atk_object = ATK_OBJECT (object);
91 atk_object->role = ATK_ROLE_TABLE_CELL;
93 container = GTK_CONTAINER_CELL_ACCESSIBLE (object);
94 container->children = NULL;
95 container->NChildren = 0;
100 _gtk_container_cell_accessible_add_child (GtkContainerCellAccessible *container,
101 GtkCellAccessible *child)
103 g_return_if_fail (GTK_IS_CONTAINER_CELL_ACCESSIBLE (container));
104 g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (child));
106 container->NChildren++;
107 container->children = g_list_append (container->children, child);
108 atk_object_set_parent (ATK_OBJECT (child), ATK_OBJECT (container));
112 _gtk_container_cell_accessible_remove_child (GtkContainerCellAccessible *container,
113 GtkCellAccessible *child)
115 g_return_if_fail (GTK_IS_CONTAINER_CELL_ACCESSIBLE (container));
116 g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (child));
117 g_return_if_fail (container->NChildren > 0);
119 container->children = g_list_remove (container->children, child);
120 container->NChildren--;