builder: Fix connect_signals_full Fn in Rust 1.34.0
@@ -22,7 +22,10 @@ impl Builder {
pub trait BuilderExtManual: 'static {
fn get_object<T: IsA<Object>>(&self, name: &str) -> Option<T>;
fn add_from_file<T: AsRef<Path>>(&self, file_path: T) -> Result<(), Error>;
- fn connect_signals_full<P: FnMut(&Builder, &str) -> Box<dyn Fn(&[glib::Value]) -> Option<glib::Value> + Send + Sync + 'static>>(&self, func: P);
+ fn connect_signals_full<P, F>(&self, func: P)
+ where
+ P: FnMut(&Builder, &str) -> F,
+ F: Fn(&[glib::Value]) -> Option<glib::Value> + Send + Sync + 'static,;
}
impl<O: IsA<Builder>> BuilderExtManual for O {
@@ -44,9 +47,18 @@ impl<O: IsA<Builder>> BuilderExtManual for O {
}
}
- fn connect_signals_full<P: FnMut(&Builder, &str) -> Box<dyn Fn(&[glib::Value]) -> Option<glib::Value> + Send + Sync + 'static>>(&self, func: P) {
+ fn connect_signals_full<P, F>(&self, func: P)
+ where
+ P: FnMut(&Builder, &str) -> F,
+ F: Fn(&[glib::Value]) -> Option<glib::Value> + Send + Sync + 'static,
+ {
let func_data: P = func;
- unsafe extern "C" fn func_func<P: FnMut(&Builder, &str) -> Box<dyn Fn(&[glib::Value]) -> Option<glib::Value> + Send + Sync + 'static>>(builder: *mut gtk_sys::GtkBuilder, object: *mut gobject_sys::GObject, signal_name: *const libc::c_char, handler_name: *const libc::c_char, connect_object: *mut gobject_sys::GObject, flags: gobject_sys::GConnectFlags, user_data: glib_sys::gpointer) {
+
+ unsafe extern "C" fn func_func<P, F>(builder: *mut gtk_sys::GtkBuilder, object: *mut gobject_sys::GObject, signal_name: *const libc::c_char, handler_name: *const libc::c_char, connect_object: *mut gobject_sys::GObject, flags: gobject_sys::GConnectFlags, user_data: glib_sys::gpointer)
+ where
+ P: FnMut(&Builder, &str) -> F,
+ F: Fn(&[glib::Value]) -> Option<glib::Value> + Send + Sync + 'static,
+ {
let builder = from_glib_borrow(builder);
let object: glib::Object = from_glib_borrow(object);
let signal_name: GString = from_glib_borrow(signal_name);
@@ -57,7 +69,8 @@ impl<O: IsA<Builder>> BuilderExtManual for O {
object.connect(signal_name.as_str(), flags & gobject_sys::G_CONNECT_AFTER != 0, func);
// TODO: signal id
}
- let func = Some(func_func::<P> as _);
+
+ let func = Some(func_func::<P, F> as _);
let super_callback0: &P = &func_data;
unsafe {
gtk_sys::gtk_builder_connect_signals_full(self.as_ref().to_glib_none().0, func, super_callback0 as *const _ as usize as *mut _);
