mirror of
https://github.com/13hannes11/toolbx-tuner.git
synced 2024-09-03 23:21:00 +02:00
move starting of terminal to main thread #4
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use std::process::Command;
|
||||
|
||||
use relm4::{AppUpdate, Sender};
|
||||
|
||||
use crate::{
|
||||
@@ -62,14 +64,17 @@ impl AppUpdate for AppModel {
|
||||
|
||||
AppMsg::OpenToolbxTerminal(index) => {
|
||||
if let Some(toolbx_container) = self.toolboxes.get_mut(index.current_index()) {
|
||||
components
|
||||
.async_handler
|
||||
.sender()
|
||||
.blocking_send(AsyncHandlerMsg::OpenToolbxTerminal(
|
||||
index,
|
||||
toolbx_container.clone(),
|
||||
))
|
||||
.expect("Receiver dropped");
|
||||
// TODO: support many terminals and check which are installed
|
||||
let output = Command::new("gnome-terminal")
|
||||
.arg("--")
|
||||
.arg("toolbox")
|
||||
.arg("enter")
|
||||
.arg(toolbx_container.toolbx_container.name.clone())
|
||||
.output();
|
||||
|
||||
println!("{:?}", output);
|
||||
|
||||
// TODO: update status
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use std::process::Command;
|
||||
|
||||
use relm4::factory::DynamicIndex;
|
||||
use relm4::{send, MessageHandler, Sender};
|
||||
use tokio::runtime::{Builder, Runtime};
|
||||
@@ -20,7 +18,6 @@ pub struct AsyncHandler {
|
||||
pub enum AsyncHandlerMsg {
|
||||
StopToolbx(DynamicIndex, ToolbxEntry),
|
||||
StartToolbx(DynamicIndex, ToolbxEntry),
|
||||
OpenToolbxTerminal(DynamicIndex, ToolbxEntry),
|
||||
}
|
||||
|
||||
impl MessageHandler<AppModel> for AsyncHandler {
|
||||
@@ -52,19 +49,6 @@ impl MessageHandler<AppModel> for AsyncHandler {
|
||||
tbx.changing_status = false;
|
||||
send! {parent_sender, AppMsg::ToolbxContainerChanged(index, tbx)};
|
||||
}
|
||||
AsyncHandlerMsg::OpenToolbxTerminal(index, mut tbx) => {
|
||||
// TODO: support many terminals and check which are installed
|
||||
let output = Command::new("gnome-terminal")
|
||||
.arg("--")
|
||||
.arg("toolbox")
|
||||
.arg("enter")
|
||||
.arg(tbx.toolbx_container.name.clone())
|
||||
.output();
|
||||
|
||||
println!("{:?}", output);
|
||||
|
||||
// TODO: update status
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user