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