idanarye / woab

Widgets on Actors Bridge - a GUI microframework for combining GTK with Actix
https://crates.io/crates/woab
MIT License
14 stars 1 forks source link

gboolean in event handling #17

Closed piegamesde closed 3 years ago

piegamesde commented 3 years ago

I added a variant like this to my signal enum: OnButtonToggle(gtk::CheckButton, bool),

This panics at runtime GetError { actual: GParam, requested: gboolean }, and I don't really understand why or what would be "correct".

idanarye commented 3 years ago

I think this is the signal? https://developer.gnome.org/gtk3/stable/GtkToggleButton.html#GtkToggleButton-toggled

It does not look like the toggle signal has a second argument. No idea why you are not getting the proper Expected OnButtonToggle to have 2 parameters - got 1 error though...

piegamesde commented 3 years ago

No, the signal I have in the xml file is notify::active. I couldn't manage to find out which connect_ method it maps in GTK-rs though.

idanarye commented 3 years ago

It looks like all the connect_notify methods are receiving a closure that receives ParamSpec - so that's the type you need.

Note that this type does not seem to contain the actual boolean value - instead you need to get the property name from it and pass it to the widget's get_property. Maybe WoAB can do that for your with a new #[signal(param)] annotation?

piegamesde commented 3 years ago

Thanks, it works now. Turns out that I confounded the "actual" and the "requested" paramters of the error message. Also I didn't figure out that GParam is ParamSpec in the bindings.

Note that this type does not seem to contain the actual boolean value - instead you need to get the property name from it and pass it to the widget's get_property.

Ugh, in that case I'll simply query the property in question from the widget.

Maybe WoAB can do that for your with a new #[signal(param)] annotation?

If you want to improve the signal enum (it's fine for me, and who knows if it will exist in the future), add some attributes that have more broad use cases. For example, to only use the first parameter, or to not use the first parameter etc.