From 4b3c8d7d9f310929eafb2e8b09049c498ea48d5e Mon Sep 17 00:00:00 2001 From: ochibani <11yzyv86j@relay.firefox.com> Date: Sat, 4 Jan 2025 20:32:32 +0200 Subject: [PATCH] fix borrow_mut error --- core/src/ffmpeg_linux.rs | 4 +- core/src/ffmpeg_windows.rs | 4 +- gui/src/ui.rs | 186 ++++++++++++++++++------------------- 3 files changed, 97 insertions(+), 97 deletions(-) diff --git a/core/src/ffmpeg_linux.rs b/core/src/ffmpeg_linux.rs index 863cc9d..7ea96fe 100644 --- a/core/src/ffmpeg_linux.rs +++ b/core/src/ffmpeg_linux.rs @@ -428,7 +428,7 @@ impl Ffmpeg { #[cfg(feature = "gtk")] impl Ffmpeg { // Get file name - pub fn get_filename(&mut self) -> Result { + pub fn get_filename(&mut self) -> Result<()> { self.saved_filename = self.filename .0 @@ -448,7 +448,7 @@ impl Ffmpeg { .as_path() .display() .to_string(); - Ok(self.saved_filename.clone()) + Ok(()) } // Start video recording diff --git a/core/src/ffmpeg_windows.rs b/core/src/ffmpeg_windows.rs index 1c043ec..ed2921c 100644 --- a/core/src/ffmpeg_windows.rs +++ b/core/src/ffmpeg_windows.rs @@ -419,7 +419,7 @@ impl Ffmpeg { #[cfg(feature = "gtk")] impl Ffmpeg { // Get file name - pub fn get_filename(&mut self) -> Result { + pub fn get_filename(&mut self) -> Result<()> { self.saved_filename = self.filename .0 @@ -439,7 +439,7 @@ impl Ffmpeg { .as_path() .display() .to_string(); - Ok(self.saved_filename.clone()) + Ok(()) } // Start video recording diff --git a/gui/src/ui.rs b/gui/src/ui.rs index eac7fdd..c7d0538 100644 --- a/gui/src/ui.rs +++ b/gui/src/ui.rs @@ -820,102 +820,103 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag _error_dialog.show(); }, Ok(_) => { - if !_audio_input_switch.is_active() && - !_audio_output_switch.is_active() && - !_video_switch.is_active() || - !is_overwrite(&get_bundle("already-exist", None), + // Continue + }, + } + 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, - _main_window.clone() - ) && !second_click.borrow_mut().is_clicked() && _delay_spin.value() as u16 == 0 + _main_window.clone()) { - // Do nothing + //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, - _main_window.clone()) - { - //Do nothing - } else { - recording_delay( - _delay_spin.clone(), - _delay_spin.value() as u16, - delay_window.clone(), - _delay_window_button.clone(), - delay_window_label.clone(), - _record_button.clone(), - second_click.clone(), - ); - } - } else if _delay_spin.value() as u16 == 0 && !is_wayland() { - let _area_capture = area_capture.borrow_mut(); - disable_input_widgets(_input_widgets.clone()); - start_timer(record_time_label.clone()); - record_time_label.set_visible(true); - if hide_switch.is_active() { - _main_window.minimize(); - } - _play_button.hide(); - _record_button.hide(); - _stop_button.show(); - if _audio_input_switch.is_active() { - match _ffmpeg_record_interface.borrow_mut().start_input_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 _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(); - }, - } - } + recording_delay( + _delay_spin.clone(), + _delay_spin.value() as u16, + delay_window.clone(), + _delay_window_button.clone(), + delay_window_label.clone(), + _record_button.clone(), + second_click.clone(), + ); + } + } else if _delay_spin.value() as u16 == 0 && !is_wayland() { + let _area_capture = area_capture.borrow_mut(); + disable_input_widgets(_input_widgets.clone()); + start_timer(record_time_label.clone()); + record_time_label.set_visible(true); + if hide_switch.is_active() { + _main_window.minimize(); + } + _play_button.hide(); + _record_button.hide(); + _stop_button.show(); + if _audio_input_switch.is_active() { + match _ffmpeg_record_interface.borrow_mut().start_input_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 _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 - let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone(); 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(); adw::gtk::Inhibit(true) });