summaryrefslogtreecommitdiff
path: root/gtk/gtkcheckbutton.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-07-17 15:51:28 -0400
committerEmmanuele Bassi <ebassi@gnome.org>2020-07-26 20:31:15 +0100
commite17b5f337d319a89f979f623b124f1653670a042 (patch)
treea3ef0921a6b78ea76b58c4698d07622f1241de3d /gtk/gtkcheckbutton.c
parentc36ad5f474a7b6c516b1b2943c43dc41a2c74a46 (diff)
downloadgtk+-e17b5f337d319a89f979f623b124f1653670a042.tar.gz
a11y: Update GtkCheckButton
This is a bit unfortunate, since the aria modelling doesn't quite agree with ours, so we have to listen for the togglebutton property change, and we inherit the pressed state from the togglebutton accessible.
Diffstat (limited to 'gtk/gtkcheckbutton.c')
-rw-r--r--gtk/gtkcheckbutton.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index efc0112791..82e2fd5963 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -172,11 +172,42 @@ gtk_check_button_get_property (GObject *object,
}
static void
+update_accessible_state (GtkCheckButton *check_button)
+{
+ GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (check_button);
+
+ GtkAccessibleTristate checked_state;
+
+ if (priv->inconsistent)
+ checked_state = GTK_ACCESSIBLE_TRISTATE_MIXED;
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_button)))
+ checked_state = GTK_ACCESSIBLE_TRISTATE_TRUE;
+ else
+ checked_state = GTK_ACCESSIBLE_TRISTATE_FALSE;
+
+ gtk_accessible_update_state (GTK_ACCESSIBLE (check_button),
+ GTK_ACCESSIBLE_STATE_CHECKED, checked_state,
+ -1);
+}
+
+static void
+gtk_check_button_notify (GObject *object,
+ GParamSpec *pspec)
+{
+ if (pspec->name == I_("active"))
+ update_accessible_state (GTK_CHECK_BUTTON (object));
+
+ if (G_OBJECT_CLASS (gtk_check_button_parent_class)->notify)
+ G_OBJECT_CLASS (gtk_check_button_parent_class)->notify (object, pspec);
+}
+
+static void
gtk_check_button_class_init (GtkCheckButtonClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+ object_class->notify = gtk_check_button_notify;
object_class->finalize = gtk_check_button_finalize;
object_class->set_property = gtk_check_button_set_property;
object_class->get_property = gtk_check_button_get_property;
@@ -394,6 +425,8 @@ gtk_check_button_set_inconsistent (GtkCheckButton *check_button,
else
gtk_widget_unset_state_flags (GTK_WIDGET (check_button), GTK_STATE_FLAG_INCONSISTENT);
+ update_accessible_state (check_button);
+
g_object_notify_by_pspec (G_OBJECT (check_button), props[PROP_INCONSISTENT]);
}
}