gtk-rs-core
gtk-rs-core copied to clipboard
`ObjectExt.emit_by_name()` has arcane syntax when there's no return value
The documentation says:
fn emit_by_name<R: TryFromClosureReturnValue>(
&self,
signal_name: &str,
args: &[&dyn ToValue]
) -> R
TryFromClosureReturnValue
is completely unhelpful: https://gtk-rs.org/gtk-rs-core/stable/0.17/docs/glib/closure/trait.TryFromClosureReturnValue.html
It's really hard to figure out that you have to do obj.emit_by_name::<()>("signal-name", &[...])
.
Maybe we can have emit_by_name()
that discards the value and emit_by_name_return<R>()
for when you want the return value?
I think the long term plan here is that we have a macro to generate signals that would also generate emit_foo
with the right signature
That doesn't help you with signals defined by GStreamer plugins, which I assume is what @nirbheek was using.
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/252 would be somewhat a solution for that, but having a general nicer API would still be good.