From 115f60796f329ad804bba0ba1d6483376653a176 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 17 Jun 2023 11:37:11 -0400 Subject: [PATCH 1/6] gtk-demo: Cosmetics --- demos/gtk-demo/pickers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/gtk-demo/pickers.c b/demos/gtk-demo/pickers.c index 309362cc9d..4c99bf8141 100644 --- a/demos/gtk-demo/pickers.c +++ b/demos/gtk-demo/pickers.c @@ -249,7 +249,7 @@ do_pickers (GtkWidget *do_widget) } if (!gtk_widget_get_visible (window)) - gtk_widget_set_visible (window, TRUE); + gtk_window_present (GTK_WINDOW (window)); else gtk_window_destroy (GTK_WINDOW (window)); From 80c4d4f51deedefcedfeb0cc8794d8ad66d296fd Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 17 Jun 2023 11:37:22 -0400 Subject: [PATCH 2/6] colordialogbutton: Sync color Make sure the color of the swatch and the button are initially in sync. As a side-effect, this ensures that the swatch has its accessible label computed at the outset. --- gtk/gtkcolordialogbutton.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk/gtkcolordialogbutton.c b/gtk/gtkcolordialogbutton.c index 10f527febf..dce03690d1 100644 --- a/gtk/gtkcolordialogbutton.c +++ b/gtk/gtkcolordialogbutton.c @@ -141,6 +141,8 @@ gtk_color_dialog_button_init (GtkColorDialogButton *self) GTK_PHASE_CAPTURE); gtk_widget_add_controller (self->button, GTK_EVENT_CONTROLLER (source)); gtk_widget_add_css_class (self->button, "color"); + + gtk_color_dialog_button_set_rgba (self, &(GdkRGBA) { 0.75, 0.25, 0.25, 1.0 }); } static void From efeff41501225d910977b352c25da246ba5f3a40 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 17 Jun 2023 12:18:34 -0400 Subject: [PATCH 3/6] a11y: Set has-popup consistently Set the has-popup property when a widget has a context menu. --- gtk/gtkentry.c | 4 ++++ gtk/gtklabel.c | 11 +++++++++++ gtk/gtkpasswordentry.c | 4 ++++ gtk/gtksearchentry.c | 4 ++++ gtk/gtktext.c | 4 ++++ gtk/gtktextview.c | 5 +++++ 6 files changed, 32 insertions(+) diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 761a10ccff..67281c2f36 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -1396,6 +1396,10 @@ gtk_entry_init (GtkEntry *entry) GTK_EVENT_CONTROLLER (catchall)); priv->editing_canceled = FALSE; + + gtk_accessible_update_property (GTK_ACCESSIBLE (entry), + GTK_ACCESSIBLE_PROPERTY_HAS_POPUP, TRUE, + -1); } static void diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index a90b2c480b..d8741e8481 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -4951,6 +4951,10 @@ gtk_label_set_selectable (GtkLabel *self, gtk_label_ensure_select_info (self); self->select_info->selectable = TRUE; gtk_label_update_cursor (self); + + gtk_accessible_update_property (GTK_ACCESSIBLE (self), + GTK_ACCESSIBLE_PROPERTY_HAS_POPUP, TRUE, + -1); } else { @@ -4962,7 +4966,10 @@ gtk_label_set_selectable (GtkLabel *self, self->select_info->selectable = FALSE; gtk_label_clear_select_info (self); } + + gtk_accessible_reset_property (GTK_ACCESSIBLE (self), GTK_ACCESSIBLE_PROPERTY_HAS_POPUP); } + if (setting != old_setting) { g_object_freeze_notify (G_OBJECT (self)); @@ -5744,6 +5751,10 @@ gtk_label_do_popup (GtkLabel *self, gtk_popover_set_has_arrow (GTK_POPOVER (self->popup_menu), FALSE); gtk_widget_set_halign (self->popup_menu, GTK_ALIGN_START); + gtk_accessible_update_property (GTK_ACCESSIBLE (self->popup_menu), + GTK_ACCESSIBLE_PROPERTY_LABEL, _("Context menu"), + -1); + g_object_unref (model); } diff --git a/gtk/gtkpasswordentry.c b/gtk/gtkpasswordentry.c index e88e2d14fe..eaf1df82ab 100644 --- a/gtk/gtkpasswordentry.c +++ b/gtk/gtkpasswordentry.c @@ -229,6 +229,10 @@ gtk_password_entry_init (GtkPasswordEntry *entry) /* Transfer ownership to the GtkText widget */ g_object_unref (buffer); + + gtk_accessible_update_property (GTK_ACCESSIBLE (entry), + GTK_ACCESSIBLE_PROPERTY_HAS_POPUP, TRUE, + -1); } static void diff --git a/gtk/gtksearchentry.c b/gtk/gtksearchentry.c index faf85d6803..6191d1f01e 100644 --- a/gtk/gtksearchentry.c +++ b/gtk/gtksearchentry.c @@ -771,6 +771,10 @@ gtk_search_entry_init (GtkSearchEntry *entry) GTK_EVENT_CONTROLLER (catchall)); gtk_widget_add_css_class (GTK_WIDGET (entry), I_("search")); + + gtk_accessible_update_property (GTK_ACCESSIBLE (entry), + GTK_ACCESSIBLE_PROPERTY_HAS_POPUP, TRUE, + -1); } /** diff --git a/gtk/gtktext.c b/gtk/gtktext.c index e4605a6970..2a74fb3d92 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -2712,6 +2712,10 @@ gtk_text_do_popup (GtkText *self, gtk_popover_set_has_arrow (GTK_POPOVER (priv->popup_menu), FALSE); gtk_widget_set_halign (priv->popup_menu, GTK_ALIGN_START); + gtk_accessible_update_property (GTK_ACCESSIBLE (priv->popup_menu), + GTK_ACCESSIBLE_PROPERTY_LABEL, _("Context menu"), + -1); + g_object_unref (model); } diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 18aa13c99f..b0a68f8504 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -2024,6 +2024,7 @@ gtk_text_view_init (GtkTextView *text_view) gtk_accessible_update_property (GTK_ACCESSIBLE (widget), GTK_ACCESSIBLE_PROPERTY_MULTI_LINE, TRUE, + GTK_ACCESSIBLE_PROPERTY_HAS_POPUP, TRUE, -1); } @@ -9089,6 +9090,10 @@ gtk_text_view_do_popup (GtkTextView *text_view, gtk_popover_set_has_arrow (GTK_POPOVER (priv->popup_menu), FALSE); gtk_widget_set_halign (priv->popup_menu, GTK_ALIGN_START); + gtk_accessible_update_property (GTK_ACCESSIBLE (priv->popup_menu), + GTK_ACCESSIBLE_PROPERTY_LABEL, _("Context menu"), + -1); + g_object_unref (model); } From 158a3d4f04edb9f34e9e0d3f5c4405fdf3d032c0 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 17 Jun 2023 14:48:18 -0400 Subject: [PATCH 4/6] inspector: Realize AT ontexts Otherwise we don't get change notification... --- gtk/inspector/a11y.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk/inspector/a11y.c b/gtk/inspector/a11y.c index e06e767bea..c07b4f0290 100644 --- a/gtk/inspector/a11y.c +++ b/gtk/inspector/a11y.c @@ -486,6 +486,7 @@ gtk_inspector_a11y_set_object (GtkInspectorA11y *sl, context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (sl->object)); if (context != NULL) { + gtk_at_context_realize (context); g_signal_connect_swapped (context, "state-change", G_CALLBACK (refresh_all), sl); g_object_unref (context); } From e251e7583f48c7a0c25480dab4c35bef658f19bb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 17 Jun 2023 12:19:05 -0400 Subject: [PATCH 5/6] 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 * From cbdcf64e4dd3c92de6401700e7b07b6e19c337eb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 17 Jun 2023 16:44:16 -0400 Subject: [PATCH 6/6] inspector: Limit the width of a11y page Ellipsize labels that can contain long content to prevent a super-wide window. --- gtk/inspector/a11y.c | 2 ++ gtk/inspector/a11y.ui | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/gtk/inspector/a11y.c b/gtk/inspector/a11y.c index c07b4f0290..98c496fba1 100644 --- a/gtk/inspector/a11y.c +++ b/gtk/inspector/a11y.c @@ -404,6 +404,8 @@ setup_cell_cb (GtkSignalListItemFactory *factory, label = gtk_label_new (NULL); gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); + gtk_label_set_width_chars (GTK_LABEL (label), 50); gtk_widget_set_margin_start (label, 6); gtk_widget_set_margin_end (label, 6); gtk_list_item_set_child (list_item, label); diff --git a/gtk/inspector/a11y.ui b/gtk/inspector/a11y.ui index fad8470f31..dd35af307a 100644 --- a/gtk/inspector/a11y.ui +++ b/gtk/inspector/a11y.ui @@ -55,6 +55,8 @@ 1 end baseline + end + 50 1 1 @@ -81,6 +83,8 @@ 1 end baseline + end + 50 2 1 @@ -133,6 +137,8 @@ 1 end baseline + end + 50 4 1