gtk: Subclassing: Start implementing missing forall func for Gtk.Container
@@ -35,6 +35,10 @@ pub trait ContainerImpl: ContainerImplExt + WidgetImpl {
fn get_path_for_child(&self, container: &Container, widget: &Widget) -> WidgetPath {
self.parent_get_path_for_child(container, widget)
}
+
+ fn forall<P: FnMut(&Widget)>(&self, container: &Container, callback: P) {
+ self.parent_forall(container, callback);
+ }
}
pub trait ContainerImplExt {
@@ -44,6 +48,7 @@ pub trait ContainerImplExt {
fn parent_set_focus_child(&self, container: &Container, widget: Option<&Widget>);
fn parent_child_type(&self, container: &Container) -> glib::Type;
fn parent_get_path_for_child(&self, container: &Container, widget: &Widget) -> WidgetPath;
+ fn parent_forall<P: FnMut(&Widget)>(&self, container: &Container, callback: P);
}
impl<T: ContainerImpl> ContainerImplExt for T {
@@ -109,6 +114,16 @@ impl<T: ContainerImpl> ContainerImplExt for T {
from_glib_none(f(container.to_glib_none().0, widget.to_glib_none().0))
}
}
+
+ fn parent_forall<P: FnMut(&Widget)>(&self, container: &Container, callback: P) {
+ unsafe {
+ let data = self.get_type_data();
+ let parent_class = data.as_ref().get_parent_class() as *mut gtk_sys::GtkContainerClass;
+ if let Some(f) = (*parent_class).forall {
+ f(container.to_glib_none().0, false, callback.to_glib_none().0)
+ }
+ }
+ }
}
unsafe impl<T: ContainerImpl> IsSubclassable<T> for ContainerClass {
@@ -191,3 +206,17 @@ unsafe extern "C" fn container_get_path_for_child<T: ContainerImpl>(
imp.get_path_for_child(&wrap, &widget).to_glib_none().0
}
+
+unsafe extern "C" fn container_forall<T: ObjectSubclass, P: FnMut(&Widget)>(
+ ptr: *mut gtk_sys::GtkContainer,
+ callback: P
+)
+where
+ T: ContainerImpl,
+{
+ let instance = &*(ptr as *mut T::Instance);
+ let imp = instance.get_impl();
+ let wrap: Borrowed<Container> = from_glib_borrow(ptr);
+
+ imp.forall(&wrap, callback)
+}
