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, see <http://www.gnu.org/licenses/>.
21 #include "gtkbooleancellaccessible.h"
23 static AtkActionIface *parent_action_iface;
26 gtk_boolean_cell_accessible_get_n_actions (AtkAction *action)
28 return parent_action_iface->get_n_actions (action) + 1;
32 gtk_boolean_cell_accessible_get_description (AtkAction *action,
36 return "toggles the cell";
38 return parent_action_iface->get_description (action, i - 1);
42 gtk_boolean_cell_accessible_action_get_name (AtkAction *action,
48 return parent_action_iface->get_description (action, i - 1);
52 gtk_boolean_cell_accessible_do_action (AtkAction *action,
56 return parent_action_iface->do_action (action, 2);
58 return parent_action_iface->do_action (action, i - 1);
62 gtk_boolean_cell_accessible_action_interface_init (AtkActionIface *iface)
64 parent_action_iface = g_type_interface_peek_parent (iface);
66 iface->do_action = gtk_boolean_cell_accessible_do_action;
67 iface->get_n_actions = gtk_boolean_cell_accessible_get_n_actions;
68 iface->get_description = gtk_boolean_cell_accessible_get_description;
69 iface->get_name = gtk_boolean_cell_accessible_action_get_name;
73 G_DEFINE_TYPE_EXTENDED (GtkBooleanCellAccessible, _gtk_boolean_cell_accessible, GTK_TYPE_RENDERER_CELL_ACCESSIBLE, 0,
74 G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, gtk_boolean_cell_accessible_action_interface_init))
78 gtk_boolean_cell_accessible_ref_state_set (AtkObject *accessible)
80 GtkBooleanCellAccessible *cell = GTK_BOOLEAN_CELL_ACCESSIBLE (accessible);
81 AtkStateSet *state_set;
83 state_set = ATK_OBJECT_CLASS (_gtk_boolean_cell_accessible_parent_class)->ref_state_set (accessible);
86 atk_state_set_add_state (state_set, ATK_STATE_CHECKED);
88 if (cell->cell_sensitive)
89 atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE);
91 atk_state_set_remove_state (state_set, ATK_STATE_SENSITIVE);
97 gtk_boolean_cell_accessible_update_cache (GtkCellAccessible *cell)
99 GtkBooleanCellAccessible *boolean_cell = GTK_BOOLEAN_CELL_ACCESSIBLE (cell);
103 g_object_get (G_OBJECT (GTK_RENDERER_CELL_ACCESSIBLE (cell)->renderer),
105 "sensitive", &sensitive,
108 if (boolean_cell->cell_value != active)
110 boolean_cell->cell_value = !boolean_cell->cell_value;
112 atk_object_notify_state_change (ATK_OBJECT (cell), ATK_STATE_CHECKED, active);
115 if (boolean_cell->cell_sensitive != sensitive)
117 boolean_cell->cell_sensitive = !boolean_cell->cell_sensitive;
119 atk_object_notify_state_change (ATK_OBJECT (cell), ATK_STATE_CHECKED, sensitive);
124 _gtk_boolean_cell_accessible_class_init (GtkBooleanCellAccessibleClass *klass)
126 GtkCellAccessibleClass *cell_class = GTK_CELL_ACCESSIBLE_CLASS (klass);
127 AtkObjectClass *atkobject_class = ATK_OBJECT_CLASS (klass);
129 atkobject_class->ref_state_set = gtk_boolean_cell_accessible_ref_state_set;
131 cell_class->update_cache = gtk_boolean_cell_accessible_update_cache;
135 _gtk_boolean_cell_accessible_init (GtkBooleanCellAccessible *cell)