Skip to content

Commit

Permalink
general: Reimplement a11y for gtk4
Browse files Browse the repository at this point in the history
Set the accessible role for our custom UI widgets.  Misc
labelling and descriptions.
  • Loading branch information
coreyberla authored and antoniojpfernandes committed Jul 30, 2022
1 parent 8a7608c commit 1c569b0
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 15 deletions.
6 changes: 6 additions & 0 deletions src/gtk/nautilusgtkplacessidebar.c
Expand Up @@ -3976,6 +3976,11 @@ nautilus_gtk_places_sidebar_init (NautilusGtkPlacesSidebar *sidebar)
entries, G_N_ELEMENTS (entries),
sidebar);
gtk_widget_insert_action_group (GTK_WIDGET (sidebar), "row", sidebar->row_actions);

gtk_accessible_update_property (GTK_ACCESSIBLE (sidebar),
GTK_ACCESSIBLE_PROPERTY_LABEL, _("Sidebar"),
GTK_ACCESSIBLE_PROPERTY_DESCRIPTION,
_("List of common shortcuts, mountpoints, and bookmarks."), -1);
}

static void
Expand Down Expand Up @@ -4515,6 +4520,7 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class)
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, properties);

gtk_widget_class_set_css_name (widget_class, "placessidebar");
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_LIST);
}

/*
Expand Down
1 change: 1 addition & 0 deletions src/gtk/nautilusgtkplacesview.c
Expand Up @@ -2418,6 +2418,7 @@ nautilus_gtk_places_view_class_init (NautilusGtkPlacesViewClass *klass)
gtk_widget_class_install_action (widget_class, "location.properties", NULL, properties_cb);

gtk_widget_class_set_css_name (widget_class, "placesview");
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_LIST);
}

static void
Expand Down
4 changes: 4 additions & 0 deletions src/gtk/nautilusgtkplacesview.ui
Expand Up @@ -154,6 +154,10 @@
</child>
</object>
<template class="NautilusGtkPlacesView" parent="GtkBox">
<accessibility>
<property name="label" translatable="yes">Other Locations</property>
<property name="description" translatable="yes">List of common local and remote mountpoints.</property>
</accessibility>
<property name="orientation">1</property>
<child>
<object class="GtkStack" id="stack">
Expand Down
3 changes: 0 additions & 3 deletions src/nautilus-file-operations.c
Expand Up @@ -3030,9 +3030,6 @@ create_empty_trash_prompt (GtkWindow *parent_window)
_("Empty _Trash"), GTK_RESPONSE_ACCEPT, NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
gtk_window_set_title (GTK_WINDOW (dialog), "");
#if 0 && NAUTILUS_A11Y_NEEDS_GTK4_REIMPLEMENTATION
atk_object_set_role (gtk_widget_get_accessible (dialog), ATK_ROLE_ALERT);
#endif

return dialog;
}
Expand Down
10 changes: 0 additions & 10 deletions src/nautilus-files-view.c
Expand Up @@ -9537,9 +9537,6 @@ nautilus_files_view_init (NautilusFilesView *view)
{
NautilusFilesViewPrivate *priv;
GtkBuilder *builder;
#if 0 && NAUTILUS_A11Y_NEEDS_GTK4_REIMPLEMENTATION
AtkObject *atk_object;
#endif
NautilusDirectory *scripts_directory;
NautilusDirectory *templates_directory;
GtkEventController *controller;
Expand Down Expand Up @@ -9670,13 +9667,6 @@ nautilus_files_view_init (NautilusFilesView *view)

priv->in_destruction = FALSE;

#if 0 && NAUTILUS_A11Y_NEEDS_GTK4_REIMPLEMENTATION
/* Accessibility */
atk_object = gtk_widget_get_accessible (GTK_WIDGET (view));
atk_object_set_name (atk_object, _("Content View"));
atk_object_set_description (atk_object, _("View of the current folder"));
#endif

priv->view_action_group = G_ACTION_GROUP (g_simple_action_group_new ());
g_action_map_add_action_entries (G_ACTION_MAP (priv->view_action_group),
view_entries,
Expand Down
2 changes: 2 additions & 0 deletions src/nautilus-grid-cell.c
Expand Up @@ -203,6 +203,8 @@ nautilus_grid_cell_class_init (NautilusGridCellClass *klass)
gtk_widget_class_bind_template_child (widget_class, NautilusGridCell, first_caption);
gtk_widget_class_bind_template_child (widget_class, NautilusGridCell, second_caption);
gtk_widget_class_bind_template_child (widget_class, NautilusGridCell, third_caption);

gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_GRID_CELL);
}

static void
Expand Down
2 changes: 1 addition & 1 deletion src/nautilus-query-editor.c
Expand Up @@ -328,7 +328,7 @@ nautilus_query_editor_class_init (NautilusQueryEditorClass *class)

gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
gtk_widget_class_set_css_name (widget_class, "entry");
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_TEXT_BOX);
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_SEARCH_BOX);
}

GFile *
Expand Down
2 changes: 2 additions & 0 deletions src/nautilus-toolbar.c
Expand Up @@ -1195,6 +1195,8 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, search_button);

gtk_widget_class_bind_template_callback (widget_class, on_operations_popover_notify_visible);

gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_TOOLBAR);
}

GtkWidget *
Expand Down
6 changes: 6 additions & 0 deletions src/resources/ui/nautilus-compress-dialog.ui
Expand Up @@ -33,6 +33,9 @@
<property name="spacing">12</property>
<child>
<object class="GtkEntry" id="name_entry">
<accessibility>
<relation name="labelled-by">name_label</relation>
</accessibility>
<property name="hexpand">True</property>
<property name="width-chars">30</property>
</object>
Expand Down Expand Up @@ -63,6 +66,9 @@
</child>
<child>
<object class="GtkEntry" id="passphrase_entry">
<accessibility>
<relation name="labelled-by">passphrase_label</relation>
</accessibility>
<property name="visible">False</property>
<property name="placeholder-text" translatable="yes">Enter a password here.</property>
<property name="input-purpose">password</property>
Expand Down
6 changes: 5 additions & 1 deletion src/resources/ui/nautilus-create-folder-dialog.ui
Expand Up @@ -21,7 +21,11 @@
</object>
</child>
<child>
<object class="GtkEntry" id="name_entry"/>
<object class="GtkEntry" id="name_entry">
<accessibility>
<relation name="labelled-by">name_label</relation>
</accessibility>
</object>
</child>
<child>
<object class="GtkRevealer" id="error_revealer">
Expand Down
4 changes: 4 additions & 0 deletions src/resources/ui/nautilus-files-view.ui
Expand Up @@ -2,6 +2,10 @@
<interface>
<requires lib="gtk" version="4.0"/>
<template class="NautilusFilesView" parent="AdwBin">
<accessibility>
<property name="label" translatable="yes">Content View</property>
<property name="description" translatable="yes">View of the current folder</property>
</accessibility>
<child>
<object class="GtkOverlay" id="overlay">
<property name="hexpand">True</property>
Expand Down
3 changes: 3 additions & 0 deletions src/resources/ui/nautilus-rename-file-popover.ui
Expand Up @@ -19,6 +19,9 @@
</child>
<child>
<object class="GtkEntry" id="name_entry">
<accessibility>
<property name="label" translatable="yes">New Filename</property>
</accessibility>
<property name="margin-bottom">12</property>
</object>
</child>
Expand Down

0 comments on commit 1c569b0

Please sign in to comment.