gtk-rs / gtk3-rs

Rust bindings for GTK 3
https://gtk-rs.org
MIT License
508 stars 90 forks source link

Glade: Add connect object feature to the builder signal connection #129

Open DBLouis opened 4 years ago

DBLouis commented 4 years ago

Is passing user data to a signal handler supported? I load and XML generated by Glade and it panics here: https://github.com/gtk-rs/gtk/blob/master/src/builder.rs#L81. I am not sure if this failed assert means that I messed up somehow or if this is not supported.

sdroege commented 4 years ago

Can you provide a complete code example that reproduces the problem? The connect object feature is not currently supported, but that also shouldn't usually be needed.

DBLouis commented 4 years ago

If you use the example repo, take the builder_signal program and add an object attribute to the button. It will panic with the same error.

I new to GTK, basically I wanted to have one function that called show() on any widget and pass the name of the widget via the userdata. But maybe that is not possible.

sdroege commented 4 years ago

You will have to pass any context into the signal handler when creating the closures in there. I can't remember the details about the connect object feature, but if I remember correctly it was difficult/impossible to implement that safely.