Shutdown properly when the main window closes

This commit is contained in:
Savanni D'Gerinel 2023-08-10 13:14:45 -04:00
parent b2ca3d195d
commit c76396a010
2 changed files with 6 additions and 21 deletions

View File

@ -43,16 +43,6 @@ impl ApplicationWindow {
let date_label = Date::new(); 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();
layout.append(&next_event);
*/
let events = Events::new(); let events = Events::new();
layout.append(&events); layout.append(&events);
@ -75,8 +65,6 @@ impl ApplicationWindow {
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)); */
self.events.set_events(state.events, state.next_event); self.events.set_events(state.events, state.next_event);
if let Some(transit) = state.transit { if let Some(transit) = state.transit {
self.transit_card.update_transit(&transit); self.transit_card.update_transit(&transit);

View File

@ -81,18 +81,16 @@ pub fn main() {
let latitude = Latitude::from(41.78); let latitude = Latitude::from(41.78);
let longitude = Longitude::from(-71.41); let longitude = Longitude::from(-71.41);
let runtime = Arc::new( let runtime = tokio::runtime::Builder::new_multi_thread()
tokio::runtime::Builder::new_multi_thread()
.enable_all() .enable_all()
.build() .build()
.unwrap(), .unwrap();
);
let core = Core { let core = Core {
tx: Arc::new(RwLock::new(None)), tx: Arc::new(RwLock::new(None)),
}; };
let app_handle = runtime.spawn({ let _ = runtime.spawn({
let core = core.clone(); let core = core.clone();
async move { async move {
let soluna_client = SolunaClient::new(); let soluna_client = SolunaClient::new();
@ -142,6 +140,5 @@ pub fn main() {
let args: Vec<String> = env::args().collect(); let args: Vec<String> = env::args().collect();
ApplicationExtManual::run_with_args(&app, &args); ApplicationExtManual::run_with_args(&app, &args);
runtime.shutdown_background();
let _ = runtime.block_on(async { app_handle.await });
} }