[gnome-shell/wip/gtkmenutrackeritem: 27/32] remoteMenu: Add support for extended accessibility roles



commit 844c461a162118e48c8eeb49265867c53c98042a
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu May 9 16:24:40 2013 -0400

    remoteMenu: Add support for extended accessibility roles

 js/ui/remoteMenu.js |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/remoteMenu.js b/js/ui/remoteMenu.js
index 00c0684..a77ac01 100644
--- a/js/ui/remoteMenu.js
+++ b/js/ui/remoteMenu.js
@@ -1,5 +1,6 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
+const Atk = imports.gi.Atk;
 const GLib = imports.gi.GLib;
 const GObject = imports.gi.GObject;
 const Gio = imports.gi.Gio;
@@ -29,12 +30,12 @@ const RemoteMenuItemMapper = new Lang.Class({
 
         this._trackerItem.connect('notify::label', Lang.bind(this, this._updateLabel));
         this._trackerItem.connect('notify::sensitive', Lang.bind(this, this._updateSensitivity));
-        this._trackerItem.connect('notify::role', Lang.bind(this, this._updateDecoration));
+        this._trackerItem.connect('notify::role', Lang.bind(this, this._updateRole));
         this._trackerItem.connect('notify::toggled', Lang.bind(this, this._updateDecoration));
 
         this._updateLabel();
         this._updateSensitivity();
-        this._updateDecoration();
+        this._updateRole();
     },
 
     _updateLabel: function() {
@@ -59,6 +60,18 @@ const RemoteMenuItemMapper = new Lang.Class({
 
         this.menuItem.setOrnament(ornament);
     },
+
+    _updateRole: function() {
+        let a11yRoles = {};
+        a11yRoles[ShellMenu.MenuTrackerItemRole.NORMAL] = Atk.Role.MENU_ITEM;
+        a11yRoles[ShellMenu.MenuTrackerItemRole.RADIO] = Atk.Role.RADIO_MENU_ITEM;
+        a11yRoles[ShellMenu.MenuTrackerItemRole.CHECK] = Atk.Role.CHECK_MENU_ITEM;
+
+        let a11yRole = a11yRoles[this._trackerItem.role];
+        this.menuItem.actor.accessible_role = a11yRole;
+
+        this._updateDecoration();
+    },
 });
 
 const RemoteMenu = new Lang.Class({


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