Gtk-rs GCallback and g_signal_connect_data

Trying to use g_signal_connect_data in gtk-rs. One of the arguments is of type GCallback, which is defined as Option<unsafe extern "C" fn()>. However, the function parameter required by the (FFI) g_signal_connect_data needs to take at least one argument. In fact, I can't see any use at all for a callback function that does not receive any data - it would be rather in the dark as to what it should do. Anyway, I've tried to use a Rust function that does take an argument, but cannot see how to coerce its type into something the compiler will be happy with. Grateful for any ideas. Or is it perhaps even a bug in gtk-rs?

OK, found the answer by asking elsewhere. Basically, I hadn't realised that transmute could work on functions, as well as on data objects. Since it does, it's simple to cast my callback to the expected type. Another case of RTFM ... :slight_smile:

If the gtk-rs api expects the wrong signature, please file a bug.

I did post a bug, and was told to use transmute. I must say, on further reflection, that does not sound sensible; the function signature is known, and it's not GCallback, so why not supply a paramter type that does not need transmute? Perhaps I'll have another crack at the bug people! :slight_smile:

The bug people pointed me to this, which allows glib::object::Object::connect to safely connect a closure to a signal. And indeed it worked just fine, so my original use of the raw FFI library gobject_sys::g_signal_connect_data was not the best approach. We live and learn. :slight_smile: