[gtk/a11y/atspi] accessible: Add gtk_accessible_get_platform_state
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/a11y/atspi] accessible: Add gtk_accessible_get_platform_state
- Date: Tue, 13 Oct 2020 01:59:57 +0000 (UTC)
commit ade9e4b82af90666711474b00b2342b1380937f1
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Oct 12 19:00:03 2020 -0400
accessible: Add gtk_accessible_get_platform_state
As a companion to go with the platform_change api,
add a gtk_accessible_get_platform_state() function
that can be used by backends to get the platform
state.
This is in preparation for making entries inherit
their focus states from the text widget within.
gtk/gtkaccessible.c | 17 +++++++++++++++++
gtk/gtkaccessibleprivate.h | 9 +++++++--
gtk/gtkatcontextprivate.h | 9 +++++++--
gtk/gtkwidget.c | 16 ++++++++++++++++
4 files changed, 47 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c
index 49186ed0ff..6215e032d8 100644
--- a/gtk/gtkaccessible.c
+++ b/gtk/gtkaccessible.c
@@ -643,6 +643,16 @@ gtk_accessible_platform_changed (GtkAccessible *self,
GtkAccessiblePlatformChange change)
{
GtkATContext *context = gtk_accessible_get_at_context (self);
+
+ /* propagate changes up from ignored widgets */
+ if (gtk_accessible_get_accessible_role (self) == GTK_ACCESSIBLE_ROLE_NONE)
+ {
+ if (gtk_widget_get_parent (GTK_WIDGET (self)) == NULL)
+ return;
+
+ context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (gtk_widget_get_parent (GTK_WIDGET (self))));
+ }
+
if (context == NULL)
return;
@@ -650,6 +660,13 @@ gtk_accessible_platform_changed (GtkAccessible *self,
gtk_at_context_update (context);
}
+gboolean
+gtk_accessible_get_platform_state (GtkAccessible *self,
+ GtkAccessiblePlatformState state)
+{
+ return GTK_ACCESSIBLE_GET_IFACE (self)->get_platform_state (self, state);
+}
+
gboolean
gtk_accessible_should_present (GtkAccessible *self)
{
diff --git a/gtk/gtkaccessibleprivate.h b/gtk/gtkaccessibleprivate.h
index ae4847f39c..4d1f458fb8 100644
--- a/gtk/gtkaccessibleprivate.h
+++ b/gtk/gtkaccessibleprivate.h
@@ -30,6 +30,9 @@ struct _GtkAccessibleInterface
GTypeInterface g_iface;
GtkATContext * (* get_at_context) (GtkAccessible *self);
+
+ gboolean (* get_platform_state) (GtkAccessible *self,
+ GtkAccessiblePlatformState state);
};
GtkATContext * gtk_accessible_get_at_context (GtkAccessible *self);
@@ -37,8 +40,10 @@ GtkATContext * gtk_accessible_get_at_context (GtkAccessible *self);
const char * gtk_accessible_role_to_name (GtkAccessibleRole role,
const char *domain);
-void gtk_accessible_platform_changed (GtkAccessible *self,
- GtkAccessiblePlatformChange change);
+void gtk_accessible_platform_changed (GtkAccessible *self,
+ GtkAccessiblePlatformChange change);
+gboolean gtk_accessible_get_platform_state (GtkAccessible *self,
+ GtkAccessiblePlatformState state);
gboolean gtk_accessible_should_present (GtkAccessible *self);
diff --git a/gtk/gtkatcontextprivate.h b/gtk/gtkatcontextprivate.h
index fb396c8ccc..4fec1444c8 100644
--- a/gtk/gtkatcontextprivate.h
+++ b/gtk/gtkatcontextprivate.h
@@ -81,8 +81,13 @@ typedef enum {
} GtkAccessibleStateChange;
typedef enum {
- GTK_ACCESSIBLE_PLATFORM_CHANGE_FOCUSABLE = 1 << 0,
- GTK_ACCESSIBLE_PLATFORM_CHANGE_FOCUSED = 1 << 1,
+ GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSABLE,
+ GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED,
+} GtkAccessiblePlatformState;
+
+typedef enum {
+ GTK_ACCESSIBLE_PLATFORM_CHANGE_FOCUSABLE = 1 << GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSABLE,
+ GTK_ACCESSIBLE_PLATFORM_CHANGE_FOCUSED = 1 << GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED,
} GtkAccessiblePlatformChange;
struct _GtkATContext
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index fea2da5c3f..acaaf9251a 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -8124,10 +8124,26 @@ gtk_widget_accessible_get_at_context (GtkAccessible *accessible)
return priv->at_context;
}
+static gboolean
+gtk_widget_accessible_get_platform_state (GtkAccessible *self,
+ GtkAccessiblePlatformState state)
+{
+ switch (state)
+ {
+ case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSABLE:
+ return gtk_widget_get_focusable (GTK_WIDGET (self));
+ case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED:
+ return gtk_widget_has_focus (GTK_WIDGET (self));
+ default:
+ g_assert_not_reached ();
+ }
+}
+
static void
gtk_widget_accessible_interface_init (GtkAccessibleInterface *iface)
{
iface->get_at_context = gtk_widget_accessible_get_at_context;
+ iface->get_platform_state = gtk_widget_accessible_get_platform_state;
}
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]