]> Pileus Git - ~andy/gtk/blob - gtk/a11y/gtkcontainercellaccessible.c
Change FSF Address
[~andy/gtk] / gtk / a11y / gtkcontainercellaccessible.c
1 /* GAIL - The GNOME Accessibility Enabling Library
2  * Copyright 2001 Sun Microsystems Inc.
3  *
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.
8  *
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.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include "config.h"
19
20 #include <gtk/gtk.h>
21 #include "gtkcontainercellaccessible.h"
22
23
24 G_DEFINE_TYPE (GtkContainerCellAccessible, _gtk_container_cell_accessible, GTK_TYPE_CELL_ACCESSIBLE)
25
26
27 static void
28 gtk_container_cell_accessible_finalize (GObject *obj)
29 {
30   GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
31
32   g_list_free_full (container->children, g_object_unref);
33
34   G_OBJECT_CLASS (_gtk_container_cell_accessible_parent_class)->finalize (obj);
35 }
36
37
38 static gint
39 gtk_container_cell_accessible_get_n_children (AtkObject *obj)
40 {
41   GtkContainerCellAccessible *cell = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
42
43   return cell->NChildren;
44 }
45
46 static AtkObject *
47 gtk_container_cell_accessible_ref_child (AtkObject *obj,
48                                          gint       child)
49 {
50   GtkContainerCellAccessible *cell = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
51   GList *l;
52
53   l = g_list_nth (cell->children, child);
54   if (l == NULL)
55     return NULL;
56
57   return g_object_ref (ATK_OBJECT (l->data));
58 }
59
60 static void
61 gtk_container_cell_accessible_update_cache (GtkCellAccessible *cell)
62 {
63   GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (cell);
64   GList *l;
65
66   for (l = container->children; l; l = l->next)
67     {
68       _gtk_cell_accessible_update_cache (l->data);
69     }
70 }
71
72 static void
73 gtk_container_cell_widget_set (GtkAccessible *accessible)
74 {
75   GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (accessible);
76   GList *l;
77
78   for (l = container->children; l; l = l->next)
79     {
80       gtk_accessible_set_widget (l->data, gtk_accessible_get_widget (accessible));
81     }
82
83   GTK_ACCESSIBLE_CLASS (_gtk_container_cell_accessible_parent_class)->widget_unset (accessible);
84 }
85
86 static void
87 gtk_container_cell_widget_unset (GtkAccessible *accessible)
88 {
89   GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (accessible);
90   GList *l;
91
92   for (l = container->children; l; l = l->next)
93     {
94       gtk_accessible_set_widget (l->data, NULL);
95     }
96
97   GTK_ACCESSIBLE_CLASS (_gtk_container_cell_accessible_parent_class)->widget_unset (accessible);
98 }
99
100 static void
101 _gtk_container_cell_accessible_class_init (GtkContainerCellAccessibleClass *klass)
102 {
103   GtkCellAccessibleClass *cell_class = GTK_CELL_ACCESSIBLE_CLASS (klass);
104   GtkAccessibleClass *accessible_class = GTK_ACCESSIBLE_CLASS (klass);
105   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
106   GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
107
108   g_object_class->finalize = gtk_container_cell_accessible_finalize;
109
110   class->get_n_children = gtk_container_cell_accessible_get_n_children;
111   class->ref_child = gtk_container_cell_accessible_ref_child;
112
113   accessible_class->widget_unset = gtk_container_cell_widget_set;
114   accessible_class->widget_unset = gtk_container_cell_widget_unset;
115
116   cell_class->update_cache = gtk_container_cell_accessible_update_cache;
117 }
118
119 static void
120 _gtk_container_cell_accessible_init (GtkContainerCellAccessible *cell)
121 {
122 }
123
124 GtkContainerCellAccessible *
125 _gtk_container_cell_accessible_new (void)
126 {
127   GObject *object;
128   AtkObject *atk_object;
129   GtkContainerCellAccessible *container;
130
131   object = g_object_new (GTK_TYPE_CONTAINER_CELL_ACCESSIBLE, NULL);
132
133   g_return_val_if_fail (object != NULL, NULL);
134
135   atk_object = ATK_OBJECT (object);
136   atk_object->role = ATK_ROLE_TABLE_CELL;
137
138   container = GTK_CONTAINER_CELL_ACCESSIBLE (object);
139   container->children = NULL;
140   container->NChildren = 0;
141   return container;
142 }
143
144 void
145 _gtk_container_cell_accessible_add_child (GtkContainerCellAccessible *container,
146                                           GtkCellAccessible          *child)
147 {
148   g_return_if_fail (GTK_IS_CONTAINER_CELL_ACCESSIBLE (container));
149   g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (child));
150
151   container->NChildren++;
152   container->children = g_list_append (container->children, child);
153   atk_object_set_parent (ATK_OBJECT (child), ATK_OBJECT (container));
154 }
155
156 void
157 _gtk_container_cell_accessible_remove_child (GtkContainerCellAccessible *container,
158                                              GtkCellAccessible          *child)
159 {
160   g_return_if_fail (GTK_IS_CONTAINER_CELL_ACCESSIBLE (container));
161   g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (child));
162   g_return_if_fail (container->NChildren > 0);
163
164   container->children = g_list_remove (container->children, child);
165   container->NChildren--;
166 }