WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit c206d9d

Browse files
committed
menu applet: Fix screen-reader/Atk support.
This fixes screen reader (orca) support for the start menu. App buttons report both name and description, while all other elements just report their name.
1 parent 2262bc7 commit c206d9d

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ class SimpleMenuItem {
281281
this.label.clutter_text.ellipsize = Pango.EllipsizeMode.END;
282282
this.actor.add_actor(this.labelContainer);
283283
this.labelContainer.add_actor(this.label);
284+
this.actor.set_label_actor(this.label);
284285
}
285286

286287
addDescription(label='', styleClass=null) {
@@ -302,6 +303,20 @@ class SimpleMenuItem {
302303
this.labelContainer.add_actor(this.descriptionLabel);
303304
}
304305

306+
updateAccessibleName() {
307+
this.actor.set_label_actor(null);
308+
309+
let name = "";
310+
if (this.label)
311+
name += this.label.get_text();
312+
if (this.descriptionLabel) {
313+
if (name.length > 0)
314+
name += ". ";
315+
name += this.descriptionLabel.get_text();
316+
}
317+
this.actor.set_accessible_name(name);
318+
}
319+
305320
/**
306321
* Adds a ClutterActor as the next child.
307322
*
@@ -333,7 +348,7 @@ class SimpleMenuItem {
333348

334349
class ApplicationContextMenuItem extends PopupMenu.PopupBaseMenuItem {
335350
constructor(appButton, label, action, iconName) {
336-
super({focusOnHover: false});
351+
super({focusOnHover: true});
337352

338353
this._appButton = appButton;
339354
this._action = action;
@@ -350,6 +365,7 @@ class ApplicationContextMenuItem extends PopupMenu.PopupBaseMenuItem {
350365
}
351366

352367
this.addActor(this.label);
368+
this.actor.set_label_actor(this.label);
353369
}
354370

355371
activate (event) {
@@ -604,6 +620,8 @@ class ApplicationButton extends GenericApplicationButton {
604620
if (applet.showDescription)
605621
this.addDescription(this.description, 'appmenu-application-button-description');
606622

623+
this.updateAccessibleName();
624+
607625
this._draggable = DND.makeDraggable(this.actor);
608626
this._signals.connect(this._draggable, 'drag-end', this._onDragEnd.bind(this));
609627
this.isDraggableApp = true;
@@ -809,7 +827,6 @@ class CategoryButton extends SimpleMenuItem {
809827
styleClass: 'appmenu-category-button',
810828
categoryId: categoryId,
811829
});
812-
this.actor.accessible_role = Atk.Role.LIST_ITEM;
813830

814831
let size = applet.categoryIconSize;
815832
if (applet.symbolicCategoryIcons) {
@@ -895,6 +912,8 @@ class SystemButton extends SimpleMenuItem {
895912
styleClass: 'appmenu-system-button',
896913
});
897914
this.addIcon(16, iconName, null, true);
915+
this.actor.set_accessible_name(name);
916+
this.actor.set_accessible_role(Atk.Role.BUTTON);
898917
}
899918
}
900919

@@ -1818,6 +1837,7 @@ class CinnamonMenuApplet extends Applet.TextIconApplet {
18181837

18191838
_buttonEnterEvent(button) {
18201839
this.categoriesBox.get_children().forEach(child => child.remove_style_pseudo_class("hover"));
1840+
this.categoriesBox.get_children().forEach(child => child.remove_accessible_state(Atk.StateType.FOCUSED));
18211841
this.applicationsBox.get_children().forEach(child => child.set_style_class_name("appmenu-application-button"));
18221842
this.favoriteAppsBox.get_children().forEach(child => child.remove_style_pseudo_class("hover"));
18231843
this.placesBox.get_children().forEach(child => child.remove_style_pseudo_class("hover"));
@@ -1847,6 +1867,7 @@ class CinnamonMenuApplet extends Applet.TextIconApplet {
18471867
}
18481868
}
18491869

1870+
button.actor.add_accessible_state(Atk.StateType.FOCUSED);
18501871

18511872
let parent = button.actor.get_parent();
18521873
this._activeContainer = parent;
@@ -1868,6 +1889,8 @@ class CinnamonMenuApplet extends Applet.TextIconApplet {
18681889
button.actor.set_style_class_name(button.styleClass);
18691890
}
18701891

1892+
button.actor.remove_accessible_state(Atk.StateType.FOCUSED);
1893+
18711894
// This method is only called on mouse leave so return key focus to the
18721895
// currently active category button.
18731896
this._setKeyFocusToCurrentCategoryButton();
@@ -2451,6 +2474,9 @@ class CinnamonMenuApplet extends Applet.TextIconApplet {
24512474
let user = AccountsService.UserManager.get_default().get_user(GLib.get_user_name());
24522475
this.userIcon = new UserWidget.UserWidget(user, Clutter.Orientation.VERTICAL, false);
24532476
this.userIcon.set_reactive(true);
2477+
this.userIcon.track_hover = true;
2478+
this.userIcon.set_accessible_role(Atk.Role.BUTTON);
2479+
this.userIcon.set_accessible_name(_("Account details"));
24542480
this.userIcon.connect('button-press-event', () => {
24552481
this.menu.toggle();
24562482
Util.spawnCommandLine("cinnamon-settings user");
@@ -2525,7 +2551,10 @@ class CinnamonMenuApplet extends Applet.TextIconApplet {
25252551
name: 'appmenu-search-entry',
25262552
track_hover: true,
25272553
can_focus: true,
2554+
accessible_name: _("Search"),
2555+
accessible_role: Atk.Role.ENTRY,
25282556
});
2557+
this.searchEntry.add_accessible_state(Atk.StateType.EDITABLE);
25292558

25302559
this.searchEntry.set_secondary_icon(this._searchInactiveIcon);
25312560
this.searchActive = false;

js/ui/userWidget.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// A widget showing the user avatar and name
44
/* exported UserWidget */
55

6+
const Atk = imports.gi.Atk;
67
const Clutter = imports.gi.Clutter;
78
const GLib = imports.gi.GLib;
89
const GObject = imports.gi.GObject;
@@ -59,13 +60,15 @@ class Avatar extends St.Bin {
5960
effect.set_contrast(0.3);
6061
this.add_effect(effect);
6162
}
63+
this.add_accessible_state(Atk.StateType.FOCUSED);
6264
} else {
6365
if (this.child) {
6466
this.child.remove_style_class_name('highlighted');
6567
}
6668
else {
6769
this.clear_effects();
6870
}
71+
this.remove_accessible_state(Atk.StateType.FOCUSED);
6972
}
7073
}
7174

src/st/st-widget.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2386,7 +2386,7 @@ st_widget_get_label_actor (StWidget *widget)
23862386
/**
23872387
* st_widget_set_label_actor:
23882388
* @widget: a #StWidget
2389-
* @label: a #ClutterActor
2389+
* @label: (nullable): a #ClutterActor
23902390
*
23912391
* Sets @label as the #ClutterActor that identifies (labels)
23922392
* @widget. @label can be %NULL to indicate that @widget is not

0 commit comments

Comments
 (0)