bodil / vgtk

A declarative desktop UI framework for Rust built on GTK and Gtk-rs
http://bodil.lol/vgtk/
Other
1.05k stars 36 forks source link

allow non-unit signal return values #70

Closed pepijndevos closed 3 years ago

pepijndevos commented 3 years ago

As per #39 some signals do not return () but rather Inhibit(bool) or similar flags.

This PR introduces a IntoSignalReturn trait that has a blanket implementation for converting types into (). This trait is then used to create the return value of the signal callbacks. It will automatically convert any message to (), and allows the user to implement custom conversions, as follows:

impl IntoSignalReturn<Inhibit> for Message {
    fn into_signal_return(&self) -> Inhibit {
        Inhibit(false)
    }
}

My main concern is if this handles all cases, or needs special handling for subcomponents as @LiHRaM seemed to suggest. @bodil any input?