gtk: don't require LayoutChildType when subclassing LayoutManager
it's only required if the child widget used implements a LayoutChild
@@ -29,7 +29,10 @@ pub trait LayoutManagerImpl: LayoutManagerImplExt + ObjectImpl {
self.parent_create_layout_child(layout_manager, widget, for_child)
}
- fn layout_child_type() -> glib::Type;
+ /// Only set if the child implemented LayoutChildImpl
+ fn layout_child_type() -> Option<glib::Type> {
+ None
+ }
fn request_mode(&self, layout_manager: &Self::Type, widget: &Widget) -> SizeRequestMode {
self.parent_request_mode(layout_manager, widget)
@@ -222,7 +225,9 @@ unsafe impl<T: LayoutManagerImpl> IsSubclassable<T> for LayoutManager {
let klass = class.as_mut();
klass.allocate = Some(layout_manager_allocate::<T>);
klass.create_layout_child = Some(layout_manager_create_layout_child::<T>);
- klass.layout_child_type = T::layout_child_type().to_glib();
+ if let Some(type_) = T::layout_child_type() {
+ klass.layout_child_type = type_.to_glib();
+ }
klass.get_request_mode = Some(layout_manager_get_request_mode::<T>);
klass.measure = Some(layout_manager_measure::<T>);
klass.root = Some(layout_manager_root::<T>);
