update core

This commit is contained in:
ochibani 2025-01-03 21:23:04 +02:00
parent ebc930d564
commit c3741880d8
4 changed files with 30 additions and 5 deletions

12
Cargo.lock generated
View File

@ -504,8 +504,10 @@ version = "0.1.0"
dependencies = [
"anyhow",
"ffmpeg-sidecar",
"glib 0.10.3",
"libadwaita",
"open",
"subprocess",
"tempfile",
]
@ -3721,6 +3723,16 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "subprocess"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c2e86926081dda636c546d8c5e641661049d7562a68f5488be4a1f7f66f6086"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "subtle"
version = "2.6.1"

View File

@ -5,11 +5,13 @@ edition = "2021"
[features]
cmd = []
gtk = ["dep:adw"]
gtk = ["dep:adw", "dep:glib", "dep:subprocess"]
[dependencies]
adw = { version = "0.2.1", package = "libadwaita", features = ["gtk_v4_6"], optional = true }
anyhow = "1.0.86"
ffmpeg-sidecar = "1.1.0"
glib = { version = "0.10.3", optional = true }
open = "5.1.4"
subprocess = {version = "0.2.6", optional = true }
tempfile = "3.10.1"

View File

@ -9,6 +9,15 @@ pub enum RecordMode {
Window,
}
#[cfg(feature = "gtk")]
// Execute command after finish recording
pub fn exec(command: &str) -> Result<()> {
if !command.trim().is_empty() {
subprocess::Exec::shell(command.trim()).popen()?;
}
Ok(())
}
// Check if tmp input video file exist
pub fn is_input_audio_record(audio_filename: &str) -> bool {
std::path::Path::new(audio_filename).exists()
@ -21,18 +30,19 @@ pub fn is_output_audio_record(audio_filename: &str) -> bool {
#[cfg(feature = "gtk")]
// Overwrite file if exists or not
pub fn is_overwrite(filename: &str, window: Window) -> bool {
let is_file_already_exists = Path::new(filename).exists();
pub fn is_overwrite(msg_bundle: &str, filename: &str, window: adw::Window) -> bool {
let is_file_already_exists = std::path::Path::new(filename).exists();
if is_file_already_exists {
let message_dialog = adw::gtk::MessageDialog::new(
Some(&window),
adw::gtk::DialogFlags::all(),
adw::gtk::MessageType::Warning,
adw::gtk::ButtonsType::YesNo,
&&get_bundle("already-exist", None),
msg_bundle,
);
let main_context = glib::MainContext::default();
use adw::prelude::*;
let answer = main_context.block_on(message_dialog.run_future());
message_dialog.close();
@ -77,6 +87,7 @@ pub fn is_wayland() -> bool {
.eq_ignore_ascii_case("wayland")
}
#[cfg(feature = "gtk")]
// Play recorded file
pub fn play_record(file_name: &str) -> Result<()> {
if is_snap() {

View File

@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
anyhow = "1.0.86"
async-std = {version = "1.12.0", features = ["attributes"]}
blue-recorder-core = { path = "../core", features = ["cmd"] }
blue-recorder-core = { path = "../core", features = ["gtk"] }
chrono = "0.4.19"
cpal = "0.15.3"
dark-light = "1.0.0"