From e251e7583f48c7a0c25480dab4c35bef658f19bb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 17 Jun 2023 12:19:05 -0400 Subject: [PATCH] gtk-demo: Misc a11y fixes Add some missing labels. --- demos/gtk-demo/entry_completion.c | 7 +++++++ demos/gtk-demo/entry_undo.c | 4 ++++ demos/gtk-demo/errorstates.c | 15 +++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/demos/gtk-demo/entry_completion.c b/demos/gtk-demo/entry_completion.c index 614571f0cf..5a9860efdd 100644 --- a/demos/gtk-demo/entry_completion.c +++ b/demos/gtk-demo/entry_completion.c @@ -95,6 +95,13 @@ do_entry_completion (GtkWidget *do_widget) entry = gtk_entry_new (); gtk_box_append (GTK_BOX (vbox), entry); + gtk_accessible_update_relation (GTK_ACCESSIBLE (entry), + GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL, + -1); + gtk_accessible_update_property (GTK_ACCESSIBLE (entry), + GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE, GTK_ACCESSIBLE_AUTOCOMPLETE_LIST, + -1); + /* Create the completion object */ completion = gtk_entry_completion_new (); diff --git a/demos/gtk-demo/entry_undo.c b/demos/gtk-demo/entry_undo.c index 48ee0e8b32..63de4bd9fa 100644 --- a/demos/gtk-demo/entry_undo.c +++ b/demos/gtk-demo/entry_undo.c @@ -43,6 +43,10 @@ do_entry_undo (GtkWidget *do_widget) entry = gtk_entry_new (); gtk_editable_set_enable_undo (GTK_EDITABLE (entry), TRUE); gtk_box_append (GTK_BOX (vbox), entry); + + gtk_accessible_update_relation (GTK_ACCESSIBLE (entry), + GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL, + -1); } if (!gtk_widget_get_visible (window)) diff --git a/demos/gtk-demo/errorstates.c b/demos/gtk-demo/errorstates.c index c3a9bbc041..bdd765ee97 100644 --- a/demos/gtk-demo/errorstates.c +++ b/demos/gtk-demo/errorstates.c @@ -22,11 +22,15 @@ validate_more_details (GtkEntry *entry, { gtk_widget_set_tooltip_text (GTK_WIDGET (entry), "Must have details first"); gtk_widget_add_css_class (GTK_WIDGET (entry), "error"); + gtk_accessible_update_state (GTK_ACCESSIBLE (entry), + GTK_ACCESSIBLE_STATE_INVALID, GTK_ACCESSIBLE_INVALID_TRUE, + -1); } else { gtk_widget_set_tooltip_text (GTK_WIDGET (entry), ""); gtk_widget_remove_css_class (GTK_WIDGET (entry), "error"); + gtk_accessible_reset_state (GTK_ACCESSIBLE (entry), GTK_ACCESSIBLE_STATE_INVALID); } } @@ -44,10 +48,18 @@ mode_switch_state_set (GtkSwitch *sw, { gtk_widget_set_visible (label, FALSE); gtk_switch_set_state (sw, state); + gtk_accessible_reset_relation (GTK_ACCESSIBLE (sw), GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE); + gtk_accessible_reset_state (GTK_ACCESSIBLE (sw), GTK_ACCESSIBLE_STATE_INVALID); } else { gtk_widget_set_visible (label, TRUE); + gtk_accessible_update_relation (GTK_ACCESSIBLE (sw), + GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE, label, + -1); + gtk_accessible_update_state (GTK_ACCESSIBLE (sw), + GTK_ACCESSIBLE_STATE_INVALID, GTK_ACCESSIBLE_INVALID_TRUE, + -1); } return TRUE; @@ -73,6 +85,9 @@ level_scale_value_changed (GtkRange *range, { gtk_switch_set_state (GTK_SWITCH (sw), FALSE); } + + gtk_accessible_reset_relation (GTK_ACCESSIBLE (sw), GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE); + gtk_accessible_reset_state (GTK_ACCESSIBLE (sw), GTK_ACCESSIBLE_STATE_INVALID); } GtkWidget *