Gtk.ToggleButton no state in Gio.SimpleAction

I am trying to get the state of a Gtk.ToggleButton in a Gio.SimpleAction. I can toggle it but the state I get is always None. What am I missing here?

search_button = Gtk.ToggleButton(label="Search")
search_button.set_action_name("app.search")
search_action = Gio.SimpleAction.new_stateful("search", None, GLib.Variant.new_boolean(False))

I kinda “solved” it by manually setting the state in the change-state and then execute my code in the same callback. I do feel this is weird as I would have expected to see the proper state in the activate signal.

Yes, this is what you have to do, it’s designed this way because you could add some conditional there to make the activation fail.

That seems very odd to me. I can easily update the state in the activate callback if I wanted to.

Anyway, does this apply to all stateful actions?

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