Compare commits

..

No commits in common. "14ad4f0888f0c77c1c07e3ec588e000a1e8d5444" and "6cae7dbb0ef3929b420a7266dc0c6739c231daa0" have entirely different histories.

8 changed files with 204 additions and 74 deletions

188
Cargo.lock generated
View File

@ -166,11 +166,11 @@ version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c"
dependencies = [
"async-lock",
"async-lock 3.3.0",
"async-task",
"concurrent-queue",
"fastrand",
"futures-lite",
"fastrand 2.0.1",
"futures-lite 2.2.0",
"slab",
]
@ -182,32 +182,61 @@ checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c"
dependencies = [
"async-channel 2.1.1",
"async-executor",
"async-io",
"async-lock",
"async-io 2.3.1",
"async-lock 3.3.0",
"blocking",
"futures-lite",
"futures-lite 2.2.0",
"once_cell",
]
[[package]]
name = "async-io"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af"
dependencies = [
"async-lock 2.8.0",
"autocfg 1.1.0",
"cfg-if",
"concurrent-queue",
"futures-lite 1.13.0",
"log 0.4.20",
"parking",
"polling 2.8.0",
"rustix 0.37.27",
"slab",
"socket2 0.4.10",
"waker-fn",
]
[[package]]
name = "async-io"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f97ab0c5b00a7cdbe5a371b9a782ee7be1316095885c8a4ea1daf490eb0ef65"
dependencies = [
"async-lock",
"async-lock 3.3.0",
"cfg-if",
"concurrent-queue",
"futures-io",
"futures-lite",
"futures-lite 2.2.0",
"parking",
"polling",
"rustix",
"polling 3.4.0",
"rustix 0.38.28",
"slab",
"tracing",
"windows-sys 0.52.0",
]
[[package]]
name = "async-lock"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b"
dependencies = [
"event-listener 2.5.3",
]
[[package]]
name = "async-lock"
version = "3.3.0"
@ -221,19 +250,19 @@ dependencies = [
[[package]]
name = "async-std"
version = "1.13.0"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c634475f29802fde2b8f0b505b1bd00dfe4df7d4a000f0b36f7671197d5c3615"
checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d"
dependencies = [
"async-channel 1.9.0",
"async-global-executor",
"async-io",
"async-lock",
"async-io 1.13.0",
"async-lock 2.8.0",
"crossbeam-utils",
"futures-channel",
"futures-core",
"futures-io",
"futures-lite",
"futures-lite 1.13.0",
"gloo-timers",
"kv-log-macro",
"log 0.4.20",
@ -464,11 +493,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118"
dependencies = [
"async-channel 2.1.1",
"async-lock",
"async-lock 3.3.0",
"async-task",
"fastrand",
"fastrand 2.0.1",
"futures-io",
"futures-lite",
"futures-lite 2.2.0",
"piper",
"tracing",
]
@ -925,9 +954,8 @@ dependencies = [
[[package]]
name = "dashboard"
version = "0.1.3"
version = "0.1.2"
dependencies = [
"async-std",
"cairo-rs",
"chrono",
"fluent",
@ -939,11 +967,13 @@ dependencies = [
"glib",
"glib-build-tools 0.18.0",
"gtk4",
"ifc",
"lazy_static",
"libadwaita",
"memorycache",
"reqwest",
"serde 1.0.209",
"serde_derive",
"serde_json",
"tokio",
"unic-langid",
@ -1189,6 +1219,15 @@ dependencies = [
"zune-inflate",
]
[[package]]
name = "fastrand"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
dependencies = [
"instant",
]
[[package]]
name = "fastrand"
version = "2.0.1"
@ -1515,13 +1554,28 @@ version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa"
[[package]]
name = "futures-lite"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce"
dependencies = [
"fastrand 1.9.0",
"futures-core",
"futures-io",
"memchr",
"parking",
"pin-project-lite",
"waker-fn",
]
[[package]]
name = "futures-lite"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba"
dependencies = [
"fastrand",
"fastrand 2.0.1",
"futures-core",
"futures-io",
"parking",
@ -1798,9 +1852,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "gloo-timers"
version = "0.3.0"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994"
checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c"
dependencies = [
"futures-channel",
"futures-core",
@ -2190,7 +2244,7 @@ dependencies = [
"httpdate",
"itoa",
"pin-project-lite",
"socket2",
"socket2 0.5.5",
"tokio",
"tower-service",
"tracing",
@ -2327,6 +2381,15 @@ dependencies = [
"hashbrown",
]
[[package]]
name = "instant"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [
"cfg-if",
]
[[package]]
name = "intl-memoizer"
version = "0.5.1"
@ -2346,6 +2409,17 @@ dependencies = [
"unic-langid",
]
[[package]]
name = "io-lifetimes"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
dependencies = [
"hermit-abi",
"libc",
"windows-sys 0.48.0",
]
[[package]]
name = "ipnet"
version = "2.9.0"
@ -2375,7 +2449,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [
"hermit-abi",
"rustix",
"rustix 0.38.28",
"windows-sys 0.48.0",
]
@ -2573,6 +2647,12 @@ version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286"
[[package]]
name = "linux-raw-sys"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
[[package]]
name = "linux-raw-sys"
version = "0.4.12"
@ -3266,7 +3346,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4"
dependencies = [
"atomic-waker",
"fastrand",
"fastrand 2.0.1",
"futures-io",
]
@ -3359,6 +3439,22 @@ dependencies = [
"miniz_oxide 0.7.1",
]
[[package]]
name = "polling"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce"
dependencies = [
"autocfg 1.1.0",
"bitflags 1.3.2",
"cfg-if",
"concurrent-queue",
"libc",
"log 0.4.20",
"pin-project-lite",
"windows-sys 0.48.0",
]
[[package]]
name = "polling"
version = "3.4.0"
@ -3368,7 +3464,7 @@ dependencies = [
"cfg-if",
"concurrent-queue",
"pin-project-lite",
"rustix",
"rustix 0.38.28",
"tracing",
"windows-sys 0.52.0",
]
@ -3901,6 +3997,20 @@ dependencies = [
"semver 1.0.20",
]
[[package]]
name = "rustix"
version = "0.37.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2"
dependencies = [
"bitflags 1.3.2",
"errno",
"io-lifetimes",
"libc",
"linux-raw-sys 0.3.8",
"windows-sys 0.48.0",
]
[[package]]
name = "rustix"
version = "0.38.28"
@ -3910,7 +4020,7 @@ dependencies = [
"bitflags 2.4.1",
"errno",
"libc",
"linux-raw-sys",
"linux-raw-sys 0.4.12",
"windows-sys 0.52.0",
]
@ -4205,6 +4315,16 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27207bb65232eda1f588cf46db2fee75c0808d557f6b3cf19a75f5d6d7c94df1"
[[package]]
name = "socket2"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "socket2"
version = "0.5.5"
@ -4555,9 +4675,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5"
dependencies = [
"cfg-if",
"fastrand",
"fastrand 2.0.1",
"redox_syscall",
"rustix",
"rustix 0.38.28",
"windows-sys 0.48.0",
]
@ -4697,7 +4817,7 @@ dependencies = [
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
"socket2",
"socket2 0.5.5",
"tokio-macros",
"windows-sys 0.52.0",
]
@ -5167,6 +5287,12 @@ dependencies = [
"libc",
]
[[package]]
name = "waker-fn"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690"
[[package]]
name = "want"
version = "0.3.1"

View File

@ -1,13 +1,12 @@
[package]
name = "dashboard"
version = "0.1.3"
version = "0.1.2"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
adw = { version = "0.5", package = "libadwaita", features = [ "v1_2" ] }
async-std = { version = "1.13" }
cairo-rs = { version = "0.18" }
chrono = { version = "0.4", features = ["serde"] }
fluent-ergonomics = { path = "../fluent-ergonomics/" }
@ -18,11 +17,13 @@ gio = { version = "0.18" }
glib = { version = "0.18" }
gdk = { version = "0.7", package = "gdk4" }
gtk = { version = "0.7", package = "gtk4" }
ifc = { path = "../ifc/" }
lazy_static = { version = "1.4" }
memorycache = { path = "../memorycache/" }
reqwest = { version = "0.11", features = ["json"] }
serde_derive = { version = "1" }
serde_json = { version = "1" }
serde = { version = "1", features = [ "derive" ] }
serde = { version = "1" }
tokio = { version = "1", features = ["full"] }
unic-langid = { version = "0.9" }

View File

@ -41,10 +41,7 @@ impl ApplicationWindow {
.build();
let date_label = Date::default();
let header = adw::HeaderBar::builder()
.title_widget(&date_label)
.build();
layout.append(&header);
layout.append(&date_label);
let events = Events::default();
layout.append(&events);

View File

@ -1,19 +1,21 @@
use std::{cell::RefCell, rc::Rc};
use chrono::NaiveDate;
use chrono::Datelike;
use glib::Object;
use gtk::{prelude::*, subclass::prelude::*};
use ifc::IFC;
use std::{cell::RefCell, rc::Rc};
pub struct DatePrivate {
date: Rc<RefCell<NaiveDate>>,
date: Rc<RefCell<IFC>>,
label: Rc<RefCell<gtk::Label>>,
}
impl Default for DatePrivate {
fn default() -> Self {
let date = chrono::Local::now().date_naive();
let year = date.year();
let date = date.with_year(year + 10000).unwrap();
Self {
date: Rc::new(RefCell::new(date)),
date: Rc::new(RefCell::new(IFC::from(date))),
label: Rc::new(RefCell::new(gtk::Label::new(None))),
}
}
@ -50,16 +52,19 @@ impl Default for Date {
}
impl Date {
pub fn update_date(&self, date: NaiveDate) {
pub fn update_date(&self, date: IFC) {
*self.imp().date.borrow_mut() = date;
self.redraw();
}
fn redraw(&self) {
let date = self.imp().date.borrow();
self.imp()
.label
.borrow_mut()
.set_text(&date.format("%Y %B %d").to_string());
let date = self.imp().date.borrow().clone();
self.imp().label.borrow_mut().set_text(&format!(
"{:?}, {:?} {}, {}",
date.weekday(),
date.month(),
date.day(),
date.year()
));
}
}

View File

@ -4,6 +4,7 @@ use crate::{
};
use glib::Object;
use gtk::{prelude::*, subclass::prelude::*};
use ifc::IFC;
/*
#[derive(PartialEq)]
@ -58,19 +59,19 @@ impl Events {
pub fn set_events(&self, events: YearlyEvents, next_event: solstices::Event) {
self.imp()
.spring_equinox
.update_date(events.spring_equinox.date_naive());
.update_date(IFC::from(events.spring_equinox.date_naive()));
self.imp()
.summer_solstice
.update_date(events.summer_solstice.date_naive());
.update_date(IFC::from(events.summer_solstice.date_naive()));
self.imp()
.autumn_equinox
.update_date(events.autumn_equinox.date_naive());
.update_date(IFC::from(events.autumn_equinox.date_naive()));
self.imp()
.winter_solstice
.update_date(events.winter_solstice.date_naive());
.update_date(IFC::from(events.winter_solstice.date_naive()));
self.imp().spring_equinox.remove_css_class("highlight");
self.imp().summer_solstice.remove_css_class("highlight");

View File

@ -1,13 +1,13 @@
use chrono::{Datelike, Local, Utc};
use geo_types::{Latitude, Longitude};
use glib::Sender;
use gtk::prelude::*;
use ifc::IFC;
use std::{
env,
sync::{Arc, RwLock},
};
use async_std::channel::Sender;
use chrono::{Datelike, Local, Utc};
use geo_types::{Latitude, Longitude};
use gtk::prelude::*;
mod app_window;
use app_window::ApplicationWindow;
@ -102,17 +102,14 @@ pub fn main() {
let now = Local::now();
let state = State {
date: now.date_naive(),
date: IFC::from(now.date_naive().with_year(now.year() + 10000).unwrap()),
next_event: EVENTS.next_event(now.with_timezone(&Utc)).unwrap(),
events: EVENTS.yearly_events(now.year()).unwrap(),
transit: Some(transit),
};
let gtk_tx = core.tx.read().unwrap().clone();
if let Some(gtk_tx) = gtk_tx {
let state = state.clone();
let _ = gtk_tx.send(Message::Refresh(state)).await;
if let Some(ref gtk_tx) = *core.tx.read().unwrap() {
let _ = gtk_tx.send(Message::Refresh(state.clone()));
std::thread::sleep(std::time::Duration::from_secs(60));
} else {
std::thread::sleep(std::time::Duration::from_secs(1));
@ -122,17 +119,21 @@ pub fn main() {
});
app.connect_activate(move |app| {
let (gtk_tx, gtk_rx) = async_std::channel::unbounded();
let (gtk_tx, gtk_rx) =
gtk::glib::MainContext::channel::<Message>(gtk::glib::Priority::DEFAULT);
*core.tx.write().unwrap() = Some(gtk_tx);
let window = ApplicationWindow::new(app);
window.window.present();
glib::spawn_future_local(async move {
loop {
let Message::Refresh(state) = gtk_rx.recv().await.unwrap();
window.update_state(state);
gtk_rx.attach(None, {
let window = window.clone();
move |msg| {
let Message::Refresh(state) = msg;
ApplicationWindow::update_state(&window, state);
glib::ControlFlow::Continue
}
});
});

View File

@ -1,8 +1,7 @@
use std::collections::HashMap;
use chrono::prelude::*;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use serde_derive::{Deserialize, Serialize};
use std::collections::HashMap;
// http://astropixels.com/ephemeris/soleq2001.html
const SOLSTICE_TEXT: &str = "

View File

@ -2,11 +2,11 @@ use crate::{
solstices::{Event, YearlyEvents},
soluna_client::SunMoon,
};
use chrono::NaiveDate;
use ifc::IFC;
#[derive(Clone, Debug)]
pub struct State {
pub date: NaiveDate,
pub date: IFC,
pub next_event: Event,
pub events: YearlyEvents,
pub transit: Option<SunMoon>,