a11y: Setting a name/label_actor for several items on the panel

https://bugzilla.gnome.org/show_bug.cgi?id=667376
This commit is contained in:
Alejandro Piñeiro 2012-01-05 19:00:06 +01:00
parent 5a85fc0e55
commit 74dd298891
10 changed files with 33 additions and 9 deletions

View File

@ -69,6 +69,7 @@ const DateMenuButton = new Lang.Class({
// Date // Date
this._date = new St.Label(); this._date = new St.Label();
this.actor.label_actor = this._date;
this._date.style_class = 'datemenu-date-label'; this._date.style_class = 'datemenu-date-label';
vbox.add(this._date); vbox.add(this._date);

View File

@ -237,7 +237,7 @@ const AppMenuButton = new Lang.Class({
Extends: PanelMenu.Button, Extends: PanelMenu.Button,
_init: function(menuManager) { _init: function(menuManager) {
this.parent(0.0, true); this.parent(0.0, null, true);
this._startingApps = []; this._startingApps = [];
@ -537,6 +537,7 @@ const AppMenuButton = new Lang.Class({
let icon = targetApp.get_faded_icon(2 * PANEL_ICON_SIZE); let icon = targetApp.get_faded_icon(2 * PANEL_ICON_SIZE);
this._label.setText(targetApp.get_name()); this._label.setText(targetApp.get_name());
this.setName(targetApp.get_name());
this._iconBox.set_child(icon); this._iconBox.set_child(icon);
this._iconBox.show(); this._iconBox.show();

View File

@ -96,7 +96,7 @@ const Button = new Lang.Class({
Name: 'PanelMenuButton', Name: 'PanelMenuButton',
Extends: ButtonBox, Extends: ButtonBox,
_init: function(menuAlignment, dontCreateMenu) { _init: function(menuAlignment, nameText, dontCreateMenu) {
this.parent({ reactive: true, this.parent({ reactive: true,
can_focus: true, can_focus: true,
track_hover: true }); track_hover: true });
@ -108,6 +108,24 @@ const Button = new Lang.Class({
this.menu = null; this.menu = null;
else else
this.setMenu(new PopupMenu.PopupMenu(this.actor, menuAlignment, St.Side.TOP, 0)); 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) { setMenu: function(menu) {
@ -203,8 +221,8 @@ const SystemStatusButton = new Lang.Class({
Name: 'SystemStatusButton', Name: 'SystemStatusButton',
Extends: Button, Extends: Button,
_init: function(iconName,tooltipText) { _init: function(iconName, tooltipText, nameText) {
this.parent(0.0); this.parent(0.0, nameText);
this._iconActor = new St.Icon({ icon_name: iconName, this._iconActor = new St.Icon({ icon_name: iconName,
icon_type: St.IconType.SYMBOLIC, icon_type: St.IconType.SYMBOLIC,

View File

@ -389,6 +389,7 @@ const PopupMenuItem = new Lang.Class({
this.label = new St.Label({ text: text }); this.label = new St.Label({ text: text });
this.addActor(this.label); 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.label = new St.Label({ text: text });
this.addActor(this.label); this.addActor(this.label);
this.actor.label_actor = this.label;
this._triangle = new St.Label({ text: '\u25B8' }); this._triangle = new St.Label({ text: '\u25B8' });
this.addActor(this._triangle, { align: St.Align.END }); this.addActor(this._triangle, { align: St.Align.END });

View File

@ -44,7 +44,7 @@ const ATIndicator = new Lang.Class({
Extends: PanelMenu.SystemStatusButton, Extends: PanelMenu.SystemStatusButton,
_init: function() { _init: function() {
this.parent('preferences-desktop-accessibility', null); this.parent('preferences-desktop-accessibility', null, _("Accessibility"));
let highContrast = this._buildHCItem(); let highContrast = this._buildHCItem();
this.menu.addMenuItem(highContrast); this.menu.addMenuItem(highContrast);

View File

@ -28,7 +28,7 @@ const Indicator = new Lang.Class({
Extends: PanelMenu.SystemStatusButton, Extends: PanelMenu.SystemStatusButton,
_init: function() { _init: function() {
this.parent('bluetooth-disabled', null); this.parent('bluetooth-disabled', null, _("Bluetooth"));
this._applet = new GnomeBluetoothApplet.Applet(); this._applet = new GnomeBluetoothApplet.Applet();

View File

@ -113,6 +113,7 @@ const NMNetworkMenuItem = new Lang.Class({
} }
this._label = new St.Label({ text: title }); this._label = new St.Label({ text: title });
this.actor.label_actor = this._label;
this.addActor(this._label); this.addActor(this._label);
this._icons = new St.BoxLayout({ style_class: 'nm-menu-item-icons' }); this._icons = new St.BoxLayout({ style_class: 'nm-menu-item-icons' });
this.addActor(this._icons, { align: St.Align.END }); this.addActor(this._icons, { align: St.Align.END });
@ -1537,7 +1538,7 @@ const NMApplet = new Lang.Class({
Extends: PanelMenu.SystemStatusButton, Extends: PanelMenu.SystemStatusButton,
_init: function() { _init: function() {
this.parent('network-error', null); this.parent('network-error', null, _("Network"));
this._client = NMClient.Client.new(); this._client = NMClient.Client.new();

View File

@ -57,7 +57,7 @@ const Indicator = new Lang.Class({
Extends: PanelMenu.SystemStatusButton, Extends: PanelMenu.SystemStatusButton,
_init: function() { _init: function() {
this.parent('battery-missing', null); this.parent('battery-missing', null, _("Battery"));
this._proxy = new PowerManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH); this._proxy = new PowerManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH);

View File

@ -22,7 +22,7 @@ const Indicator = new Lang.Class({
Extends: PanelMenu.SystemStatusButton, Extends: PanelMenu.SystemStatusButton,
_init: function() { _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 = new Gvc.MixerControl({ name: 'GNOME Shell Volume Control' });
this._control.connect('state-changed', Lang.bind(this, this._onControlStateChanged)); this._control.connect('state-changed', Lang.bind(this, this._onControlStateChanged));

View File

@ -466,6 +466,7 @@ const UserMenuButton = new Lang.Class({
})); }));
this._name = new St.Label(); this._name = new St.Label();
this.actor.label_actor = this._name;
box.add(this._name, { y_align: St.Align.MIDDLE, y_fill: false }); 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._userLoadedId = this._user.connect('notify::is-loaded', Lang.bind(this, this._updateUserName));
this._userChangedId = this._user.connect('changed', Lang.bind(this, this._updateUserName)); this._userChangedId = this._user.connect('changed', Lang.bind(this, this._updateUserName));