aboutsummaryrefslogtreecommitdiff
path: root/src/app/app.rs
diff options
context:
space:
mode:
authorJoris2022-02-26 18:57:55 +0100
committerJoris2022-02-26 18:57:55 +0100
commitf9f49285c5ecc76d3edfb0a54ffab53c2e296d7f (patch)
treef77f9b625446de7f0b9de1553fc52d702c4cbc69 /src/app/app.rs
parent2d80413609130f1c121dcae39a150a27dd9f02ea (diff)
downloadcalendar-f9f49285c5ecc76d3edfb0a54ffab53c2e296d7f.tar.gz
calendar-f9f49285c5ecc76d3edfb0a54ffab53c2e296d7f.tar.bz2
calendar-f9f49285c5ecc76d3edfb0a54ffab53c2e296d7f.zip
Apply linter advices
Diffstat (limited to 'src/app/app.rs')
-rw-r--r--src/app/app.rs76
1 files changed, 0 insertions, 76 deletions
diff --git a/src/app/app.rs b/src/app/app.rs
deleted file mode 100644
index 58240af..0000000
--- a/src/app/app.rs
+++ /dev/null
@@ -1,76 +0,0 @@
-use gtk4 as gtk;
-
-use async_channel::Sender;
-use chrono::{Datelike, Duration, NaiveDate, Weekday};
-use gtk::glib::signal::Inhibit;
-use gtk::prelude::*;
-use rusqlite::Connection;
-use std::rc::Rc;
-
-use crate::app::calendar;
-use crate::app::update::Msg;
-use crate::{db, model::event::Event};
-
-pub struct App {
- pub conn: Rc<Connection>,
- pub window: Rc<gtk::ApplicationWindow>,
- pub grid: gtk::Grid,
- pub events: Vec<Event>,
- pub repeated_events: Vec<Event>,
- pub today: NaiveDate,
- pub start_date: NaiveDate,
- pub end_date: NaiveDate,
- pub tx: Sender<Msg>,
-}
-
-impl App {
- pub fn new(conn: Rc<Connection>, app: &gtk::Application, tx: Sender<Msg>) -> Self {
- let window = Rc::new(
- gtk::ApplicationWindow::builder()
- .application(app)
- .title("Calendar")
- .default_width(800)
- .default_height(600)
- .visible(true)
- .build(),
- );
-
- let today = chrono::offset::Local::today().naive_utc();
- let start_date =
- 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_repeated_between(&conn, start_date, end_date).unwrap_or(vec![]);
- let repeated_events = db::list_repeated(&conn).unwrap_or(vec![]);
-
- let grid = calendar::create(
- tx.clone(),
- today,
- start_date,
- end_date,
- &events,
- &repeated_events,
- );
-
- window.set_child(Some(&grid));
-
- window.connect_close_request(move |window| {
- if let Some(application) = window.application() {
- application.remove_window(window);
- }
- Inhibit(false)
- });
-
- Self {
- conn,
- window,
- grid,
- events,
- repeated_events,
- today,
- start_date,
- end_date,
- tx,
- }
- }
-}