a11y: Setting role on several panel ui elements

https://bugzilla.gnome.org/show_bug.cgi?id=667432
This commit is contained in:
Alejandro Piñeiro 2012-02-27 17:31:10 +01:00
parent f4d3153e91
commit 7c25dead17
5 changed files with 26 additions and 3 deletions

View File

@ -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);

View File

@ -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));

View File

@ -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));

View File

@ -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;
}
},

View File

@ -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);