Compare commits
No commits in common. "ab97e14ad76fe5ffe89ed526c6be411ddabc71a3" and "5e2b7fbc9989c09f6bee7ba759022d4e6d01c54b" have entirely different histories.
ab97e14ad7
...
5e2b7fbc99
|
@ -8,13 +8,14 @@ use gtk::prelude::*;
|
||||||
pub struct ApplicationWindow {
|
pub struct ApplicationWindow {
|
||||||
pub window: gtk::ApplicationWindow,
|
pub window: gtk::ApplicationWindow,
|
||||||
pub date_label: Date,
|
pub date_label: Date,
|
||||||
pub next_event: gtk::Label,
|
|
||||||
pub transit_clock: TransitClock,
|
pub transit_clock: TransitClock,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ApplicationWindow {
|
impl ApplicationWindow {
|
||||||
pub fn new(app: >k::Application) -> Self {
|
pub fn new(app: >k::Application) -> Self {
|
||||||
let window = gtk::ApplicationWindow::new(app);
|
let window = gtk::ApplicationWindow::new(app);
|
||||||
|
let date_label = Date::new();
|
||||||
|
let transit_clock = TransitClock::new();
|
||||||
|
|
||||||
let layout = gtk::Box::builder()
|
let layout = gtk::Box::builder()
|
||||||
.orientation(gtk::Orientation::Vertical)
|
.orientation(gtk::Orientation::Vertical)
|
||||||
|
@ -22,20 +23,7 @@ impl ApplicationWindow {
|
||||||
.vexpand(true)
|
.vexpand(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let date_label = Date::new();
|
|
||||||
layout.append(&date_label);
|
layout.append(&date_label);
|
||||||
|
|
||||||
let next_event = gtk::Label::builder()
|
|
||||||
.margin_bottom(8)
|
|
||||||
.margin_top(8)
|
|
||||||
.margin_start(8)
|
|
||||||
.margin_end(8)
|
|
||||||
.build();
|
|
||||||
next_event.add_css_class("card");
|
|
||||||
next_event.add_css_class("activatable");
|
|
||||||
layout.append(&next_event);
|
|
||||||
|
|
||||||
let transit_clock = TransitClock::new();
|
|
||||||
layout.append(&transit_clock);
|
layout.append(&transit_clock);
|
||||||
|
|
||||||
window.set_child(Some(&layout));
|
window.set_child(Some(&layout));
|
||||||
|
@ -43,14 +31,12 @@ impl ApplicationWindow {
|
||||||
Self {
|
Self {
|
||||||
window,
|
window,
|
||||||
date_label,
|
date_label,
|
||||||
next_event,
|
|
||||||
transit_clock,
|
transit_clock,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_state(&self, state: State) {
|
pub fn update_state(&self, state: State) {
|
||||||
self.date_label.update_date(state.date);
|
self.date_label.update_date(state.date);
|
||||||
self.next_event.set_text(&format!("{:?}", state.next_event));
|
|
||||||
if let Some(transit) = state.transit {
|
if let Some(transit) = state.transit {
|
||||||
self.transit_clock.update_transit(transit);
|
self.transit_clock.update_transit(transit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,16 @@ impl PieChart {
|
||||||
end_angle,
|
end_angle,
|
||||||
color,
|
color,
|
||||||
}| {
|
}| {
|
||||||
|
println!(
|
||||||
|
"wedge: {:.02?} {:.02?} {:.02?}",
|
||||||
|
start_angle, end_angle, color
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
"wedge: {:.02?} {:.02?} [{:.02?}]",
|
||||||
|
start_angle + self.rotation,
|
||||||
|
end_angle + self.rotation,
|
||||||
|
self.rotation
|
||||||
|
);
|
||||||
context.move_to(self.center_x, self.center_y);
|
context.move_to(self.center_x, self.center_y);
|
||||||
context.set_source_rgb(color.r, color.g, color.b);
|
context.set_source_rgb(color.r, color.g, color.b);
|
||||||
context.arc(
|
context.arc(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use chrono::{Datelike, Local, Utc};
|
use chrono::{Datelike, Local};
|
||||||
use geo_types::{Latitude, Longitude};
|
use geo_types::{Latitude, Longitude};
|
||||||
use glib::Sender;
|
use glib::Sender;
|
||||||
use gtk::prelude::*;
|
use gtk::{prelude::*, subclass::prelude::*, Orientation};
|
||||||
use ifc::IFC;
|
use ifc::IFC;
|
||||||
use std::{
|
use std::{
|
||||||
env,
|
env,
|
||||||
|
@ -12,11 +12,12 @@ mod app_window;
|
||||||
use app_window::ApplicationWindow;
|
use app_window::ApplicationWindow;
|
||||||
|
|
||||||
mod components;
|
mod components;
|
||||||
|
use components::{Date, TransitClock};
|
||||||
|
|
||||||
mod drawing;
|
mod drawing;
|
||||||
|
|
||||||
mod soluna_client;
|
mod soluna_client;
|
||||||
use soluna_client::SolunaClient;
|
use soluna_client::{SolunaClient, SunMoon};
|
||||||
|
|
||||||
mod solstices;
|
mod solstices;
|
||||||
use solstices::EVENTS;
|
use solstices::EVENTS;
|
||||||
|
@ -98,10 +99,8 @@ pub fn main() {
|
||||||
.request(latitude, longitude, Local::now())
|
.request(latitude, longitude, Local::now())
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let now = Local::now();
|
|
||||||
let state = State {
|
let state = State {
|
||||||
date: IFC::from(now.date_naive().with_year(12023).unwrap()),
|
date: IFC::from(Local::now().date_naive().with_year(12023).unwrap()),
|
||||||
next_event: EVENTS.next_event(now.with_timezone(&Utc)).unwrap(),
|
|
||||||
transit: Some(transit),
|
transit: Some(transit),
|
||||||
};
|
};
|
||||||
loop {
|
loop {
|
||||||
|
|
|
@ -133,11 +133,9 @@ fn parse_events() -> Vec<Option<YearlyEvents>> {
|
||||||
pub struct Solstices(HashMap<i32, YearlyEvents>);
|
pub struct Solstices(HashMap<i32, YearlyEvents>);
|
||||||
|
|
||||||
impl Solstices {
|
impl Solstices {
|
||||||
/*
|
|
||||||
pub fn acquire(&self, year: i32) -> Option<YearlyEvents> {
|
pub fn acquire(&self, year: i32) -> Option<YearlyEvents> {
|
||||||
self.0.get(&year).map(|c| c.clone())
|
self.0.get(&year).map(|c| c.clone())
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
pub fn next_event(&self, date: chrono::DateTime<chrono::Utc>) -> Option<Event> {
|
pub fn next_event(&self, date: chrono::DateTime<chrono::Utc>) -> Option<Event> {
|
||||||
let year_events = self.0.get(&date.year());
|
let year_events = self.0.get(&date.year());
|
||||||
|
@ -154,7 +152,7 @@ impl Solstices {
|
||||||
} else {
|
} else {
|
||||||
self.0
|
self.0
|
||||||
.get(&(date.year() + 1))
|
.get(&(date.year() + 1))
|
||||||
.map(|_| Event::SpringEquinox(year_events.spring_equinox.clone()))
|
.map(|events| Event::SpringEquinox(year_events.spring_equinox.clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => None,
|
None => None,
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use crate::{solstices::Event, soluna_client::SunMoon};
|
use crate::soluna_client::SunMoon;
|
||||||
use ifc::IFC;
|
use ifc::IFC;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct State {
|
pub struct State {
|
||||||
pub date: IFC,
|
pub date: IFC,
|
||||||
pub next_event: Event,
|
|
||||||
pub transit: Option<SunMoon>,
|
pub transit: Option<SunMoon>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue