[gtk/matthiasc/atspi-child] a11y: Handle all cases for state change
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/atspi-child] a11y: Handle all cases for state change
- Date: Sun, 25 Oct 2020 02:06:29 +0000 (UTC)
commit 8ffb39851746f364594d4bd52a2869886435fef3
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Oct 24 22:05:17 2020 -0400
a11y: Handle all cases for state change
Make state_change handle state changes for non-widgets,
and handle the cases for HIDDEN involving stack pages.
gtk/a11y/gtkatspicontext.c | 51 +++++++++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 25 deletions(-)
---
diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c
index 1787a9f2c9..b7ab1458b5 100644
--- a/gtk/a11y/gtkatspicontext.c
+++ b/gtk/a11y/gtkatspicontext.c
@@ -837,41 +837,38 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
{
GtkAtSpiContext *self = GTK_AT_SPI_CONTEXT (ctx);
GtkAccessible *accessible = gtk_at_context_get_accessible (ctx);
- GtkWidget *widget;
GtkAccessibleValue *value;
- if (!GTK_IS_WIDGET (accessible))
- return;
-
- widget = GTK_WIDGET (accessible);
- if (!gtk_widget_get_realized (widget))
+ if (GTK_IS_WIDGET (accessible) && !gtk_widget_get_realized (GTK_WIDGET (accessible)))
return;
if (changed_states & GTK_ACCESSIBLE_STATE_CHANGE_HIDDEN)
{
GtkWidget *parent;
- gboolean hidden;
+ GtkATContext *context;
+ GtkAccessibleChildChange change;
value = gtk_accessible_attribute_set_get_value (states, GTK_ACCESSIBLE_STATE_HIDDEN);
- hidden = gtk_boolean_accessible_value_get (value);
+ if (gtk_boolean_accessible_value_get (value))
+ change = GTK_ACCESSIBLE_CHILD_CHANGE_REMOVED;
+ else
+ change = GTK_ACCESSIBLE_CHILD_CHANGE_ADDED;
- parent = gtk_widget_get_parent (widget);
- if (parent)
+ if (GTK_IS_ROOT (accessible))
{
- if (GTK_IS_STACK (parent))
- g_warning ("Setting GTK_ACCESSIBLE_STATE_HIDDEN on stack children is not supported");
- else
- gtk_at_context_child_changed (gtk_accessible_get_at_context (GTK_ACCESSIBLE (parent)),
- hidden ? GTK_ACCESSIBLE_CHILD_CHANGE_REMOVED
- : GTK_ACCESSIBLE_CHILD_CHANGE_ADDED,
- GTK_ACCESSIBLE (widget));
+ gtk_at_spi_root_child_changed (self->root, change, accessible);
}
else
{
- gtk_at_spi_root_child_changed (self->root,
- hidden ? GTK_ACCESSIBLE_CHILD_STATE_REMOVED
- : GTK_ACCESSIBLE_CHILD_STATE_ADDED,
- widget);
+ if (GTK_IS_WIDGET (accessible))
+ parent = gtk_widget_get_parent (GTK_WIDGET (accessible));
+ else if (GTK_IS_STACK_PAGE (accessible))
+ parent = gtk_widget_get_parent (gtk_stack_page_get_child (GTK_STACK_PAGE (accessible)));
+ else
+ g_assert_not_reached ();
+
+ context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (parent));
+ gtk_at_context_child_changed (context, change, accessible);
}
}
@@ -1097,15 +1094,12 @@ gtk_at_spi_context_child_change (GtkATContext *ctx,
GtkWidget *child_widget;
int idx = 0;
- if (!GTK_IS_WIDGET (accessible) || !GTK_IS_WIDGET (child))
+ if (!GTK_IS_WIDGET (accessible))
return;
if (child_context == NULL)
return;
- parent_widget = GTK_WIDGET (accessible);
- child_widget = GTK_WIDGET (child);
-
/* handle the stack page special case */
if (GTK_IS_WIDGET (child) &&
GTK_IS_STACK (gtk_widget_get_parent (GTK_WIDGET (child))))
@@ -1163,6 +1157,13 @@ gtk_at_spi_context_child_change (GtkATContext *ctx,
return;
}
+ parent_widget = GTK_WIDGET (accessible);
+
+ if (GTK_IS_STACK_PAGE (child))
+ child_widget = gtk_stack_page_get_child (GTK_STACK_PAGE (child));
+ else
+ child_widget = GTK_WIDGET (child);
+
if (gtk_widget_get_parent (child_widget) != parent_widget)
{
idx = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]