feat(handler): remove custom event handlers

This commit is contained in:
doryan 2024-08-09 15:07:32 +04:00
parent cbde9a8af1
commit 56357c4697
3 changed files with 0 additions and 46 deletions

View File

@ -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));
}
}

View File

@ -1,2 +0,0 @@
pub mod button_event_handlers;
pub mod switch_event_handlers;

View File

@ -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));
}
}