mirror of
https://github.com/13hannes11/toolbx-tuner.git
synced 2024-09-03 23:21:00 +02:00
add first hacky implementaion that opens terminal, #4
This commit is contained in:
@@ -6,5 +6,6 @@ pub enum AppMsg {
|
|||||||
ShowToolboxSettingsRequest,
|
ShowToolboxSettingsRequest,
|
||||||
ShowToolboxAppsRequest,
|
ShowToolboxAppsRequest,
|
||||||
ToolbxContainerToggleStartStop(DynamicIndex),
|
ToolbxContainerToggleStartStop(DynamicIndex),
|
||||||
|
OpenToolbxTerminal(DynamicIndex),
|
||||||
ToolbxContainerChanged(DynamicIndex, ToolbxEntry),
|
ToolbxContainerChanged(DynamicIndex, ToolbxEntry),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ impl FactoryPrototype for ToolbxEntry {
|
|||||||
type Msg = AppMsg;
|
type Msg = AppMsg;
|
||||||
|
|
||||||
fn init_view(&self, key: &DynamicIndex, sender: Sender<Self::Msg>) -> Self::Widgets {
|
fn init_view(&self, key: &DynamicIndex, sender: Sender<Self::Msg>) -> Self::Widgets {
|
||||||
|
let index = key.clone();
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
suffix_box = >k::Box{
|
suffix_box = >k::Box{
|
||||||
append = >k::AspectFrame{
|
append = >k::AspectFrame{
|
||||||
@@ -56,6 +58,9 @@ impl FactoryPrototype for ToolbxEntry {
|
|||||||
set_margin_bottom: 10,
|
set_margin_bottom: 10,
|
||||||
set_tooltip_text: Some(TERMINAL_TOOLTIP),
|
set_tooltip_text: Some(TERMINAL_TOOLTIP),
|
||||||
set_css_classes: &["flat"],
|
set_css_classes: &["flat"],
|
||||||
|
connect_clicked(sender) => move |btn| {
|
||||||
|
send!(sender, AppMsg::OpenToolbxTerminal(index.clone()));
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
append = >k::AspectFrame{
|
append = >k::AspectFrame{
|
||||||
|
|||||||
@@ -59,6 +59,19 @@ impl AppUpdate for AppModel {
|
|||||||
toolbx_container.update_entry(container);
|
toolbx_container.update_entry(container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
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};
|
||||||
@@ -18,6 +20,7 @@ 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 {
|
||||||
@@ -49,6 +52,19 @@ 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