commit
824da89578
5 changed files with 66 additions and 46 deletions
17
Cargo.lock
generated
17
Cargo.lock
generated
|
@ -64,6 +64,7 @@ dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libadwaita",
|
"libadwaita",
|
||||||
"md-5",
|
"md-5",
|
||||||
|
"open",
|
||||||
"relm4",
|
"relm4",
|
||||||
"rfd",
|
"rfd",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
@ -1684,6 +1685,16 @@ version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "open"
|
||||||
|
version = "3.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2078c0039e6a54a0c42c28faa984e115fb4c2d5bf2208f77d1961002df8576f8"
|
||||||
|
dependencies = [
|
||||||
|
"pathdiff",
|
||||||
|
"windows-sys 0.42.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl-probe"
|
name = "openssl-probe"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
|
@ -1785,6 +1796,12 @@ dependencies = [
|
||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pathdiff"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pbkdf2"
|
name = "pbkdf2"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
|
|
|
@ -34,3 +34,5 @@ anyhow = "1.0"
|
||||||
cached = { version = "0.42", features = ["proc_macro"] }
|
cached = { version = "0.42", features = ["proc_macro"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
md-5 = { version = "0.10", features = ["asm"] }
|
md-5 = { version = "0.10", features = ["asm"] }
|
||||||
|
|
||||||
|
open = "3.2.0"
|
||||||
|
|
|
@ -208,12 +208,9 @@ impl SimpleComponent for FirstRunApp {
|
||||||
|
|
||||||
#[allow(unused_must_use)]
|
#[allow(unused_must_use)]
|
||||||
dialog.connect_response(Some("save"), |_, _| {
|
dialog.connect_response(Some("save"), |_, _| {
|
||||||
let result = std::process::Command::new("xdg-open")
|
match open::that(crate::DEBUG_FILE.as_os_str()) {
|
||||||
.arg(crate::DEBUG_FILE.as_os_str())
|
Ok(()) => {},
|
||||||
.output();
|
Err(err) => tracing::error!("Failed to open debug file: {}", err)
|
||||||
|
|
||||||
if let Err(err) = result {
|
|
||||||
tracing::error!("Failed to open debug file: {}", err);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ use crate::ui::components::*;
|
||||||
use super::preferences::main::*;
|
use super::preferences::main::*;
|
||||||
use super::about::*;
|
use super::about::*;
|
||||||
|
|
||||||
|
use open::*;
|
||||||
|
|
||||||
relm4::new_action_group!(WindowActionGroup, "win");
|
relm4::new_action_group!(WindowActionGroup, "win");
|
||||||
|
|
||||||
relm4::new_stateless_action!(LauncherFolder, WindowActionGroup, "launcher_folder");
|
relm4::new_stateless_action!(LauncherFolder, WindowActionGroup, "launcher_folder");
|
||||||
|
@ -526,49 +528,57 @@ impl SimpleComponent for App {
|
||||||
// TODO: reduce code somehow
|
// TODO: reduce code somehow
|
||||||
|
|
||||||
group.add_action::<LauncherFolder>(&RelmAction::new_stateless(clone!(@strong sender => move |_| {
|
group.add_action::<LauncherFolder>(&RelmAction::new_stateless(clone!(@strong sender => move |_| {
|
||||||
if let Err(err) = std::process::Command::new("xdg-open").arg(LAUNCHER_FOLDER.as_path()).spawn() {
|
match open::that(LAUNCHER_FOLDER.as_path()) {
|
||||||
|
Ok(()) => {},
|
||||||
|
Err(err) => {
|
||||||
sender.input(AppMsg::Toast {
|
sender.input(AppMsg::Toast {
|
||||||
title: tr("launcher-folder-opening-error"),
|
title: tr("launcher-folder-opening-error"),
|
||||||
description: Some(err.to_string())
|
description: Some(err.to_string())
|
||||||
});
|
});
|
||||||
|
|
||||||
tracing::error!("Failed to open launcher folder: {err}");
|
tracing::error!("Failed to open launcher folder: {err}");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
group.add_action::<GameFolder>(&RelmAction::new_stateless(clone!(@strong sender => move |_| {
|
group.add_action::<GameFolder>(&RelmAction::new_stateless(clone!(@strong sender => move |_| {
|
||||||
if let Err(err) = std::process::Command::new("xdg-open").arg(&CONFIG.game.path).spawn() {
|
match open::that(&CONFIG.game.path) {
|
||||||
|
Ok(()) => {},
|
||||||
|
Err(err) => {
|
||||||
sender.input(AppMsg::Toast {
|
sender.input(AppMsg::Toast {
|
||||||
title: tr("game-folder-opening-error"),
|
title: tr("game-folder-opening-error"),
|
||||||
description: Some(err.to_string())
|
description: Some(err.to_string())
|
||||||
});
|
});
|
||||||
|
|
||||||
tracing::error!("Failed to open game folder: {err}");
|
tracing::error!("Failed to open game folder: {err}");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
group.add_action::<ConfigFile>(&RelmAction::new_stateless(clone!(@strong sender => move |_| {
|
group.add_action::<ConfigFile>(&RelmAction::new_stateless(clone!(@strong sender => move |_| {
|
||||||
if let Some(file) = anime_launcher_sdk::consts::config_file() {
|
if let Some(file) = anime_launcher_sdk::consts::config_file() {
|
||||||
if let Err(err) = std::process::Command::new("xdg-open").arg(file).spawn() {
|
match open::that(file) {
|
||||||
|
Ok(()) => {},
|
||||||
|
Err(err) => {
|
||||||
sender.input(AppMsg::Toast {
|
sender.input(AppMsg::Toast {
|
||||||
title: tr("config-file-opening-error"),
|
title: tr("config-file-opening-error"),
|
||||||
description: Some(err.to_string())
|
description: Some(err.to_string())
|
||||||
});
|
});
|
||||||
|
|
||||||
tracing::error!("Failed to open config file: {err}");
|
tracing::error!("Failed to open config file: {err}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
group.add_action::<DebugFile>(&RelmAction::new_stateless(clone!(@strong sender => move |_| {
|
group.add_action::<DebugFile>(&RelmAction::new_stateless(clone!(@strong sender => move |_| {
|
||||||
if let Err(err) = std::process::Command::new("xdg-open").arg(DEBUG_FILE.as_os_str()).spawn() {
|
match open::that(crate::DEBUG_FILE.as_os_str()) {
|
||||||
|
Ok(()) => {},
|
||||||
|
Err(err) => {
|
||||||
sender.input(AppMsg::Toast {
|
sender.input(AppMsg::Toast {
|
||||||
title: tr("debug-file-opening-error"),
|
title: tr("debug-file-opening-error"),
|
||||||
description: Some(err.to_string())
|
description: Some(err.to_string())
|
||||||
});
|
});
|
||||||
|
|
||||||
tracing::error!("Failed to open debug file: {err}");
|
tracing::error!("Failed to open debug file: {err}");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
group.add_action::<About>(&RelmAction::new_stateless(move |_| {
|
group.add_action::<About>(&RelmAction::new_stateless(move |_| {
|
||||||
|
@ -1277,12 +1287,9 @@ impl App {
|
||||||
|
|
||||||
#[allow(unused_must_use)]
|
#[allow(unused_must_use)]
|
||||||
dialog.connect_response(Some("save"), |_, _| {
|
dialog.connect_response(Some("save"), |_, _| {
|
||||||
let result = std::process::Command::new("xdg-open")
|
match open::that(crate::DEBUG_FILE.as_os_str()) {
|
||||||
.arg(crate::DEBUG_FILE.as_os_str())
|
Ok(()) => {},
|
||||||
.output();
|
Err(err) => tracing::error!("Failed to open debug file: {}", err),
|
||||||
|
|
||||||
if let Err(err) = result {
|
|
||||||
tracing::error!("Failed to open debug file: {}", err);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -166,12 +166,9 @@ impl SimpleAsyncComponent for PreferencesApp {
|
||||||
|
|
||||||
#[allow(unused_must_use)]
|
#[allow(unused_must_use)]
|
||||||
dialog.connect_response(Some("save"), |_, _| {
|
dialog.connect_response(Some("save"), |_, _| {
|
||||||
let result = std::process::Command::new("xdg-open")
|
match open::that(crate::DEBUG_FILE.as_os_str()) {
|
||||||
.arg(crate::DEBUG_FILE.as_os_str())
|
Ok(()) => {},
|
||||||
.output();
|
Err(err) => tracing::error!("Failed to open debug file: {}", err)
|
||||||
|
|
||||||
if let Err(err) = result {
|
|
||||||
tracing::error!("Failed to open debug file: {}", err);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue