infirit
(infirit)
January 4, 2023, 6:40pm
#1
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))
infirit
(infirit)
January 5, 2023, 3:38pm
#2
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.
infirit
(infirit)
January 6, 2023, 7:58pm
#4
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?
system
(system)
Closed
February 5, 2023, 7:58pm
#5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.