[gnome-shell] a11y: adding checked state on the popup menu items



commit c2fdec188eca7cf9b8e0ec0c65ffec41e5a1b89d
Author: Alejandro PiÃeiro <apinheiro igalia com>
Date:   Fri Jan 20 18:10:45 2012 +0100

    a11y: adding checked state on the popup menu items
    
    https://bugzilla.gnome.org/show_bug.cgi?id=668366

 js/ui/popupMenu.js |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index 3aca567..ace32e0 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);
+        }
     }
 });
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]