[gtk/a11y/atspi] atspi: Derive readonly state from aria properties



commit 66a81f118700fd4d627d1e88f9bac975e5c793f9
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Oct 11 23:35:34 2020 -0400

    atspi: Derive readonly state from aria properties
    
    We can use the read-only property, together with the
    accessible role, to determine whether to set editable
    and read-only states for at-spi. This lets us avoid
    directly poking at the widgets.

 gtk/a11y/gtkatspicontext.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c
index 332c52c4d7..2b6b3394b4 100644
--- a/gtk/a11y/gtkatspicontext.c
+++ b/gtk/a11y/gtkatspicontext.c
@@ -97,19 +97,23 @@ collect_states (GtkAtSpiContext    *self,
                 GVariantBuilder *builder)
 {
   GtkATContext *ctx = GTK_AT_CONTEXT (self);
-  GtkWidget *widget = GTK_WIDGET (gtk_at_context_get_accessible (ctx));
   GtkAccessibleValue *value;
   guint64 state = 0;
 
   state |= (G_GUINT64_CONSTANT (1) << ATSPI_STATE_VISIBLE);
 
-  if (GTK_IS_EDITABLE (widget) &&
-      gtk_editable_get_editable (GTK_EDITABLE (widget)))
+  if (ctx->accessible_role == GTK_ACCESSIBLE_ROLE_TEXT_BOX)
     state |= (G_GUINT64_CONSTANT (1) << ATSPI_STATE_EDITABLE);
 
-  if (GTK_IS_TEXT_VIEW (widget) &&
-      gtk_text_view_get_editable (GTK_TEXT_VIEW (widget)))
-    state |= (G_GUINT64_CONSTANT (1) << ATSPI_STATE_EDITABLE);
+  if (gtk_at_context_has_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_READ_ONLY))
+    {
+      value = gtk_at_context_get_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_READ_ONLY);
+      if (gtk_boolean_accessible_value_get (value))
+        {
+          state |= (G_GUINT64_CONSTANT (1) << ATSPI_STATE_READ_ONLY);
+          state &= ~(G_GUINT64_CONSTANT (1) << ATSPI_STATE_EDITABLE);
+        }
+    }
 
   if (gtk_at_context_has_accessible_state (ctx, GTK_ACCESSIBLE_STATE_BUSY))
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]