diff --git a/src/bin/gui/main_window.rs b/src/bin/gui/main_window.rs index 17d912c..b48990e 100644 --- a/src/bin/gui/main_window.rs +++ b/src/bin/gui/main_window.rs @@ -2,7 +2,7 @@ use std::{cell::RefCell, rc::Rc}; use gtk4::{ glib, - prelude::{ApplicationExt, GtkWindowExt, WidgetExt}, + prelude::{ApplicationExt, BoxExt, GtkWindowExt, WidgetExt}, Application, ApplicationWindow, Builder, Label, }; use log::trace; @@ -25,13 +25,36 @@ fn build_ui( app: >k4::Application, from_backend_rx: Rc>>>, ) { - let glade_src = include_str!("../../../gui/sieverman.ui"); - let builder = Builder::from_string(glade_src); - let main_window: ApplicationWindow = builder.object("sieverman").expect("get main-window"); - main_window.set_height_request(400); - main_window.set_application(Some(app)); + let action_content_status = gtk4::Box::builder() + .orientation(gtk4::Orientation::Vertical) + .spacing(5) + .build(); + let action = gtk4::ActionBar::new(); + let status = gtk4::Statusbar::new(); + let main_log_server_info = gtk4::Box::builder() + .orientation(gtk4::Orientation::Horizontal) + .hexpand(true) + .vexpand(true) + .halign(gtk4::Align::Fill) + .build(); + action_content_status.append(&action); + action_content_status.append(&main_log_server_info); + action_content_status.append(&status); + let log = gtk4::Label::new(Some("Log")); + let server_info = gtk4::Label::new(Some("Server Info")); + main_log_server_info.append(&log); + main_log_server_info.append(&server_info); + let main_window = gtk4::ApplicationWindow::builder() + .application(app) + .title("Sieverman") + .height_request(400) + .width_request(400) + .child(&action_content_status) + .build(); main_window.present(); + let server_info = Rc::new(RefCell::new(server_info)); + let future = { let mut data_event_receiver = from_backend_rx.take().expect("data_event_reciver"); async move { @@ -40,8 +63,7 @@ fn build_ui( match event { BackToFront::ServerConnected(message) => { trace!("Received {}", message); - let status_label: Label = builder.object("serverstatus").unwrap(); - status_label.set_text(&message) + server_info.borrow_mut().set_text(&message); } } }