]> Pileus Git - ~andy/gtk/blob - gtk/a11y/gtkbooleancellaccessible.c
Change FSF Address
[~andy/gtk] / gtk / a11y / gtkbooleancellaccessible.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 "gtkbooleancellaccessible.h"
22
23
24 G_DEFINE_TYPE (GtkBooleanCellAccessible, _gtk_boolean_cell_accessible, GTK_TYPE_RENDERER_CELL_ACCESSIBLE)
25
26
27 static AtkStateSet *
28 gtk_boolean_cell_accessible_ref_state_set (AtkObject *accessible)
29 {
30   GtkBooleanCellAccessible *cell = GTK_BOOLEAN_CELL_ACCESSIBLE (accessible);
31   AtkStateSet *state_set;
32
33   state_set = ATK_OBJECT_CLASS (_gtk_boolean_cell_accessible_parent_class)->ref_state_set (accessible);
34
35   if (cell->cell_value)
36     atk_state_set_add_state (state_set, ATK_STATE_CHECKED);
37
38   if (cell->cell_sensitive)
39     atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE);
40   else
41     atk_state_set_remove_state (state_set, ATK_STATE_SENSITIVE);
42
43   return state_set;
44 }
45
46 static void
47 gtk_boolean_cell_accessible_update_cache (GtkCellAccessible *cell)
48 {
49   GtkBooleanCellAccessible *boolean_cell = GTK_BOOLEAN_CELL_ACCESSIBLE (cell);
50   gboolean active;
51   gboolean sensitive;
52
53   g_object_get (G_OBJECT (GTK_RENDERER_CELL_ACCESSIBLE (cell)->renderer),
54                 "active", &active,
55                 "sensitive", &sensitive,
56                 NULL);
57
58   if (boolean_cell->cell_value != active)
59     {
60       boolean_cell->cell_value = !boolean_cell->cell_value;
61
62       atk_object_notify_state_change (ATK_OBJECT (cell), ATK_STATE_CHECKED, active);
63     }
64
65   if (boolean_cell->cell_sensitive != sensitive)
66     {
67       boolean_cell->cell_sensitive = !boolean_cell->cell_sensitive;
68
69       atk_object_notify_state_change (ATK_OBJECT (cell), ATK_STATE_CHECKED, sensitive);
70     }
71 }
72
73 static void
74 _gtk_boolean_cell_accessible_class_init (GtkBooleanCellAccessibleClass *klass)
75 {
76   GtkCellAccessibleClass *cell_class = GTK_CELL_ACCESSIBLE_CLASS (klass);
77   AtkObjectClass *atkobject_class = ATK_OBJECT_CLASS (klass);
78
79   atkobject_class->ref_state_set = gtk_boolean_cell_accessible_ref_state_set;
80
81   cell_class->update_cache = gtk_boolean_cell_accessible_update_cache;
82 }
83
84 static void
85 _gtk_boolean_cell_accessible_init (GtkBooleanCellAccessible *cell)
86 {
87 }
88