diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-07-29 18:18:04 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-07-29 22:46:00 -0400 |
commit | c68fe1053aa7009161a5a2f1a137ff81693e9c47 (patch) | |
tree | ea542662e7bcf6890276092329910f21ffb33d64 /gtk/gtktextview.c | |
parent | 9722bb4d9e6508ebbaf4d237e5580a7209db31f4 (diff) | |
download | gtk+-c68fe1053aa7009161a5a2f1a137ff81693e9c47.tar.gz |
a11y: Set an accessible role for GtkTextView
Use the text-box accessible role for GtkTextView
and set properties as appropriate.
Update the documentation and add a test.
Diffstat (limited to 'gtk/gtktextview.c')
-rw-r--r-- | gtk/gtktextview.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 8be1e73a86..f59b259277 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -89,9 +89,12 @@ * * If a context menu is opened, the window node will appear as a subnode * of the main node. + * + * # Accessibility + * + * GtkTextView uses the #GTK_ACCESSIBLE_ROLE_TEXT_BOX role. */ - /* How scrolling, validation, exposes, etc. work. * * The expose_event handler has the invariant that the onscreen lines @@ -1801,6 +1804,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass) "(i)", GTK_DIR_TAB_BACKWARD); gtk_widget_class_set_css_name (widget_class, I_("textview")); + gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_TEXT_BOX); quark_text_selection_data = g_quark_from_static_string ("gtk-text-view-text-selection-data"); quark_gtk_signal = g_quark_from_static_string ("gtk-signal"); @@ -1942,6 +1946,10 @@ gtk_text_view_init (GtkTextView *text_view) gtk_widget_action_set_enabled (GTK_WIDGET (text_view), "text.can-redo", FALSE); gtk_widget_action_set_enabled (GTK_WIDGET (text_view), "text.can-undo", FALSE); + + gtk_accessible_update_property (GTK_ACCESSIBLE (widget), + GTK_ACCESSIBLE_PROPERTY_MULTI_LINE, TRUE, + -1); } GtkCssNode * @@ -3074,11 +3082,11 @@ gtk_text_view_set_editable (GtkTextView *text_view, if (priv->editable != setting) { if (!setting) - { - gtk_text_view_reset_im_context(text_view); - if (gtk_widget_has_focus (GTK_WIDGET (text_view))) - gtk_im_context_focus_out (priv->im_context); - } + { + gtk_text_view_reset_im_context (text_view); + if (gtk_widget_has_focus (GTK_WIDGET (text_view))) + gtk_im_context_focus_out (priv->im_context); + } priv->editable = setting; @@ -3090,12 +3098,16 @@ gtk_text_view_set_editable (GtkTextView *text_view, if (priv->layout && priv->layout->default_style) { - gtk_text_layout_set_overwrite_mode (priv->layout, - priv->overwrite_mode && priv->editable); + gtk_text_layout_set_overwrite_mode (priv->layout, + priv->overwrite_mode && priv->editable); priv->layout->default_style->editable = priv->editable; gtk_text_layout_default_style_changed (priv->layout); } + gtk_accessible_update_property (GTK_ACCESSIBLE (text_view), + GTK_ACCESSIBLE_PROPERTY_READ_ONLY, !setting, + -1); + g_object_notify (G_OBJECT (text_view), "editable"); } } |