gtk: Add new Callback struct
@@ -2,6 +2,7 @@ use gtk_sys;
use glib::translate::*;
use glib_sys::gboolean;
+use glib_sys::gpointer;
use glib::subclass::prelude::*;
@@ -240,3 +241,16 @@ unsafe extern "C" fn container_forall<T: ObjectSubclass, P: FnMut(&Widget)>(
imp.forall(&wrap, include_internals, callback)
}
+
+pub struct Callback {
+ cb: gtk_sys::GtkCallback,
+ user_data: gpointer,
+}
+
+impl Callback {
+ pub fn call(&self, widget: &Widget) {
+ unsafe {
+ self.cb(widget.to_glib_none().0, self.user_data);
+ }
+ }
+}
