moved buttons from tabpanel
This commit is contained in:
parent
a62eb7fdf1
commit
76904e33b2
7 changed files with 130 additions and 128 deletions
|
@ -135,6 +135,10 @@ impl<'a> CoordState<'a> {
|
||||||
debug!("Starting socket");
|
debug!("Starting socket");
|
||||||
self.sck_alive_recvr.store(true, Ordering::SeqCst);
|
self.sck_alive_recvr.store(true, Ordering::SeqCst);
|
||||||
|
|
||||||
|
if let Err(e) = self.to_gui.send(GuiUpdate::SocketConnecting).await {
|
||||||
|
error!("Cannot send message to gui thread: {e}");
|
||||||
|
}
|
||||||
|
|
||||||
let conn_string: String = {
|
let conn_string: String = {
|
||||||
let read_settings = self.settings.read().await;
|
let read_settings = self.settings.read().await;
|
||||||
|
|
||||||
|
@ -156,9 +160,16 @@ impl<'a> CoordState<'a> {
|
||||||
inbound,
|
inbound,
|
||||||
));
|
));
|
||||||
self.sck_outbound = Some(outbound);
|
self.sck_outbound = Some(outbound);
|
||||||
|
|
||||||
|
if let Err(e) = self.to_gui.send(GuiUpdate::SocketConnected).await {
|
||||||
|
error!("Cannot send message to gui thread: {e}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
error!("Couldn't connect to URL!");
|
error!("Couldn't connect to URL!");
|
||||||
|
if let Err(e) = self.to_gui.send(GuiUpdate::SocketDisconnected).await {
|
||||||
|
error!("Cannot send message to gui thread: {e}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,6 +180,10 @@ impl<'a> CoordState<'a> {
|
||||||
error!("Couldnt' close socket during shutdown: {e}");
|
error!("Couldnt' close socket during shutdown: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Err(e) = self.to_gui.send(GuiUpdate::SocketDisconnected).await {
|
||||||
|
error!("Cannot send message to gui thread: {e}");
|
||||||
|
}
|
||||||
self.sck_alive_recvr.store(false, Ordering::SeqCst);
|
self.sck_alive_recvr.store(false, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,10 +245,10 @@ impl<'a> CoordState<'a> {
|
||||||
if !self.sck_alive_recvr.load(Ordering::SeqCst) || self.sck_outbound.is_none() {
|
if !self.sck_alive_recvr.load(Ordering::SeqCst) || self.sck_outbound.is_none() {
|
||||||
self.socket_close().await;
|
self.socket_close().await;
|
||||||
|
|
||||||
if let Err(e) = self.to_gui.send(GuiUpdate::SocketState(false)).await {
|
if let Err(e) = self.to_gui.send(GuiUpdate::SocketDisconnected).await {
|
||||||
error!("Cannot send message to gui thread: {e}");
|
error!("Cannot send message to gui thread: {e}");
|
||||||
}
|
}
|
||||||
} else if let Err(e) = self.to_gui.send(GuiUpdate::SocketState(true)).await {
|
} else if let Err(e) = self.to_gui.send(GuiUpdate::SocketConnected).await {
|
||||||
error!("Cannot send message to gui thread: {e}");
|
error!("Cannot send message to gui thread: {e}");
|
||||||
self.close().await;
|
self.close().await;
|
||||||
}
|
}
|
||||||
|
@ -296,7 +311,7 @@ pub async fn start_coordinator(
|
||||||
state.socket_start().await;
|
state.socket_start().await;
|
||||||
}
|
}
|
||||||
ApplicationEvent::SocketMessage(socket_message) => {
|
ApplicationEvent::SocketMessage(socket_message) => {
|
||||||
if let Err(e) = state.to_gui.send(GuiUpdate::SocketState(true)).await {
|
if let Err(e) = state.to_gui.send(GuiUpdate::SocketConnected).await {
|
||||||
error!("Could not send to gui thread! Closing coordinator: {e}");
|
error!("Could not send to gui thread! Closing coordinator: {e}");
|
||||||
state.close().await;
|
state.close().await;
|
||||||
break;
|
break;
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -3,6 +3,7 @@ use gtk::{glib, Application};
|
||||||
use std::{env, sync::Arc};
|
use std::{env, sync::Arc};
|
||||||
use tokio::{runtime, sync::RwLock};
|
use tokio::{runtime, sync::RwLock};
|
||||||
use tracing::{self, info, Level};
|
use tracing::{self, info, Level};
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
use tracing_appender;
|
use tracing_appender;
|
||||||
use tracing_subscriber;
|
use tracing_subscriber;
|
||||||
|
|
||||||
|
@ -20,9 +21,20 @@ fn main() -> glib::ExitCode {
|
||||||
// set the environment var to make gtk use window's default action bar
|
// set the environment var to make gtk use window's default action bar
|
||||||
env::set_var("gtk_csd", "0");
|
env::set_var("gtk_csd", "0");
|
||||||
|
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
{
|
||||||
let file_appender = tracing_appender::rolling::daily(".", "joystick-log");
|
let file_appender = tracing_appender::rolling::daily(".", "joystick-log");
|
||||||
let (non_blocking, _gaurd) = tracing_appender::non_blocking(file_appender);
|
let (non_blocking, _gaurd) = tracing_appender::non_blocking(file_appender);
|
||||||
tracing_subscriber::fmt().with_writer(non_blocking).init();
|
tracing_subscriber::fmt().with_writer(non_blocking).init();
|
||||||
|
}
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
{
|
||||||
|
tracing_subscriber::fmt()
|
||||||
|
// .compact()
|
||||||
|
.pretty()
|
||||||
|
.with_max_level(tracing::Level::TRACE)
|
||||||
|
.init();
|
||||||
|
}
|
||||||
|
|
||||||
let span = tracing::span!(Level::TRACE, "main");
|
let span = tracing::span!(Level::TRACE, "main");
|
||||||
let _enter = span.enter();
|
let _enter = span.enter();
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
|
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use async_channel::Sender;
|
use async_channel::Sender;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
glib::object::CastNone,
|
glib::{self, object::CastNone}, prelude::{
|
||||||
prelude::{
|
BoxExt, ButtonExt, Cast, GObjectPropertyExpressionExt, ListItemExt,
|
||||||
BoxExt, ButtonExt, Cast, GObjectPropertyExpressionExt, ListItemExt, ListModelExt,
|
|
||||||
ToggleButtonExt,
|
ToggleButtonExt,
|
||||||
},
|
}, Box, Button, Expander, Label, ListItem, ListView, ScrolledWindow, SignalListItemFactory, SingleSelection, StringList, StringObject, ToggleButton, Widget
|
||||||
Box, Label, ListItem, ListView, ScrolledWindow, SignalListItemFactory, SingleSelection,
|
|
||||||
StringList, StringObject, ToggleButton, Widget,
|
|
||||||
};
|
};
|
||||||
use tracing::{error, instrument};
|
use tracing::{error, span, Level, event};
|
||||||
|
|
||||||
#[cfg(feature = "tracker-state-debug")]
|
#[cfg(feature = "tracker-state-debug")]
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
@ -18,19 +16,25 @@ use tracing::debug;
|
||||||
use crate::{coordinator::ApplicationEvent, remote_sources::TrackerState};
|
use crate::{coordinator::ApplicationEvent, remote_sources::TrackerState};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TrackerPanel {
|
pub struct ControlPanel {
|
||||||
top_level: Box,
|
top_level: Box,
|
||||||
|
|
||||||
enable_disable: ToggleButton,
|
pub connection_buttons: ExpanderMenu,
|
||||||
pub current_id: Label,
|
pub current_id: Label,
|
||||||
scrolled_window: ScrolledWindow,
|
|
||||||
|
|
||||||
pub items: StringList,
|
pub items: StringList,
|
||||||
list_view: ListView,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TrackerPanel {
|
#[derive(Debug)]
|
||||||
pub fn new(tracker_state: Arc<Mutex<TrackerState>>) -> TrackerPanel {
|
pub struct ExpanderMenu {
|
||||||
|
pub top_level: Expander,
|
||||||
|
|
||||||
|
pub camera_connection: Button,
|
||||||
|
pub tracker_enable_toggle: ToggleButton,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ControlPanel {
|
||||||
|
pub fn new(tracker_state: Arc<Mutex<TrackerState>>) -> ControlPanel {
|
||||||
let factory = SignalListItemFactory::new();
|
let factory = SignalListItemFactory::new();
|
||||||
factory.connect_setup(move |_, list_item| {
|
factory.connect_setup(move |_, list_item| {
|
||||||
let list_item = list_item
|
let list_item = list_item
|
||||||
|
@ -89,10 +93,7 @@ impl TrackerPanel {
|
||||||
.margin_bottom(12)
|
.margin_bottom(12)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let enable_disable = ToggleButton::builder()
|
let expander = ExpanderMenu::new();
|
||||||
.label("Enable Automatic Tracking")
|
|
||||||
.active(false)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let current_id = Label::builder()
|
let current_id = Label::builder()
|
||||||
.label("Not Tracking")
|
.label("Not Tracking")
|
||||||
|
@ -101,19 +102,17 @@ impl TrackerPanel {
|
||||||
.css_classes(["current-id"])
|
.css_classes(["current-id"])
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
top_level.append(&enable_disable);
|
top_level.append(&expander.top_level);
|
||||||
top_level.append(¤t_id);
|
top_level.append(¤t_id);
|
||||||
top_level.append(&scrolled_window);
|
top_level.append(&scrolled_window);
|
||||||
|
|
||||||
TrackerPanel {
|
ControlPanel {
|
||||||
top_level,
|
top_level,
|
||||||
|
|
||||||
enable_disable,
|
connection_buttons: expander,
|
||||||
current_id,
|
current_id,
|
||||||
scrolled_window,
|
|
||||||
|
|
||||||
items,
|
items,
|
||||||
list_view,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,14 +120,63 @@ impl TrackerPanel {
|
||||||
&self.top_level
|
&self.top_level
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument]
|
pub fn connect_button_callbacks(&self, to_mec: Sender<ApplicationEvent>) {
|
||||||
pub fn connect_button_callback(&self, to_mec: Sender<ApplicationEvent>) {
|
self.connection_buttons.tracker_enable_toggle.connect_clicked(glib::clone!(@strong to_mec => move |button| {
|
||||||
self.enable_disable.connect_clicked(move |button| {
|
let span = span!(Level::TRACE, "tracker_enable_toggle callback");
|
||||||
|
let _enter = span.enter();
|
||||||
if let Err(e) =
|
if let Err(e) =
|
||||||
to_mec.send_blocking(ApplicationEvent::EnableAutomatic(button.is_active()))
|
to_mec.send_blocking(ApplicationEvent::EnableAutomatic(button.is_active()))
|
||||||
{
|
{
|
||||||
error!("Could not send message to the MEC: {e}");
|
event!(Level::ERROR, error = ?e, "Could not send message to the MEC");
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
self.connection_buttons.camera_connection.connect_clicked(glib::clone!(@strong to_mec => move |_button| {
|
||||||
|
let span = span!(Level::TRACE, "camera_connection callback");
|
||||||
|
let _enter = span.enter();
|
||||||
|
match to_mec.try_send(ApplicationEvent::StartCameraSocket) {
|
||||||
|
Ok(_) => {},
|
||||||
|
Err(async_channel::TrySendError::Closed(_)) => panic!("Coordinator MEC is closed. Unrecoverable error."),
|
||||||
|
Err(e) => event!(Level::ERROR, error = ?e, message = "There was an error sending to the MEC"),
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ExpanderMenu {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
let content_box = Box::builder()
|
||||||
|
.orientation(gtk::Orientation::Vertical)
|
||||||
|
.spacing(10)
|
||||||
|
.margin_top(12)
|
||||||
|
.margin_start(24)
|
||||||
|
.margin_end(24)
|
||||||
|
.margin_bottom(12)
|
||||||
|
.build();
|
||||||
|
let expander = Expander::builder()
|
||||||
|
.child(&content_box)
|
||||||
|
.expanded(true)
|
||||||
|
.label("Connections")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
let camera_connection = Button::builder()
|
||||||
|
.label("Connect to Camera")
|
||||||
|
.margin_top(12)
|
||||||
|
.build();
|
||||||
|
let tracker_enable_toggle = ToggleButton::builder()
|
||||||
|
.label("Connect to Tracker Computer")
|
||||||
|
.active(false)
|
||||||
|
.margin_top(12)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
content_box.append(&camera_connection);
|
||||||
|
content_box.append(&tracker_enable_toggle);
|
||||||
|
|
||||||
|
ExpanderMenu {
|
||||||
|
top_level: expander,
|
||||||
|
|
||||||
|
camera_connection,
|
||||||
|
tracker_enable_toggle,
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,12 +16,9 @@ use crate::coordinator::{start_coordinator, ApplicationEvent, MoveEvent};
|
||||||
use crate::remote_sources::TrackerState;
|
use crate::remote_sources::TrackerState;
|
||||||
|
|
||||||
mod settings_modal;
|
mod settings_modal;
|
||||||
mod socket_panel;
|
|
||||||
mod tracker_panel;
|
|
||||||
mod control_panel;
|
mod control_panel;
|
||||||
|
|
||||||
use socket_panel::SocketPanel;
|
use control_panel::ControlPanel;
|
||||||
use tracker_panel::TrackerPanel;
|
|
||||||
|
|
||||||
pub enum GuiUpdate {
|
pub enum GuiUpdate {
|
||||||
SocketDisconnected,
|
SocketDisconnected,
|
||||||
|
@ -166,21 +163,8 @@ pub fn build_ui(app: &Application, config: Arc<RwLock<AppConfig>>, runtime: Hand
|
||||||
.can_focus(true)
|
.can_focus(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let tabpanel = gtk::Notebook::builder().enable_popup(true).build();
|
let control_panel = Arc::new(ControlPanel::new(tracker_state.clone()));
|
||||||
|
control_panel.connect_button_callbacks(to_mec.clone());
|
||||||
let socket_panel = Arc::new(SocketPanel::new());
|
|
||||||
socket_panel.connect_button_callback(to_mec.clone());
|
|
||||||
tabpanel.append_page(
|
|
||||||
socket_panel.get_top_level(),
|
|
||||||
Some(>k::Label::new(Some("Cam Connection"))),
|
|
||||||
);
|
|
||||||
|
|
||||||
let tracker_panel = TrackerPanel::new(tracker_state.clone());
|
|
||||||
tracker_panel.connect_button_callback(to_mec.clone());
|
|
||||||
tabpanel.append_page(
|
|
||||||
tracker_panel.get_top_level(),
|
|
||||||
Some(&Label::new(Some("Auto Settings"))),
|
|
||||||
);
|
|
||||||
|
|
||||||
let axis_label = Label::builder()
|
let axis_label = Label::builder()
|
||||||
.label("X: 0 Y: )")
|
.label("X: 0 Y: )")
|
||||||
|
@ -189,7 +173,7 @@ pub fn build_ui(app: &Application, config: Arc<RwLock<AppConfig>>, runtime: Hand
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
left_box.append(&conn_status_label);
|
left_box.append(&conn_status_label);
|
||||||
left_box.append(&tabpanel);
|
left_box.append(control_panel.get_top_level());
|
||||||
left_box.append(&axis_label);
|
left_box.append(&axis_label);
|
||||||
|
|
||||||
main_box.append(&left_box);
|
main_box.append(&left_box);
|
||||||
|
@ -214,8 +198,8 @@ pub fn build_ui(app: &Application, config: Arc<RwLock<AppConfig>>, runtime: Hand
|
||||||
overlay_box.set_child(Some(&webcam_picture));
|
overlay_box.set_child(Some(&webcam_picture));
|
||||||
overlay_box.add_overlay(&drawable);
|
overlay_box.add_overlay(&drawable);
|
||||||
|
|
||||||
let items = tracker_panel.items.clone();
|
let items = control_panel.items.clone();
|
||||||
let id_label = tracker_panel.current_id.clone();
|
let id_label = control_panel.current_id.clone();
|
||||||
|
|
||||||
glib::timeout_add_seconds_local(
|
glib::timeout_add_seconds_local(
|
||||||
1,
|
1,
|
||||||
|
@ -251,7 +235,7 @@ pub fn build_ui(app: &Application, config: Arc<RwLock<AppConfig>>, runtime: Hand
|
||||||
);
|
);
|
||||||
|
|
||||||
glib::spawn_future_local(
|
glib::spawn_future_local(
|
||||||
glib::clone!(@weak axis_label, @weak conn_status_label, @weak tabpanel, @strong socket_panel, @strong gui_recv, @weak drawable => async move {
|
glib::clone!(@weak axis_label, @weak conn_status_label, @weak control_panel, @strong gui_recv, @weak drawable => async move {
|
||||||
while let Ok(d) = gui_recv.recv().await {
|
while let Ok(d) = gui_recv.recv().await {
|
||||||
drawable.queue_draw();
|
drawable.queue_draw();
|
||||||
match d {
|
match d {
|
||||||
|
@ -261,31 +245,24 @@ pub fn build_ui(app: &Application, config: Arc<RwLock<AppConfig>>, runtime: Hand
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
GuiUpdate::SocketConnected => {
|
GuiUpdate::SocketConnected => {
|
||||||
tabpanel.set_show_tabs(true);
|
control_panel.connection_buttons.camera_connection.set_sensitive(true);
|
||||||
|
control_panel.connection_buttons.camera_connection.set_label("Press to Disconnect");
|
||||||
socket_panel.button_enable(true);
|
|
||||||
socket_panel.button_label("Press to Disconnect");
|
|
||||||
conn_status_label.set_label("Connected");
|
conn_status_label.set_label("Connected");
|
||||||
|
|
||||||
conn_status_label.set_css_classes(&["YesConnection"]);
|
conn_status_label.set_css_classes(&["YesConnection"]);
|
||||||
|
|
||||||
},
|
},
|
||||||
GuiUpdate::SocketConnecting => {
|
GuiUpdate::SocketConnecting => {
|
||||||
tabpanel.set_show_tabs(true);
|
control_panel.connection_buttons.camera_connection.set_sensitive(true);
|
||||||
|
control_panel.connection_buttons.camera_connection.set_label("Press to Cancel");
|
||||||
socket_panel.button_enable(true);
|
|
||||||
socket_panel.button_label("Press to Cancel");
|
|
||||||
conn_status_label.set_label("Connected");
|
conn_status_label.set_label("Connected");
|
||||||
|
|
||||||
conn_status_label.set_css_classes(&["LoadingConnection"]);
|
conn_status_label.set_css_classes(&["LoadingConnection"]);
|
||||||
|
|
||||||
},
|
},
|
||||||
GuiUpdate::SocketDisconnected => {
|
GuiUpdate::SocketDisconnected => {
|
||||||
tabpanel.set_page(0);
|
control_panel.connection_buttons.camera_connection.set_sensitive(false);
|
||||||
tabpanel.set_show_tabs(false);
|
control_panel.connection_buttons.camera_connection.set_label("Press to Connect to Camera");
|
||||||
|
|
||||||
socket_panel.button_enable(false);
|
|
||||||
socket_panel.button_label("Press to Connect to Camera");
|
|
||||||
conn_status_label.set_label("Not Connected to Camera");
|
conn_status_label.set_label("Not Connected to Camera");
|
||||||
|
|
||||||
conn_status_label.set_css_classes(&["NoConnection"]);
|
conn_status_label.set_css_classes(&["NoConnection"]);
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use gtk::glib::{self, clone};
|
use gtk::glib::{self, clone};
|
||||||
use gtk::{
|
use gtk::{
|
||||||
prelude::{BoxExt, ButtonExt, EditableExt},
|
prelude::{BoxExt, ButtonExt, EditableExt, GtkWindowExt},
|
||||||
Application, ApplicationWindow, Box, Button, Entry, Label, Window,
|
Application, ApplicationWindow, Box, Button, Entry, Label, Window,
|
||||||
};
|
};
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
|
@ -121,7 +121,7 @@ impl ConnectionsModal {
|
||||||
|
|
||||||
let new_ref = app_config.clone();
|
let new_ref = app_config.clone();
|
||||||
quit_button.connect_clicked(clone!(
|
quit_button.connect_clicked(clone!(
|
||||||
@strong rt,
|
@strong rt, @weak window,
|
||||||
@weak camera_ip_entry, @weak camera_port_entry,
|
@weak camera_ip_entry, @weak camera_port_entry,
|
||||||
@weak tracker_ip_entry, @weak tracker_port_entry,
|
@weak tracker_ip_entry, @weak tracker_port_entry,
|
||||||
@weak tracker_refresh_millis => move |_| {
|
@weak tracker_refresh_millis => move |_| {
|
||||||
|
@ -151,6 +151,8 @@ impl ConnectionsModal {
|
||||||
// FBI!!! OPEN UP!!!!
|
// FBI!!! OPEN UP!!!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.close();
|
||||||
|
|
||||||
info!("Please nicholas, add a non-crashing parse");
|
info!("Please nicholas, add a non-crashing parse");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
use async_channel::Sender;
|
|
||||||
use gtk::{
|
|
||||||
glib, prelude::{BoxExt, ButtonExt, WidgetExt}, Box, Button
|
|
||||||
};
|
|
||||||
use log::error;
|
|
||||||
|
|
||||||
use crate::coordinator::ApplicationEvent;
|
|
||||||
|
|
||||||
pub struct SocketPanel {
|
|
||||||
top_level: Box,
|
|
||||||
|
|
||||||
connect_button: Button,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SocketPanel {
|
|
||||||
pub fn new() -> SocketPanel {
|
|
||||||
let content_box = Box::builder()
|
|
||||||
.orientation(gtk::Orientation::Vertical)
|
|
||||||
.spacing(10)
|
|
||||||
.margin_top(12)
|
|
||||||
.margin_start(24)
|
|
||||||
.margin_end(24)
|
|
||||||
.margin_bottom(12)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let button = Button::builder().margin_top(12).build();
|
|
||||||
|
|
||||||
content_box.append(&button);
|
|
||||||
|
|
||||||
SocketPanel {
|
|
||||||
top_level: content_box,
|
|
||||||
connect_button: button,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_top_level(&self) -> &Box {
|
|
||||||
&self.top_level
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn button_label(&self, new_label: &str) {
|
|
||||||
self.connect_button.set_label(new_label);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn button_enable(&self, new_state: bool) {
|
|
||||||
self.connect_button.set_sensitive(new_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn connect_button_callback(&self, to_mec: Sender<ApplicationEvent>) {
|
|
||||||
self.connect_button.connect_clicked(glib::clone!(@strong to_mec => move |_button| {
|
|
||||||
match to_mec.try_send(ApplicationEvent::StartCameraSocket) {
|
|
||||||
Ok(_) => {},
|
|
||||||
Err(async_channel::TrySendError::Closed(_)) => panic!("Coordinator MEC is closed. Unrecoverable error."),
|
|
||||||
Err(e) => error!("There was an error sending to the MEC: {}", e),
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,6 +19,11 @@ entry {
|
||||||
font-size: 16pt;
|
font-size: 16pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
label.LoadingConnection {
|
||||||
|
background-color: goldenrod;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
label.NoConnection {
|
label.NoConnection {
|
||||||
background-color: brown;
|
background-color: brown;
|
||||||
color: whitesmoke;
|
color: whitesmoke;
|
||||||
|
|
Loading…
Reference in a new issue