aboutsummaryrefslogtreecommitdiff
path: root/src/app/calendar.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/calendar.rs')
-rw-r--r--src/app/calendar.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/app/calendar.rs b/src/app/calendar.rs
index 847ea71..250101f 100644
--- a/src/app/calendar.rs
+++ b/src/app/calendar.rs
@@ -5,14 +5,14 @@ use chrono::{Datelike, NaiveDate};
use gtk::glib;
use gtk::prelude::*;
-use crate::{app::update, app::update::Msg, model::event::Event};
+use crate::{app::update, app::update::Msg, app::App, model::event::Event};
static DAYS: [&str; 7] = ["LUN", "MAR", "MER", "JEU", "VEN", "SAM", "DIM"];
static MONTHES: [&str; 12] = [
"Jan", "Fév", "Mar", "Avr", "Mai", "Juin", "Juil", "Aoû", "Sep", "Oct", "Nov", "Déc",
];
-pub fn grid(
+pub fn create(
tx: Sender<Msg>,
today: &NaiveDate,
start_date: &NaiveDate,
@@ -24,12 +24,12 @@ pub fn grid(
grid.attach(&day_title(col), col, 0, 1, 1);
}
- show_days(tx, &grid, &start_date, &today, &events);
+ attach_days(tx, &grid, &start_date, &today, &events);
grid
}
-fn show_days(
+fn attach_days(
tx: Sender<Msg>,
grid: &gtk::Grid,
start_date: &NaiveDate,
@@ -45,6 +45,21 @@ fn show_days(
}
}
+pub fn refresh_date(app: &App, date: NaiveDate) {
+ let d = date.signed_duration_since(app.start_date).num_days();
+
+ let col = (d % 7) as i32;
+ let row = 1 + (d / 7) as i32;
+
+ app.grid.attach(
+ &day_entry(app.tx.clone(), &date, &app.today, &app.events),
+ col,
+ row,
+ 1,
+ 1,
+ )
+}
+
fn day_title(col: i32) -> gtk::Box {
let vbox = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical)