refactor!(ccs): Improvements to design

This commit is contained in:
Michael Aaron Murphy 2022-01-26 11:30:58 +01:00
parent 148ffc6dae
commit dff9265e35
No known key found for this signature in database
GPG key ID: B2732D4240C9212C
7 changed files with 157 additions and 128 deletions

View file

@ -10,7 +10,7 @@ use gtk4::prelude::*;
use tokio::sync::mpsc;
pub use self::app_runner::AppRunner;
pub use self::component::Component;
pub use self::component::{Component, ComponentInner};
pub use self::handle::{Handle, Registered};
pub use gtk4 as gtk;
pub use relm4_macros::view;
@ -23,12 +23,14 @@ pub trait Widget<W> {
fn widget(&self) -> &W;
}
/// Convenience function for `Component::register()`.
pub fn register<C: Component>(
model: C,
args: C::InitialArgs,
) -> Registered<C::RootWidget, C::Input, C::Output> {
model.register(args)
pub trait CosmicWidgetExt<W>: Widget<W>
where
W: AsRef<gtk::Widget>,
{
fn attach_size_group(&self, sg: &gtk::SizeGroup) -> &Self {
sg.add_widget(self.widget().as_ref());
self
}
}
/// Convenience function for forwarding events from a receiver to different sender.