fix borrow_mut error

This commit is contained in:
ochibani 2025-01-04 20:32:32 +02:00
parent 3e19d0af31
commit 4b3c8d7d9f
3 changed files with 97 additions and 97 deletions

View File

@ -428,7 +428,7 @@ impl Ffmpeg {
#[cfg(feature = "gtk")] #[cfg(feature = "gtk")]
impl Ffmpeg { impl Ffmpeg {
// Get file name // Get file name
pub fn get_filename(&mut self) -> Result<String> { pub fn get_filename(&mut self) -> Result<()> {
self.saved_filename = self.saved_filename =
self.filename self.filename
.0 .0
@ -448,7 +448,7 @@ impl Ffmpeg {
.as_path() .as_path()
.display() .display()
.to_string(); .to_string();
Ok(self.saved_filename.clone()) Ok(())
} }
// Start video recording // Start video recording

View File

@ -419,7 +419,7 @@ impl Ffmpeg {
#[cfg(feature = "gtk")] #[cfg(feature = "gtk")]
impl Ffmpeg { impl Ffmpeg {
// Get file name // Get file name
pub fn get_filename(&mut self) -> Result<String> { pub fn get_filename(&mut self) -> Result<()> {
self.saved_filename = self.saved_filename =
self.filename self.filename
.0 .0
@ -439,7 +439,7 @@ impl Ffmpeg {
.as_path() .as_path()
.display() .display()
.to_string(); .to_string();
Ok(self.saved_filename.clone()) Ok(())
} }
// Start video recording // Start video recording

View File

@ -820,102 +820,103 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
_error_dialog.show(); _error_dialog.show();
}, },
Ok(_) => { Ok(_) => {
if !_audio_input_switch.is_active() && // Continue
!_audio_output_switch.is_active() && },
!_video_switch.is_active() || }
!is_overwrite(&get_bundle("already-exist", None), if !_audio_input_switch.is_active() &&
!_audio_output_switch.is_active() &&
!_video_switch.is_active() ||
!is_overwrite(&get_bundle("already-exist", None),
&_ffmpeg_record_interface.borrow_mut().saved_filename,
_main_window.clone()
) && !second_click.borrow_mut().is_clicked() && _delay_spin.value() as u16 == 0
{
// Do nothing
} else {
_delay_window_button.set_active(false);
if _delay_spin.value() as u16 > 0 {
if !is_overwrite(&get_bundle("already-exist", None),
&_ffmpeg_record_interface.borrow_mut().saved_filename, &_ffmpeg_record_interface.borrow_mut().saved_filename,
_main_window.clone() _main_window.clone())
) && !second_click.borrow_mut().is_clicked() && _delay_spin.value() as u16 == 0
{ {
// Do nothing //Do nothing
} else { } else {
_delay_window_button.set_active(false); recording_delay(
if _delay_spin.value() as u16 > 0 { _delay_spin.clone(),
if !is_overwrite(&get_bundle("already-exist", None), _delay_spin.value() as u16,
&_ffmpeg_record_interface.borrow_mut().saved_filename, delay_window.clone(),
_main_window.clone()) _delay_window_button.clone(),
{ delay_window_label.clone(),
//Do nothing _record_button.clone(),
} else { second_click.clone(),
recording_delay( );
_delay_spin.clone(), }
_delay_spin.value() as u16, } else if _delay_spin.value() as u16 == 0 && !is_wayland() {
delay_window.clone(), let _area_capture = area_capture.borrow_mut();
_delay_window_button.clone(), disable_input_widgets(_input_widgets.clone());
delay_window_label.clone(), start_timer(record_time_label.clone());
_record_button.clone(), record_time_label.set_visible(true);
second_click.clone(), if hide_switch.is_active() {
); _main_window.minimize();
} }
} else if _delay_spin.value() as u16 == 0 && !is_wayland() { _play_button.hide();
let _area_capture = area_capture.borrow_mut(); _record_button.hide();
disable_input_widgets(_input_widgets.clone()); _stop_button.show();
start_timer(record_time_label.clone()); if _audio_input_switch.is_active() {
record_time_label.set_visible(true); match _ffmpeg_record_interface.borrow_mut().start_input_audio() {
if hide_switch.is_active() { Ok(_) => {
_main_window.minimize(); // Do nothing
} },
_play_button.hide(); Err(error) => {
_record_button.hide(); enable_input_widgets(_input_widgets.clone());
_stop_button.show(); _record_button.show();
if _audio_input_switch.is_active() { _stop_button.hide();
match _ffmpeg_record_interface.borrow_mut().start_input_audio() { let text_buffer = TextBuffer::new(None);
Ok(_) => { text_buffer.set_text(&format!("{}", error));
// Do nothing _error_message.set_buffer(Some(&text_buffer));
}, _error_dialog.show();
Err(error) => { },
enable_input_widgets(_input_widgets.clone());
_record_button.show();
_stop_button.hide();
let text_buffer = TextBuffer::new(None);
text_buffer.set_text(&format!("{}", error));
_error_message.set_buffer(Some(&text_buffer));
_error_dialog.show();
},
}
}
if _audio_output_switch.is_active() {
match _ffmpeg_record_interface.borrow_mut().start_output_audio() {
Ok(_) => {
// Do nothing
},
Err(error) => {
enable_input_widgets(_input_widgets.clone());
_record_button.show();
_stop_button.hide();
let text_buffer = TextBuffer::new(None);
text_buffer.set_text(&format!("{}", error));
_error_message.set_buffer(Some(&text_buffer));
_error_dialog.show();
},
}
}
if _video_switch.is_active() {
match _ffmpeg_record_interface.borrow_mut().start_video(
_area_capture.x,
_area_capture.y,
_area_capture.width,
_area_capture.height,
mode
) {
Ok(_) => {
// Do nothing
},
Err(error) => {
enable_input_widgets(_input_widgets.clone());
_record_button.show();
_stop_button.hide();
let text_buffer = TextBuffer::new(None);
text_buffer.set_text(&format!("{}", error));
_error_message.set_buffer(Some(&text_buffer));
_error_dialog.show();
},
}
}
} }
} }
}, if _audio_output_switch.is_active() {
match _ffmpeg_record_interface.borrow_mut().start_output_audio() {
Ok(_) => {
// Do nothing
},
Err(error) => {
enable_input_widgets(_input_widgets.clone());
_record_button.show();
_stop_button.hide();
let text_buffer = TextBuffer::new(None);
text_buffer.set_text(&format!("{}", error));
_error_message.set_buffer(Some(&text_buffer));
_error_dialog.show();
},
}
}
if _video_switch.is_active() {
match _ffmpeg_record_interface.borrow_mut().start_video(
_area_capture.x,
_area_capture.y,
_area_capture.width,
_area_capture.height,
mode
) {
Ok(_) => {
// Do nothing
},
Err(error) => {
enable_input_widgets(_input_widgets.clone());
_record_button.show();
_stop_button.hide();
let text_buffer = TextBuffer::new(None);
text_buffer.set_text(&format!("{}", error));
_error_message.set_buffer(Some(&text_buffer));
_error_dialog.show();
},
}
}
}
} }
}); });
@ -1097,9 +1098,8 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
}); });
// Stop recording before close the application // Stop recording before close the application
let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone();
main_window.connect_close_request(move |main_window| { main_window.connect_close_request(move |main_window| {
_ffmpeg_record_interface.borrow_mut().kill().unwrap(); ffmpeg_record_interface.borrow_mut().kill().unwrap();
main_window.destroy(); main_window.destroy();
adw::gtk::Inhibit(true) adw::gtk::Inhibit(true)
}); });