From c2fdec188eca7cf9b8e0ec0c65ffec41e5a1b89d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= Date: Fri, 20 Jan 2012 18:10:45 +0100 Subject: [PATCH] a11y: adding checked state on the popup menu items https://bugzilla.gnome.org/show_bug.cgi?id=668366 --- js/ui/popupMenu.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index 3aca567d7..ace32e013 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -749,6 +749,7 @@ const PopupSwitchMenuItem = new Lang.Class({ this._switch = new Switch(active); this.actor.accessible_role = Atk.Role.CHECK_MENU_ITEM; + this.checkAccessibleState(); this.actor.label_actor = this.label; this.addActor(this.label); @@ -776,6 +777,7 @@ const PopupSwitchMenuItem = new Lang.Class({ this.actor.can_focus = true; this.actor.accessible_role = Atk.Role.CHECK_MENU_ITEM; } + this.checkAccessibleState(); }, activate: function(event) { @@ -795,6 +797,7 @@ const PopupSwitchMenuItem = new Lang.Class({ toggle: function() { this._switch.toggle(); this.emit('toggled', this._switch.state); + this.checkAccessibleState(); }, get state() { @@ -803,6 +806,20 @@ const PopupSwitchMenuItem = new Lang.Class({ setToggleState: function(state) { this._switch.setToggleState(state); + this.checkAccessibleState(); + }, + + checkAccessibleState: function() { + switch (this.actor.accessible_role) { + case Atk.Role.CHECK_MENU_ITEM: + if (this._switch.state) + this.actor.add_accessible_state (Atk.StateType.CHECKED); + else + this.actor.remove_accessible_state (Atk.StateType.CHECKED); + break; + default: + this.actor.remove_accessible_state (Atk.StateType.CHECKED); + } } });