AIT/src/controller/event_handlers/switch_event_handlers.rs

17 lines
418 B
Rust
Raw Normal View History

use crate::{gtk::prelude::*, model::model::*, view::components::switch::SwitchExt};
pub trait SwEventHandler {
2024-03-10 11:54:32 +03:00
fn on_toggle(self) -> ();
}
2024-03-10 11:54:32 +03:00
impl<F, C> SwEventHandler for EventHandler<F, C>
where
F: Fn(&C) + FnOnce(&C) + FnMut(&C) + 'static,
C: SwitchExt + WidgetExt,
{
2024-03-10 11:54:32 +03:00
fn on_toggle(self) -> () {
self.component
.connect_state_notify(move |switch| (self.callback)(switch));
}
2024-03-10 11:54:32 +03:00
}