From 23d15a305d1ac0b4ae7ce49506c4337435504b7b Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Mon, 23 Sep 2024 22:59:30 -0400 Subject: [PATCH] Set up a header bar --- dashboard/src/app_window.rs | 5 ++++- dashboard/src/components/date.rs | 2 +- dashboard/src/main.rs | 15 --------------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/dashboard/src/app_window.rs b/dashboard/src/app_window.rs index 482352a..2c19600 100644 --- a/dashboard/src/app_window.rs +++ b/dashboard/src/app_window.rs @@ -41,7 +41,10 @@ impl ApplicationWindow { .build(); let date_label = Date::default(); - layout.append(&date_label); + let header = adw::HeaderBar::builder() + .title_widget(&date_label) + .build(); + layout.append(&header); let events = Events::default(); layout.append(&events); diff --git a/dashboard/src/components/date.rs b/dashboard/src/components/date.rs index dc1c79f..4e3c5ec 100644 --- a/dashboard/src/components/date.rs +++ b/dashboard/src/components/date.rs @@ -56,7 +56,7 @@ impl Date { } fn redraw(&self) { - let date = self.imp().date.borrow().clone(); + let date = self.imp().date.borrow(); self.imp() .label .borrow_mut() diff --git a/dashboard/src/main.rs b/dashboard/src/main.rs index b2cfa88..4f911ad 100644 --- a/dashboard/src/main.rs +++ b/dashboard/src/main.rs @@ -111,7 +111,6 @@ pub fn main() { let gtk_tx = core.tx.read().unwrap().clone(); if let Some(gtk_tx) = gtk_tx { - println!("sending message"); let state = state.clone(); let _ = gtk_tx.send(Message::Refresh(state)).await; std::thread::sleep(std::time::Duration::from_secs(60)); @@ -124,7 +123,6 @@ pub fn main() { app.connect_activate(move |app| { let (gtk_tx, gtk_rx) = async_std::channel::unbounded(); - // gtk::glib::MainContext::channel::(gtk::glib::Priority::DEFAULT); *core.tx.write().unwrap() = Some(gtk_tx); @@ -133,23 +131,10 @@ pub fn main() { glib::spawn_future_local(async move { loop { - println!("spawn_future_local"); let Message::Refresh(state) = gtk_rx.recv().await.unwrap(); - println!("Message::Refresh"); 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 - } - }); - */ }); let args: Vec = env::args().collect();