[gtk/matthiasc/a11y] atspi: Set editable state



commit 089f75169fb8b8576f0c2b5582da9ce6b31dfc02
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Oct 11 18:59:22 2020 -0400

    atspi: Set editable state
    
    ATs look at not just the implemented interfaces, but
    also the states to decide what to do. It turns out that
    the EditableText interface is only used by accerciser
    if the editable state is set. So set it.

 gtk/a11y/gtkatspicontext.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
---
diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c
index 2600565b99..332c52c4d7 100644
--- a/gtk/a11y/gtkatspicontext.c
+++ b/gtk/a11y/gtkatspicontext.c
@@ -27,14 +27,18 @@
 #include "gtkatspiprivate.h"
 #include "gtkatspiutilsprivate.h"
 #include "gtkatspitextprivate.h"
+#include "gtkatspieditabletextprivate.h"
 #include "gtkatspivalueprivate.h"
 
 #include "a11y/atspi/atspi-accessible.h"
 #include "a11y/atspi/atspi-text.h"
+#include "a11y/atspi/atspi-editabletext.h"
 #include "a11y/atspi/atspi-value.h"
 
 #include "gtkdebug.h"
+#include "gtkeditable.h"
 #include "gtkroot.h"
+#include "gtktextview.h"
 #include "gtkwindow.h"
 
 #include <gio/gio.h>
@@ -93,11 +97,20 @@ 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)))
+    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_state (ctx, GTK_ACCESSIBLE_STATE_BUSY))
     {
       value = gtk_at_context_get_accessible_state (ctx, GTK_ACCESSIBLE_STATE_BUSY);
@@ -538,6 +551,18 @@ gtk_at_spi_context_register_object (GtkAtSpiContext *self)
                                          NULL);
     }
 
+  vtable = gtk_atspi_get_editable_text_vtable (widget);
+  if (vtable)
+    {
+      g_variant_builder_add (&interfaces, "s", "org.a11y.atspi.EditableText");
+      g_dbus_connection_register_object (self->connection,
+                                         self->context_path,
+                                         (GDBusInterfaceInfo *) &atspi_editable_text_interface,
+                                         vtable,
+                                         self,
+                                         NULL,
+                                         NULL);
+    }
   vtable = gtk_atspi_get_value_vtable (widget);
   if (vtable)
     {


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