diff options
Diffstat (limited to 'src/gui/app.rs')
-rw-r--r-- | src/gui/app.rs | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/gui/app.rs b/src/gui/app.rs index 8cd7096..4ed864b 100644 --- a/src/gui/app.rs +++ b/src/gui/app.rs @@ -10,18 +10,23 @@ use std::rc::Rc; use crate::gui::calendar; use crate::gui::update::Msg; -use crate::{db, model::event::Event}; +use crate::{db, model::category::Category, model::event::Event}; pub struct App { pub conn: Rc<Connection>, pub window: Rc<gtk::ApplicationWindow>, - pub grid: gtk::Grid, + pub tx: Sender<Msg>, + // Calendar + pub calendar: gtk::Grid, pub events: Vec<Event>, // TODO: use Hashmap to have fast access to events by id ? pub recurring_events: Vec<Event>, // TODO: use Hashmap to have fast access to events by id ? pub today: NaiveDate, pub start_date: NaiveDate, pub end_date: NaiveDate, - pub tx: Sender<Msg>, + // Categories + // pub categories: gtk::Box, + pub categories: Vec<Category>, + pub default_color: String, } impl App { @@ -29,7 +34,7 @@ impl App { let window = Rc::new( gtk::ApplicationWindow::builder() .application(app) - .title("Calendar") + .title("Calendrier") .default_width(800) .default_height(600) .visible(true) @@ -41,19 +46,32 @@ impl App { NaiveDate::from_isoywd(today.year(), today.iso_week().week(), Weekday::Mon); let end_date = start_date + Duration::days(7 * 4 - 1); - let events = db::list_non_recurring_between(&conn, start_date, end_date)?; - let recurring_events = db::list_recurring(&conn)?; + let events = db::events::list_non_recurring_between(&conn, start_date, end_date)?; + let recurring_events = db::events::list_recurring(&conn)?; + let categories = db::categories::list(&conn)?; + let default_color = db::event_color::get_default_color(&conn)?; - let grid = calendar::create( + let calendar = calendar::create( tx.clone(), today, start_date, end_date, &events, &recurring_events, + &categories, + &default_color, ); - window.set_child(Some(&grid)); + // let categories = gtk::Box::builder() + // .orientation(gtk::Orientation::Vertical) + // .build(); + + // let notebook = gtk::Notebook::builder().build(); + // notebook.append_page(&calendar, Some(>k::Label::new(Some("Calendrier")))); + // notebook.append_page(&categories, Some(>k::Label::new(Some("Catégories")))); + // window.set_child(Some(¬ebook)); + + window.set_child(Some(&calendar)); window.connect_close_request(move |window| { if let Some(application) = window.application() { @@ -65,13 +83,15 @@ impl App { Ok(Self { conn, window, - grid, + tx, + calendar, events, recurring_events, today, start_date, end_date, - tx, + categories, + default_color, }) } } |