feat(handler): remove custom event handlers
This commit is contained in:
parent
cbde9a8af1
commit
56357c4697
|
@ -1,28 +0,0 @@
|
|||
use crate::{gtk::prelude::*, model::models::*};
|
||||
|
||||
impl<F, C> EventHandler<F, C>
|
||||
where
|
||||
F: Fn(&C) + FnOnce(&C) + FnMut(&C),
|
||||
{
|
||||
pub fn new(component: C, callback: F) -> Self {
|
||||
Self {
|
||||
component,
|
||||
callback,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BtnEventHandler {
|
||||
fn on_click(self);
|
||||
}
|
||||
|
||||
impl<F, C> BtnEventHandler for EventHandler<F, C>
|
||||
where
|
||||
F: Fn(&C) + FnOnce(&C) + FnMut(&C) + 'static,
|
||||
C: ButtonExt + WidgetExt,
|
||||
{
|
||||
fn on_click(self) {
|
||||
self.component
|
||||
.connect_clicked(move |button| (self.callback)(button));
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
pub mod button_event_handlers;
|
||||
pub mod switch_event_handlers;
|
|
@ -1,16 +0,0 @@
|
|||
use crate::{gtk::prelude::*, model::models::*, view::components::switch::SwitchExt};
|
||||
|
||||
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,
|
||||
{
|
||||
fn on_toggle(self) {
|
||||
self.component
|
||||
.connect_state_notify(move |switch| (self.callback)(switch));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue