1 /* GTK+ - accessibility implementations
2 * Copyright 2002 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/>.
22 #include "gtkcheckmenuitemaccessible.h"
25 G_DEFINE_TYPE (GtkCheckMenuItemAccessible, gtk_check_menu_item_accessible, GTK_TYPE_MENU_ITEM_ACCESSIBLE)
28 toggled_cb (GtkWidget *widget)
30 AtkObject *accessible;
31 GtkCheckMenuItem *check_menu_item;
34 check_menu_item = GTK_CHECK_MENU_ITEM (widget);
35 active = gtk_check_menu_item_get_active (check_menu_item);
37 accessible = gtk_widget_get_accessible (widget);
38 atk_object_notify_state_change (accessible, ATK_STATE_CHECKED, active);
42 gtk_check_menu_item_accessible_initialize (AtkObject *obj,
45 ATK_OBJECT_CLASS (gtk_check_menu_item_accessible_parent_class)->initialize (obj, data);
47 g_signal_connect (data, "toggled", G_CALLBACK (toggled_cb), NULL);
49 obj->role = ATK_ROLE_CHECK_MENU_ITEM;
53 gtk_check_menu_item_accessible_ref_state_set (AtkObject *accessible)
55 AtkStateSet *state_set;
56 GtkCheckMenuItem *check_menu_item;
59 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
63 state_set = ATK_OBJECT_CLASS (gtk_check_menu_item_accessible_parent_class)->ref_state_set (accessible);
65 check_menu_item = GTK_CHECK_MENU_ITEM (widget);
67 if (gtk_check_menu_item_get_active (check_menu_item))
68 atk_state_set_add_state (state_set, ATK_STATE_CHECKED);
70 if (gtk_check_menu_item_get_inconsistent (check_menu_item))
72 atk_state_set_remove_state (state_set, ATK_STATE_ENABLED);
73 atk_state_set_add_state (state_set, ATK_STATE_INDETERMINATE);
80 gtk_check_menu_item_accessible_notify_gtk (GObject *obj,
83 GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (obj);
86 gboolean inconsistent;
88 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (check_menu_item));
89 sensitive = gtk_widget_get_sensitive (GTK_WIDGET (check_menu_item));
90 inconsistent = gtk_check_menu_item_get_inconsistent (check_menu_item);
92 if (strcmp (pspec->name, "inconsistent") == 0)
94 atk_object_notify_state_change (atk_obj, ATK_STATE_INDETERMINATE, inconsistent);
95 atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, (sensitive && !inconsistent));
97 else if (strcmp (pspec->name, "sensitive") == 0)
99 /* Need to override gailwidget behavior of notifying for ENABLED */
100 atk_object_notify_state_change (atk_obj, ATK_STATE_SENSITIVE, sensitive);
101 atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, (sensitive && !inconsistent));
104 GTK_WIDGET_ACCESSIBLE_CLASS (gtk_check_menu_item_accessible_parent_class)->notify_gtk (obj, pspec);
108 gtk_check_menu_item_accessible_class_init (GtkCheckMenuItemAccessibleClass *klass)
110 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
111 GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
113 widget_class->notify_gtk = gtk_check_menu_item_accessible_notify_gtk;
115 class->ref_state_set = gtk_check_menu_item_accessible_ref_state_set;
116 class->initialize = gtk_check_menu_item_accessible_initialize;
120 gtk_check_menu_item_accessible_init (GtkCheckMenuItemAccessible *item)