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 relm4::{AppUpdate, Sender};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -62,14 +64,17 @@ impl AppUpdate for AppModel {
|
|||||||
|
|
||||||
AppMsg::OpenToolbxTerminal(index) => {
|
AppMsg::OpenToolbxTerminal(index) => {
|
||||||
if let Some(toolbx_container) = self.toolboxes.get_mut(index.current_index()) {
|
if let Some(toolbx_container) = self.toolboxes.get_mut(index.current_index()) {
|
||||||
components
|
// TODO: support many terminals and check which are installed
|
||||||
.async_handler
|
let output = Command::new("gnome-terminal")
|
||||||
.sender()
|
.arg("--")
|
||||||
.blocking_send(AsyncHandlerMsg::OpenToolbxTerminal(
|
.arg("toolbox")
|
||||||
index,
|
.arg("enter")
|
||||||
toolbx_container.clone(),
|
.arg(toolbx_container.toolbx_container.name.clone())
|
||||||
))
|
.output();
|
||||||
.expect("Receiver dropped");
|
|
||||||
|
println!("{:?}", output);
|
||||||
|
|
||||||
|
// TODO: update status
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use std::process::Command;
|
|
||||||
|
|
||||||
use relm4::factory::DynamicIndex;
|
use relm4::factory::DynamicIndex;
|
||||||
use relm4::{send, MessageHandler, Sender};
|
use relm4::{send, MessageHandler, Sender};
|
||||||
use tokio::runtime::{Builder, Runtime};
|
use tokio::runtime::{Builder, Runtime};
|
||||||
@@ -20,7 +18,6 @@ pub struct AsyncHandler {
|
|||||||
pub enum AsyncHandlerMsg {
|
pub enum AsyncHandlerMsg {
|
||||||
StopToolbx(DynamicIndex, ToolbxEntry),
|
StopToolbx(DynamicIndex, ToolbxEntry),
|
||||||
StartToolbx(DynamicIndex, ToolbxEntry),
|
StartToolbx(DynamicIndex, ToolbxEntry),
|
||||||
OpenToolbxTerminal(DynamicIndex, ToolbxEntry),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MessageHandler<AppModel> for AsyncHandler {
|
impl MessageHandler<AppModel> for AsyncHandler {
|
||||||
@@ -52,19 +49,6 @@ impl MessageHandler<AppModel> for AsyncHandler {
|
|||||||
tbx.changing_status = false;
|
tbx.changing_status = false;
|
||||||
send! {parent_sender, AppMsg::ToolbxContainerChanged(index, tbx)};
|
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