summaryrefslogtreecommitdiff
path: root/gtk/gtkcheckbutton.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-07-17 15:51:28 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-07-17 15:51:28 -0400
commit71fbf35f059bdbf5a10feda63de16164c065a93b (patch)
tree733811e06493caeb1d78dff123fdbe2a63309cad /gtk/gtkcheckbutton.c
parent8d31dbdc082ea98cd1063caac80d12cd57b43b53 (diff)
downloadgtk+-matthiasc/a11y-logging.tar.gz
a11y: Update GtkCheckButtonmatthiasc/a11y-logging
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 9761dabebe..530db1237e 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]);
}
}