AIT/src/controller/event_handlers/switch_event_handlers.rs

26 lines
588 B
Rust
Raw Normal View History

2024-03-10 11:54:32 +03:00
use crate::{
model::model::*,
view::components::switch::SwitchExt,
gtk::{
*,
prelude::*
},
};
2024-03-10 11:54:32 +03:00
pub trait SwEventHandler{
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{
fn on_toggle(self) -> () {
self.component.connect_state_notify(move |switch| {
(self.callback)(switch)
});
}
2024-03-10 11:54:32 +03:00
}
2024-03-10 11:54:32 +03:00
pub fn clearing(output : &TextView, input: &TextView){
input.buffer().set_text("");
output.buffer().set_text("");
}