use gtk::{self, IsA, Object};
use super::{DisplayVariant, Relm, RemoteRelm, run};
pub trait Widget
where Self: Clone,
Self::Root: Clone + IsA<gtk::Widget>,
Self::Msg: Clone + DisplayVariant,
{
type Model;
type ModelParam: Sized;
type Msg;
type Root;
fn init_view(&self) {
}
fn model(param: Self::ModelParam) -> Self::Model;
fn on_add<W: IsA<gtk::Widget> + IsA<Object>>(&self, _parent: W) {
}
fn root(&self) -> &Self::Root;
fn run(model_param: Self::ModelParam) -> Result<(), ()>
where Self: 'static,
Self::Model: Clone + Send,
Self::ModelParam: Default,
Self::Msg: Send,
{
run::<Self>(model_param)
}
fn subscriptions(_relm: &Relm<Self::Msg>) {
}
fn update(&mut self, event: Self::Msg, model: &mut Self::Model);
fn update_command(_relm: &Relm<Self::Msg>, _event: Self::Msg, _model: &mut Self::Model) {
}
fn view(relm: &RemoteRelm<Self>, model: &Self::Model) -> Self;
}