[gnome-shell] a11y: Setting role on several panel ui elements



commit 7c25dead17d2d3de38b4fc7c69106bf87fd1e7ec
Author: Alejandro PiÃeiro <apinheiro igalia com>
Date:   Mon Feb 27 17:31:10 2012 +0100

    a11y: Setting role on several panel ui elements
    
    https://bugzilla.gnome.org/show_bug.cgi?id=667432

 js/ui/dateMenu.js  |    6 ++++++
 js/ui/panel.js     |    4 ++++
 js/ui/panelMenu.js |    4 +++-
 js/ui/popupMenu.js |   12 ++++++++++--
 js/ui/userMenu.js  |    3 +++
 5 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index f6368da..47231fa 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -8,6 +8,7 @@ const Cairo = imports.cairo;
 const Clutter = imports.gi.Clutter;
 const Shell = imports.gi.Shell;
 const St = imports.gi.St;
+const Atk = imports.gi.Atk;
 
 const Params = imports.misc.params;
 const Util = imports.misc.util;
@@ -56,6 +57,11 @@ const DateMenuButton = new Lang.Class({
             menuAlignment = 1.0 - menuAlignment;
         this.parent(menuAlignment);
 
+        // At this moment calendar menu is not keyboard navigable at
+        // all (so not accessible), so it doesn't make sense to set as
+        // role ATK_ROLE_MENU like other elements of the panel.
+        this.actor.accessible_role = Atk.Role.LABEL;
+
         this._clock = new St.Label();
         this.actor.add_actor(this._clock);
 
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 65efa70..039c453 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -11,6 +11,7 @@ const Pango = imports.gi.Pango;
 const Shell = imports.gi.Shell;
 const St = imports.gi.St;
 const Signals = imports.signals;
+const Atk = imports.gi.Atk;
 
 const Config = imports.misc.config;
 const CtrlAltTab = imports.ui.ctrlAltTab;
@@ -250,6 +251,8 @@ const AppMenuButton = new Lang.Class({
     _init: function(menuManager) {
         this.parent(0.0, null, true);
 
+        this.actor.accessible_role = Atk.Role.MENU;
+
         this._startingApps = [];
 
         this._menuManager = menuManager;
@@ -601,6 +604,7 @@ const ActivitiesButton = new Lang.Class({
 
     _init: function() {
         this.parent(0.0);
+        this.actor.accessible_role = Atk.Role.TOGGLE_BUTTON;
 
         let container = new Shell.GenericContainer();
         container.connect('get-preferred-width', Lang.bind(this, this._containerGetPreferredWidth));
diff --git a/js/ui/panelMenu.js b/js/ui/panelMenu.js
index 0b71c7c..0d8c84a 100644
--- a/js/ui/panelMenu.js
+++ b/js/ui/panelMenu.js
@@ -6,6 +6,7 @@ const Lang = imports.lang;
 const Shell = imports.gi.Shell;
 const Signals = imports.signals;
 const St = imports.gi.St;
+const Atk = imports.gi.Atk;
 
 const Main = imports.ui.main;
 const Params = imports.misc.params;
@@ -99,7 +100,8 @@ const Button = new Lang.Class({
     _init: function(menuAlignment, nameText, dontCreateMenu) {
         this.parent({ reactive: true,
                       can_focus: true,
-                      track_hover: true });
+                      track_hover: true,
+                      accessible_role: Atk.Role.MENU });
 
         this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));
         this.actor.connect('key-press-event', Lang.bind(this, this._onSourceKeyPress));
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index ea8d60b..3781319 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -9,6 +9,7 @@ const Lang = imports.lang;
 const Shell = imports.gi.Shell;
 const Signals = imports.signals;
 const St = imports.gi.St;
+const Atk = imports.gi.Atk;
 
 const BoxPointer = imports.ui.boxpointer;
 const Main = imports.ui.main;
@@ -41,7 +42,8 @@ const PopupBaseMenuItem = new Lang.Class({
         this.actor = new Shell.GenericContainer({ style_class: 'popup-menu-item',
                                                   reactive: params.reactive,
                                                   track_hover: params.reactive,
-                                                  can_focus: params.reactive });
+                                                  can_focus: params.reactive,
+                                                  accessible_role: Atk.Role.MENU_ITEM});
         this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
         this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
         this.actor.connect('allocate', Lang.bind(this, this._allocate));
@@ -711,7 +713,8 @@ const Switch = new Lang.Class({
     Name: 'Switch',
 
     _init: function(state) {
-        this.actor = new St.Bin({ style_class: 'toggle-switch' });
+        this.actor = new St.Bin({ style_class: 'toggle-switch',
+                                  accessible_role: Atk.Role.CHECK_BOX});
         // Translators: this MUST be either "toggle-switch-us"
         // (for toggle switches containing the English words
         // "ON" and "OFF") or "toggle-switch-intl" (for toggle
@@ -744,6 +747,9 @@ const PopupSwitchMenuItem = new Lang.Class({
         this.label = new St.Label({ text: text });
         this._switch = new Switch(active);
 
+        this.actor.accessible_role = Atk.Role.CHECK_MENU_ITEM;
+        this.actor.label_actor = this.label;
+
         this.addActor(this.label);
 
         this._statusBin = new St.Bin({ x_align: St.Align.END });
@@ -762,10 +768,12 @@ const PopupSwitchMenuItem = new Lang.Class({
             this._statusBin.child = this._statusLabel;
             this.actor.reactive = false;
             this.actor.can_focus = false;
+            this.actor.accessible_role = Atk.Role.MENU_ITEM;
         } else {
             this._statusBin.child = this._switch.actor;
             this.actor.reactive = true;
             this.actor.can_focus = true;
+            this.actor.accessible_role = Atk.Role.CHECK_MENU_ITEM;
         }
     },
 
diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js
index db67212..ebb0ff7 100644
--- a/js/ui/userMenu.js
+++ b/js/ui/userMenu.js
@@ -9,6 +9,7 @@ const Shell = imports.gi.Shell;
 const St = imports.gi.St;
 const Tp = imports.gi.TelepathyGLib;
 const UPowerGlib = imports.gi.UPowerGlib;
+const Atk = imports.gi.Atk;
 
 const GnomeSession = imports.misc.gnomeSession;
 const Main = imports.ui.main;
@@ -433,6 +434,8 @@ const UserMenuButton = new Lang.Class({
     _init: function() {
         this.parent(0.0);
 
+        this.actor.accessible_role = Atk.Role.MENU;
+
         let box = new St.BoxLayout({ name: 'panelUserMenu' });
         this.actor.add_actor(box);
 



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