REFACTOR: clean code and some bug fixed

This commit is contained in:
2024-04-16 21:45:31 +04:00
parent 48057646a8
commit a58110a3f8
5 changed files with 93 additions and 112 deletions

View File

@@ -1,26 +1,16 @@
use crate::{
model::model::*,
view::components::switch::SwitchExt,
gtk::{
*,
prelude::*
},
};
use crate::{gtk::prelude::*, model::model::*, view::components::switch::SwitchExt};
pub trait SwEventHandler{
pub trait SwEventHandler {
fn on_toggle(self) -> ();
}
impl<F, C> SwEventHandler for EventHandler<F, C>
where F: Fn(&C) + FnOnce(&C) + FnMut(&C) + 'static, C: SwitchExt + WidgetExt{
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)
});
self.component
.connect_state_notify(move |switch| (self.callback)(switch));
}
}
pub fn clearing(output : &TextView, input: &TextView){
input.buffer().set_text("");
output.buffer().set_text("");
}