diff options
Diffstat (limited to 'src/app/calendar.rs')
-rw-r--r-- | src/app/calendar.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/app/calendar.rs b/src/app/calendar.rs index 250101f..fa4ebe6 100644 --- a/src/app/calendar.rs +++ b/src/app/calendar.rs @@ -87,7 +87,7 @@ pub fn day_entry( vbox.add_css_class("g-Calendar__Day"); let gesture = gtk::GestureClick::new(); - gesture.connect_pressed(glib::clone!(@strong date => move |_, n, _, _| { + gesture.connect_pressed(glib::clone!(@strong date, @strong tx => move |_, n, _, _| { if n == 2 { update::send(tx.clone(), Msg::ShowAddForm { date }); } @@ -107,7 +107,7 @@ pub fn day_entry( events.sort_by_key(|e| e.start); if !events.is_empty() { - vbox.append(&day_events(events)); + vbox.append(&day_events(tx, events)); } let scrolled_window = gtk::ScrolledWindow::builder() @@ -135,7 +135,7 @@ fn day_label(date: &NaiveDate) -> gtk::Label { label } -fn day_events(events: Vec<&Event>) -> gtk::Box { +fn day_events(tx: Sender<Msg>, events: Vec<&Event>) -> gtk::Box { let vbox = gtk::Box::builder() .orientation(gtk::Orientation::Vertical) .build(); @@ -147,11 +147,14 @@ fn day_events(events: Vec<&Event>) -> gtk::Box { .build(); let gesture = gtk::GestureClick::new(); - let click_event = event.clone(); - gesture.connect_pressed(move |gesture, _, _, _| { - gesture.set_state(gtk::EventSequenceState::Claimed); - println!("Click: {:?}", click_event); - }); + gesture.connect_pressed( + glib::clone!(@strong event, @strong tx => move |gesture, n, _, _| { + gesture.set_state(gtk::EventSequenceState::Claimed); + if n == 2 { + update::send(tx.clone(), Msg::ShowUpdateForm { event: event.clone() }); + } + }), + ); hbox.add_controller(&gesture); hbox.add_css_class("g-Calendar__DayEvent"); |