From 2b049d5d66205e76ec1ca10495cb3c25dcf6120d Mon Sep 17 00:00:00 2001 From: Daniel Boles Date: Mon, 7 Aug 2017 10:32:13 +0100 Subject: [PATCH] AccelLabel: set_accel_closure() arg is nullable --- gtk/gtkaccellabel.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c index 7a18c7e47a..099829ee7e 100644 --- a/gtk/gtkaccellabel.c +++ b/gtk/gtkaccellabel.c @@ -592,16 +592,20 @@ check_accel_changed (GtkAccelGroup *accel_group, /** * gtk_accel_label_set_accel_closure: * @accel_label: a #GtkAccelLabel - * @accel_closure: the closure to monitor for accelerator changes. + * @accel_closure: (nullable): the closure to monitor for accelerator changes, + * or %NULL * * Sets the closure to be monitored by this accelerator label. The closure * must be connected to an accelerator group; see gtk_accel_group_connect(). + * Passing %NULL for @accel_closure will dissociate @accel_label from its + * current closure, if any. **/ void gtk_accel_label_set_accel_closure (GtkAccelLabel *accel_label, GClosure *accel_closure) { g_return_if_fail (GTK_IS_ACCEL_LABEL (accel_label)); + if (accel_closure) g_return_if_fail (gtk_accel_group_from_accel_closure (accel_closure) != NULL); @@ -615,7 +619,9 @@ gtk_accel_label_set_accel_closure (GtkAccelLabel *accel_label, accel_label->priv->accel_group = NULL; g_closure_unref (accel_label->priv->accel_closure); } + accel_label->priv->accel_closure = accel_closure; + if (accel_label->priv->accel_closure) { g_closure_ref (accel_label->priv->accel_closure); @@ -624,6 +630,7 @@ gtk_accel_label_set_accel_closure (GtkAccelLabel *accel_label, G_CALLBACK (check_accel_changed), accel_label, 0); } + gtk_accel_label_reset (accel_label); g_object_notify_by_pspec (G_OBJECT (accel_label), props[PROP_ACCEL_CLOSURE]); }