Set up a header bar

This commit is contained in:
Savanni D'Gerinel 2024-09-23 22:59:30 -04:00 committed by savanni
parent caaf9c57c6
commit 95b46de7fc
3 changed files with 5 additions and 17 deletions

View File

@ -41,7 +41,10 @@ impl ApplicationWindow {
.build(); .build();
let date_label = Date::default(); 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(); let events = Events::default();
layout.append(&events); layout.append(&events);

View File

@ -56,7 +56,7 @@ impl Date {
} }
fn redraw(&self) { fn redraw(&self) {
let date = self.imp().date.borrow().clone(); let date = self.imp().date.borrow();
self.imp() self.imp()
.label .label
.borrow_mut() .borrow_mut()

View File

@ -111,7 +111,6 @@ pub fn main() {
let gtk_tx = core.tx.read().unwrap().clone(); let gtk_tx = core.tx.read().unwrap().clone();
if let Some(gtk_tx) = gtk_tx { if let Some(gtk_tx) = gtk_tx {
println!("sending message");
let state = state.clone(); let state = state.clone();
let _ = gtk_tx.send(Message::Refresh(state)).await; let _ = gtk_tx.send(Message::Refresh(state)).await;
std::thread::sleep(std::time::Duration::from_secs(60)); std::thread::sleep(std::time::Duration::from_secs(60));
@ -124,7 +123,6 @@ pub fn main() {
app.connect_activate(move |app| { app.connect_activate(move |app| {
let (gtk_tx, gtk_rx) = async_std::channel::unbounded(); let (gtk_tx, gtk_rx) = async_std::channel::unbounded();
// gtk::glib::MainContext::channel::<Message>(gtk::glib::Priority::DEFAULT);
*core.tx.write().unwrap() = Some(gtk_tx); *core.tx.write().unwrap() = Some(gtk_tx);
@ -133,23 +131,10 @@ pub fn main() {
glib::spawn_future_local(async move { glib::spawn_future_local(async move {
loop { loop {
println!("spawn_future_local");
let Message::Refresh(state) = gtk_rx.recv().await.unwrap(); let Message::Refresh(state) = gtk_rx.recv().await.unwrap();
println!("Message::Refresh");
window.update_state(state); 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<String> = env::args().collect(); let args: Vec<String> = env::args().collect();