Set up a header bar
This commit is contained in:
parent
caaf9c57c6
commit
95b46de7fc
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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::<Message>(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<String> = env::args().collect();
|
||||
|
|
Loading…
Reference in New Issue