Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessibility improvements: keyboard navigation and labelling #1568

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions libcaja-private/caja-ui-utilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,22 @@ caja_ui_frame_image (GdkPixbuf **pixbuf)

*pixbuf = pixbuf_with_frame;
}

/* A simple substitution function to remove mnemonic underscores
* from a character string; useful for accessible descriptions. */
char *
caja_remove_mnemonics (const char *str)
{
gsize str_len = strlen (str);
char *buffer = g_malloc (str_len + 1 + 1);
char *p = buffer;

for (; *str != '\0'; str++) {
if (*str != '_')
*p++ = *str;
}

*p = '\0';

return buffer;
}
2 changes: 2 additions & 0 deletions libcaja-private/caja-ui-utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ GtkAction * caja_toolbar_action_from_menu_item (CajaMenuItem *item, GtkWidget *
const char *caja_ui_string_get (const char *filename);
void caja_ui_frame_image (GdkPixbuf **pixbuf);

char * caja_remove_mnemonics (const char *str);

#endif /* CAJA_UI_UTILITIES_H */
23 changes: 23 additions & 0 deletions src/caja-notes-viewer.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,27 @@ on_text_field_focus_out_event (GtkWidget *widget,
return FALSE;
}

static gboolean
filter_shift_tab_cb (GtkWidget *widget, GdkEventKey *event)
{
GdkModifierType state = event->state & gtk_accelerator_get_default_mod_mask ();

if (state == GDK_SHIFT_MASK) {
switch (event->keyval) {
case GDK_KEY_Tab:
case GDK_KEY_KP_Tab:
case GDK_KEY_ISO_Left_Tab:
g_signal_stop_emission_by_name(widget, "key-press-event");
break;

default:
break;
}
}

return FALSE;
}

static void
on_changed (GtkEditable *editable, CajaNotesViewer *notes)
{
Expand Down Expand Up @@ -355,6 +376,8 @@ caja_notes_viewer_init (CajaNotesViewer *sidebar)

gtk_container_add (GTK_CONTAINER (sidebar), details->note_text_field);

g_signal_connect (details->note_text_field, "key_press_event",
G_CALLBACK (filter_shift_tab_cb), sidebar);
g_signal_connect (details->note_text_field, "focus_out_event",
G_CALLBACK (on_text_field_focus_out_event), sidebar);
g_signal_connect (details->text_buffer, "changed",
Expand Down
5 changes: 5 additions & 0 deletions src/caja-property-browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include <libcaja-private/caja-global-preferences.h>
#include <libcaja-private/caja-metadata.h>
#include <libcaja-private/caja-signaller.h>
#include <libcaja-private/caja-ui-utilities.h>

#include "caja-property-browser.h"

Expand Down Expand Up @@ -2139,12 +2140,16 @@ property_browser_category_button_new (const char *display_name,
button = eel_labeled_image_radio_button_new (display_name, NULL);
}

gchar *button_msg = caja_remove_mnemonics (display_name);
atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (button)),
button_msg);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);

/* We also want all of the buttons to be the same height */
eel_labeled_image_set_fixed_image_height (EEL_LABELED_IMAGE (gtk_bin_get_child (GTK_BIN (button))), STANDARD_BUTTON_IMAGE_HEIGHT);

g_free (file_name);
g_free (button_msg);

return button;
}
Expand Down
31 changes: 30 additions & 1 deletion src/file-manager/fm-properties-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include <libcaja-private/caja-metadata.h>
#include <libcaja-private/caja-module.h>
#include <libcaja-private/caja-mime-actions.h>
#include <libcaja-private/caja-ui-utilities.h>

#include "fm-properties-window.h"
#include "fm-ditem-page.h"
Expand Down Expand Up @@ -551,8 +552,10 @@ create_image_widget (FMPropertiesWindow *window,

button = NULL;
if (is_customizable) {
AtkObject *button_acc;
gchar *icon_msg;
button = gtk_button_new ();
gtk_container_add (GTK_CONTAINER (button), image);
gtk_button_set_image (GTK_BUTTON (button), image);

/* prepare the image to receive dropped objects to assign custom images */
gtk_drag_dest_set (GTK_WIDGET (image),
Expand All @@ -564,6 +567,15 @@ create_image_widget (FMPropertiesWindow *window,
G_CALLBACK (fm_properties_window_drag_data_received), NULL);
g_signal_connect (button, "clicked",
G_CALLBACK (select_image_button_callback), window);

button_acc = gtk_widget_get_accessible (GTK_WIDGET (button));
get_image_for_properties_window (window, &icon_msg, NULL);
if (! icon_msg)
icon_msg = g_strdup (_("Current icon"));
atk_object_set_name (button_acc, icon_msg);
atk_object_set_description (button_acc,
_("Change this object’s icon."));
g_free (icon_msg);
}

window->details->icon_button = button;
Expand Down Expand Up @@ -3522,6 +3534,7 @@ create_emblems_page (FMPropertiesWindow *window)
button = eel_labeled_image_check_button_new (label, pixbuf);
eel_labeled_image_set_fixed_image_height (EEL_LABELED_IMAGE (gtk_bin_get_child (GTK_BIN (button))), STANDARD_EMBLEM_HEIGHT * scale);
eel_labeled_image_set_spacing (EEL_LABELED_IMAGE (gtk_bin_get_child (GTK_BIN (button))), EMBLEM_LABEL_SPACING * scale);
atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (button)), label);

g_free (label);
g_object_unref (pixbuf);
Expand Down Expand Up @@ -3880,8 +3893,17 @@ add_permissions_checkbox_with_label (FMPropertiesWindow *window,

a11y_enabled = GTK_IS_ACCESSIBLE (gtk_widget_get_accessible (check_button));
if (a11y_enabled && label_for != NULL) {
/* Work around Orca bug #218, which ignores an accessible
* object’s description if equal to its name. */
gchar *msg = caja_remove_mnemonics (label);
gchar *desc = g_strconcat (msg, " ", NULL);
g_free (msg);

eel_accessibility_set_up_label_widget_relation (GTK_WIDGET (label_for),
check_button);
atk_object_set_description (gtk_widget_get_accessible (check_button),
desc);
g_free (desc);
}

return check_button;
Expand Down Expand Up @@ -4413,6 +4435,7 @@ create_simple_permissions (FMPropertiesWindow *window, GtkGrid *page_grid)
{
gboolean has_file, has_directory;
GtkLabel *group_label;
GtkLabel *others_label;
GtkLabel *owner_label;
GtkLabel *execute_label;
GtkWidget *value;
Expand Down Expand Up @@ -4488,6 +4511,12 @@ create_simple_permissions (FMPropertiesWindow *window, GtkGrid *page_grid)
append_blank_slim_row (page_grid);

group_label = attach_title_field (page_grid, _("Others"));
/* Adding an empty focusable widget to ease keyboard navigation
* and screen reader accessibility. */
others_label = attach_label (page_grid, GTK_WIDGET (group_label),
NULL, FALSE, TRUE, FALSE);
gtk_label_set_mnemonic_widget (group_label,
GTK_WIDGET (others_label));

if (has_directory) {
add_permissions_combo_box (window, page_grid,
Expand Down