[gtk/a11y/atspi] entry: Implement GtkAccessible



commit 8faf1f64ee06f93f2140b9a88417fb6dfb20ce29
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Oct 12 20:18:48 2020 -0400

    entry: Implement GtkAccessible
    
    Override the get_platform_state vfunc to get
    the focused state from the GtkText widget within.

 gtk/gtkentry.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 3d058bad27..68495f062a 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -30,6 +30,7 @@
 
 #include "gtkentryprivate.h"
 
+#include "gtkaccessibleprivate.h"
 #include "gtkadjustment.h"
 #include "gtkbox.h"
 #include "gtkbutton.h"
@@ -320,9 +321,12 @@ static void     gtk_entry_measure (GtkWidget           *widget,
 static GtkBuildableIface *buildable_parent_iface = NULL;
 
 static void     gtk_entry_buildable_interface_init (GtkBuildableIface *iface);
+static void     gtk_entry_accessible_interface_init (GtkAccessibleInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (GtkEntry, gtk_entry, GTK_TYPE_WIDGET,
                          G_ADD_PRIVATE (GtkEntry)
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_ACCESSIBLE,
+                                                gtk_entry_accessible_interface_init)
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
                                                 gtk_entry_buildable_interface_init)
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE,
@@ -330,6 +334,31 @@ G_DEFINE_TYPE_WITH_CODE (GtkEntry, gtk_entry, GTK_TYPE_WIDGET,
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE,
                                                 gtk_entry_cell_editable_init))
 
+static gboolean
+gtk_entry_accessible_get_platform_state (GtkAccessible              *self,
+                                         GtkAccessiblePlatformState  state)
+{
+  GtkEntry *entry = GTK_ENTRY (self);
+  GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
+
+  switch (state)
+    {
+    case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSABLE:
+      return gtk_widget_get_focusable (GTK_WIDGET (priv->text));
+    case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED:
+      return gtk_widget_has_focus (GTK_WIDGET (priv->text));
+    default:
+      g_assert_not_reached ();
+    }
+}
+
+static void
+gtk_entry_accessible_interface_init (GtkAccessibleInterface *iface)
+{
+  GtkAccessibleInterface *parent_iface = g_type_interface_peek_parent (iface);
+  iface->get_at_context = parent_iface->get_at_context;
+  iface->get_platform_state = gtk_entry_accessible_get_platform_state;
+}
 
 static const GtkBuildableParser pango_parser =
 {


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