From 74dd29889121394266322a9f01976a1857b78bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= Date: Thu, 5 Jan 2012 19:00:06 +0100 Subject: [PATCH] a11y: Setting a name/label_actor for several items on the panel https://bugzilla.gnome.org/show_bug.cgi?id=667376 --- js/ui/dateMenu.js | 1 + js/ui/panel.js | 3 ++- js/ui/panelMenu.js | 24 +++++++++++++++++++++--- js/ui/popupMenu.js | 2 ++ js/ui/status/accessibility.js | 2 +- js/ui/status/bluetooth.js | 2 +- js/ui/status/network.js | 3 ++- js/ui/status/power.js | 2 +- js/ui/status/volume.js | 2 +- js/ui/userMenu.js | 1 + 10 files changed, 33 insertions(+), 9 deletions(-) diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js index d3b2309cb..05b4d095b 100644 --- a/js/ui/dateMenu.js +++ b/js/ui/dateMenu.js @@ -69,6 +69,7 @@ const DateMenuButton = new Lang.Class({ // Date this._date = new St.Label(); + this.actor.label_actor = this._date; this._date.style_class = 'datemenu-date-label'; vbox.add(this._date); diff --git a/js/ui/panel.js b/js/ui/panel.js index 3196fc108..69e75a10b 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -237,7 +237,7 @@ const AppMenuButton = new Lang.Class({ Extends: PanelMenu.Button, _init: function(menuManager) { - this.parent(0.0, true); + this.parent(0.0, null, true); this._startingApps = []; @@ -537,6 +537,7 @@ const AppMenuButton = new Lang.Class({ let icon = targetApp.get_faded_icon(2 * PANEL_ICON_SIZE); this._label.setText(targetApp.get_name()); + this.setName(targetApp.get_name()); this._iconBox.set_child(icon); this._iconBox.show(); diff --git a/js/ui/panelMenu.js b/js/ui/panelMenu.js index 126d2cc26..66f4813fe 100644 --- a/js/ui/panelMenu.js +++ b/js/ui/panelMenu.js @@ -96,7 +96,7 @@ const Button = new Lang.Class({ Name: 'PanelMenuButton', Extends: ButtonBox, - _init: function(menuAlignment, dontCreateMenu) { + _init: function(menuAlignment, nameText, dontCreateMenu) { this.parent({ reactive: true, can_focus: true, track_hover: true }); @@ -108,6 +108,24 @@ const Button = new Lang.Class({ this.menu = null; else this.setMenu(new PopupMenu.PopupMenu(this.actor, menuAlignment, St.Side.TOP, 0)); + + this.setName(nameText); + }, + + setName: function(text) { + if (text != null) { + // This is the easiest way to provide a accessible name to + // this widget. The label could be also used for other + // purposes in the future. + if (!this.label) { + this.label = new St.Label({ text: text }); + this.actor.label_actor = this.label; + } else + this.label.text = text; + } else { + this.label = null; + this.actor.label_actor = null; + } }, setMenu: function(menu) { @@ -203,8 +221,8 @@ const SystemStatusButton = new Lang.Class({ Name: 'SystemStatusButton', Extends: Button, - _init: function(iconName,tooltipText) { - this.parent(0.0); + _init: function(iconName, tooltipText, nameText) { + this.parent(0.0, nameText); this._iconActor = new St.Icon({ icon_name: iconName, icon_type: St.IconType.SYMBOLIC, diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index 1d847f8c8..fa6ddad8d 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -389,6 +389,7 @@ const PopupMenuItem = new Lang.Class({ this.label = new St.Label({ text: text }); this.addActor(this.label); + this.actor.label_actor = this.label } }); @@ -1428,6 +1429,7 @@ const PopupSubMenuMenuItem = new Lang.Class({ this.label = new St.Label({ text: text }); this.addActor(this.label); + this.actor.label_actor = this.label; this._triangle = new St.Label({ text: '\u25B8' }); this.addActor(this._triangle, { align: St.Align.END }); diff --git a/js/ui/status/accessibility.js b/js/ui/status/accessibility.js index 4173c7353..bda0e0153 100644 --- a/js/ui/status/accessibility.js +++ b/js/ui/status/accessibility.js @@ -44,7 +44,7 @@ const ATIndicator = new Lang.Class({ Extends: PanelMenu.SystemStatusButton, _init: function() { - this.parent('preferences-desktop-accessibility', null); + this.parent('preferences-desktop-accessibility', null, _("Accessibility")); let highContrast = this._buildHCItem(); this.menu.addMenuItem(highContrast); diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js index 126fd3df6..34b1b1856 100644 --- a/js/ui/status/bluetooth.js +++ b/js/ui/status/bluetooth.js @@ -28,7 +28,7 @@ const Indicator = new Lang.Class({ Extends: PanelMenu.SystemStatusButton, _init: function() { - this.parent('bluetooth-disabled', null); + this.parent('bluetooth-disabled', null, _("Bluetooth")); this._applet = new GnomeBluetoothApplet.Applet(); diff --git a/js/ui/status/network.js b/js/ui/status/network.js index a3ce9bcfa..f6cd8d032 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -113,6 +113,7 @@ const NMNetworkMenuItem = new Lang.Class({ } this._label = new St.Label({ text: title }); + this.actor.label_actor = this._label; this.addActor(this._label); this._icons = new St.BoxLayout({ style_class: 'nm-menu-item-icons' }); this.addActor(this._icons, { align: St.Align.END }); @@ -1537,7 +1538,7 @@ const NMApplet = new Lang.Class({ Extends: PanelMenu.SystemStatusButton, _init: function() { - this.parent('network-error', null); + this.parent('network-error', null, _("Network")); this._client = NMClient.Client.new(); diff --git a/js/ui/status/power.js b/js/ui/status/power.js index a3932157a..60600bfe5 100644 --- a/js/ui/status/power.js +++ b/js/ui/status/power.js @@ -57,7 +57,7 @@ const Indicator = new Lang.Class({ Extends: PanelMenu.SystemStatusButton, _init: function() { - this.parent('battery-missing', null); + this.parent('battery-missing', null, _("Battery")); this._proxy = new PowerManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH); diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js index fcaa069bf..3afe13741 100644 --- a/js/ui/status/volume.js +++ b/js/ui/status/volume.js @@ -22,7 +22,7 @@ const Indicator = new Lang.Class({ Extends: PanelMenu.SystemStatusButton, _init: function() { - this.parent('audio-volume-muted', null); + this.parent('audio-volume-muted', null, _("Volume")); this._control = new Gvc.MixerControl({ name: 'GNOME Shell Volume Control' }); this._control.connect('state-changed', Lang.bind(this, this._onControlStateChanged)); diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js index e1757e33a..6e3cf5d04 100644 --- a/js/ui/userMenu.js +++ b/js/ui/userMenu.js @@ -466,6 +466,7 @@ const UserMenuButton = new Lang.Class({ })); this._name = new St.Label(); + this.actor.label_actor = this._name; box.add(this._name, { y_align: St.Align.MIDDLE, y_fill: false }); this._userLoadedId = this._user.connect('notify::is-loaded', Lang.bind(this, this._updateUserName)); this._userChangedId = this._user.connect('changed', Lang.bind(this, this._updateUserName));