diff options
Diffstat (limited to 'src/gui/calendar.rs')
-rw-r--r-- | src/gui/calendar.rs | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/gui/calendar.rs b/src/gui/calendar.rs index 3f5b6a7..cad2465 100644 --- a/src/gui/calendar.rs +++ b/src/gui/calendar.rs @@ -19,7 +19,7 @@ pub fn create( start_date: NaiveDate, end_date: NaiveDate, events: &[Event], - repeated_events: &[Event], + recurring_events: &[Event], ) -> gtk::Grid { let grid = gtk::Grid::builder().build(); @@ -27,7 +27,7 @@ pub fn create( grid.attach(&day_title(col), col, 0, 1, 1); } - let repetitions = event::repetitions_between(repeated_events, start_date, end_date); + let repetitions = event::repetitions_between(recurring_events, start_date, end_date); attach_days(tx.clone(), &grid, start_date, today, events, &repetitions); let event_controller_key = gtk::EventControllerKey::new(); @@ -126,12 +126,12 @@ pub fn day_entry( .iter() .filter(|e| e.date == date) .collect::<Vec<&Event>>(); - let repeated_events = repetitions.get(&date).cloned().unwrap_or_default(); - events.extend(repeated_events.iter()); + let recurring_events = repetitions.get(&date).cloned().unwrap_or_default(); + events.extend(recurring_events.iter()); events.sort_by_key(|e| e.start); if !events.is_empty() { - vbox.append(&day_events(tx, events)); + vbox.append(&day_events(date, tx, events)); } gtk::ScrolledWindow::builder() @@ -147,18 +147,24 @@ fn day_label(today: NaiveDate, date: NaiveDate) -> gtk::Label { .label(&format!( "{} {}", date.day(), - if date == today || date.day() == 1 { MONTHES[date.month0() as usize] } else { "" } + if date == today || date.day() == 1 { + MONTHES[date.month0() as usize] + } else { + "" + } )) .halign(gtk::Align::Start) .build(); label.add_css_class("g-Calendar__DayNumber"); - if date.day() == 1 { label.add_css_class("g-Calendar__DayNumber--FirstOfMonth") } + if date.day() == 1 { + label.add_css_class("g-Calendar__DayNumber--FirstOfMonth") + } label } -fn day_events(tx: Sender<Msg>, events: Vec<&Event>) -> gtk::Box { +fn day_events(date: NaiveDate, tx: Sender<Msg>, events: Vec<&Event>) -> gtk::Box { let vbox = gtk::Box::builder() .orientation(gtk::Orientation::Vertical) .build(); @@ -174,7 +180,11 @@ fn day_events(tx: Sender<Msg>, events: Vec<&Event>) -> gtk::Box { 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() }); + if event.repetition.is_some() { + update::send(tx.clone(), Msg::ShowRepetitionDialog { date, event: event.clone() }); + } else { + update::send(tx.clone(), Msg::ShowUpdateForm { event: event.clone() }); + } } }), ); |