diff --git a/src/ffmpeg_interface.rs b/src/ffmpeg_interface.rs index 5209eac..556fcaf 100644 --- a/src/ffmpeg_interface.rs +++ b/src/ffmpeg_interface.rs @@ -15,6 +15,8 @@ use std::time::Duration; use subprocess::Exec; use zbus::dbus_proxy; use zvariant::Value; +use gtk::{ButtonsType, DialogFlags, MessageType, MessageDialog, ResponseType}; +use gettextrs::gettext; #[derive(Clone)] pub struct ProgressWidget { @@ -137,6 +139,19 @@ impl Ffmpeg { .to_string(), ); + let is_file_already_exists = std::path::Path::new(format!("{}", self.saved_filename.unwrap())) + .exists(); + + if is_file_already_exists { + if MessageDialog::new(None::<&Window>, + DialogFlags::empty(), + MessageType::Question, + ButtonsType::Ok, + &gettext("Would you like to overwrite this file?")).run() != ResponseType::Ok { + return (None, None); + } + } + if self.record_audio.get_active() { let mut ffmpeg_command = Command::new("ffmpeg"); ffmpeg_command.arg("-f");