diff options
author | Corey Berla <corey@berla.me> | 2022-08-31 15:42:49 +0000 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2022-08-31 15:42:49 +0000 |
commit | ee38cbef43784412147547648298de1db667c39c (patch) | |
tree | ad028f97b8f06b852da32597f48096352695609a | |
parent | dff737342dec23ab3a71eff4a0a6a4a9a8cd5712 (diff) | |
download | nautilus-ee38cbef43784412147547648298de1db667c39c.tar.gz |
general: Set labelled-by for view cells
In gtk4, we need to set labelled-by to help a11y programs know what
it currently selected.
Unfortunately, the focus is on a GTK internal widget, so at the moment
this solution requires a hack: we mark the internal list item widget as
being labeled by our cell (which is, in turn, labeled by the filename label).
We are reporting this to GTK to work toward a better solution.
Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2460
-rw-r--r-- | src/nautilus-grid-view.c | 4 | ||||
-rw-r--r-- | src/nautilus-list-view.c | 16 | ||||
-rw-r--r-- | src/resources/ui/nautilus-grid-cell.ui | 3 | ||||
-rw-r--r-- | src/resources/ui/nautilus-name-cell.ui | 3 |
4 files changed, 26 insertions, 0 deletions
diff --git a/src/nautilus-grid-view.c b/src/nautilus-grid-view.c index 74a80e1f5..cbeea42de 100644 --- a/src/nautilus-grid-view.c +++ b/src/nautilus-grid-view.c @@ -367,6 +367,10 @@ bind_cell (GtkSignalListItemFactory *factory, gtk_widget_set_margin_bottom (parent, 3); gtk_widget_set_margin_start (parent, 3); gtk_widget_set_margin_end (parent, 3); + + gtk_accessible_update_relation (GTK_ACCESSIBLE (parent), + GTK_ACCESSIBLE_RELATION_LABELLED_BY, cell, NULL, + -1); } } diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c index e2389eac3..4b7a5f2e1 100644 --- a/src/nautilus-list-view.c +++ b/src/nautilus-list-view.c @@ -945,11 +945,27 @@ bind_name_cell (GtkSignalListItemFactory *factory, GtkListItem *listitem, gpointer user_data) { + GtkWidget *cell; NautilusViewItem *item; + cell = gtk_list_item_get_child (listitem); item = NAUTILUS_VIEW_ITEM (gtk_list_item_get_item (listitem)); nautilus_view_item_set_item_ui (item, gtk_list_item_get_child (listitem)); + + if (nautilus_view_cell_once (NAUTILUS_VIEW_CELL (cell))) + { + GtkWidget *row_widget; + + /* At the time of ::setup emission, the item ui has got no parent yet, + * that's why we need to complete the widget setup process here, on the + * first time ::bind is emitted. */ + row_widget = gtk_widget_get_parent (gtk_widget_get_parent (cell)); + + gtk_accessible_update_relation (GTK_ACCESSIBLE (row_widget), + GTK_ACCESSIBLE_RELATION_LABELLED_BY, cell, NULL, + -1); + } } static void diff --git a/src/resources/ui/nautilus-grid-cell.ui b/src/resources/ui/nautilus-grid-cell.ui index 2ca1f2755..cfc0ced89 100644 --- a/src/resources/ui/nautilus-grid-cell.ui +++ b/src/resources/ui/nautilus-grid-cell.ui @@ -3,6 +3,9 @@ <requires lib="gtk" version="4.0"/> <template class="NautilusGridCell" parent="NautilusViewCell"> <property name="valign">start</property> + <accessibility> + <relation name="labelled-by">label</relation> + </accessibility> <child> <object class="AdwClamp"> <property name="maximum-size">0</property> diff --git a/src/resources/ui/nautilus-name-cell.ui b/src/resources/ui/nautilus-name-cell.ui index f2105fb55..246aa3ab2 100644 --- a/src/resources/ui/nautilus-name-cell.ui +++ b/src/resources/ui/nautilus-name-cell.ui @@ -2,6 +2,9 @@ <interface> <requires lib="gtk" version="4.0"/> <template class="NautilusNameCell" parent="NautilusViewCell"> + <accessibility> + <relation name="labelled-by">label</relation> + </accessibility> <child> <object class="GtkBox"> <property name="spacing">6</property> |