How do I bind a property to an action state from an UI file?

I’d like to bind the reveal-child property of a GtkRevealer to mirror an action state. I have a toggle action named app.playback-playing and I wanted it to be the source of that binding.

What I did was the following:

<binding name="reveal-child">
  <closure type="gboolean" function="g_variant_get_boolean">
	<lookup name="state">
	  <closure type="GSimpleAction" function="g_action_map_lookup_action">
		<closure type="GActionMap" function="g_application_get_default"></closure>
		<constant type="gchararray">playback-playing</constant>
	  </closure>
	</lookup>
  </closure>
</binding>

which is very contrived and is not working… Also, when I quit my application it generates lots of warnings that it didn’t before:

Console output
(qxplayer:7022): GLib-GIO-WARNING **: 15:11:29.945: Your application did not unregister from D-Bus before destruction. Consider using g_application_run().
(qxplayer:7022): GLib-GObject-WARNING **: 15:11:29.969: instance with invalid (NULL) class pointer
(qxplayer:7022): GLib-GObject-CRITICAL **: 15:11:29.969: g_signal_handler_disconnect: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(qxplayer:7022): GLib-GObject-WARNING **: 15:11:29.969: instance with invalid (NULL) class pointer
(qxplayer:7022): GLib-GObject-CRITICAL **: 15:11:29.969: g_signal_handler_disconnect: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(qxplayer:7022): GLib-GObject-WARNING **: 15:11:29.969: instance with invalid (NULL) class pointer
(qxplayer:7022): GLib-GObject-CRITICAL **: 15:11:29.969: g_signal_handler_disconnect: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(qxplayer:7022): GLib-GObject-WARNING **: 15:11:29.969: instance with invalid (NULL) class pointer
(qxplayer:7022): GLib-GObject-CRITICAL **: 15:11:29.969: g_signal_handler_disconnect: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(qxplayer:7022): GLib-GObject-CRITICAL **: 15:11:29.969: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(qxplayer:7022): GLib-GObject-WARNING **: 15:11:29.970: instance with invalid (NULL) class pointer
(qxplayer:7022): GLib-GObject-CRITICAL **: 15:11:29.970: g_signal_emit_valist: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

What is the correct way to do it?

Thank you, guys.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.