From d1c470681ac6d546ee679b9155299ccfcc8faa3e Mon Sep 17 00:00:00 2001 From: ochibani <11yzyv86j@relay.firefox.com> Date: Thu, 20 Oct 2022 17:36:05 +0200 Subject: [PATCH] fix FileChooserButton --- src/ffmpeg_interface.rs | 7 ++++--- src/main.rs | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ffmpeg_interface.rs b/src/ffmpeg_interface.rs index 9db9927..e6aaf60 100644 --- a/src/ffmpeg_interface.rs +++ b/src/ffmpeg_interface.rs @@ -1,9 +1,8 @@ extern crate subprocess; use chrono::prelude::*; use gettextrs::gettext; -use gio::File; use gtk::prelude::*; -use gtk::{Button, CheckButton, ComboBoxText, Entry, ProgressBar, SpinButton, Window}; +use gtk::{Button, CheckButton, ComboBoxText, Entry, FileChooserNative, ProgressBar, SpinButton, Window}; use gtk::{ButtonsType, DialogFlags, MessageDialog, MessageType, ResponseType}; use std::path::PathBuf; use std::process::Command; @@ -51,7 +50,7 @@ impl ProgressWidget { #[derive(Clone)] pub struct Ffmpeg { - pub filename: (File, Entry, ComboBoxText), + pub filename: (FileChooserNative, Entry, ComboBoxText), pub record_video: CheckButton, pub record_audio: CheckButton, pub audio_id: ComboBoxText, @@ -80,6 +79,8 @@ impl Ffmpeg { self.saved_filename = Some( self.filename .0 + .file() + .unwrap() .path() .unwrap() .join(PathBuf::from(format!( diff --git a/src/main.rs b/src/main.rs index 3cfbe1a..950ca36 100644 --- a/src/main.rs +++ b/src/main.rs @@ -304,6 +304,7 @@ pub fn build_ui(application: &Application) { ); folder_chooser_native.set_transient_for(Some(&main_window)); folder_chooser_native.set_modal(true); + folder_chooser_native.set_file(&gio::File::for_uri(&config_management::get("default", "folder"))).unwrap(); let folder_chooser = Some(gio::File::for_uri(&config_management::get("default", "folder"))).unwrap(); let folder_chooser_name = folder_chooser.basename().unwrap(); folder_chooser_label.set_label(&folder_chooser_name.to_string_lossy()); @@ -313,6 +314,7 @@ pub fn build_ui(application: &Application) { folder_chooser_button.connect_clicked(glib::clone!(@strong folder_chooser_native => move |_| { folder_chooser_native.connect_response(glib::clone!(@strong folder_chooser_native, @strong folder_chooser_label, @strong folder_chooser_image => move |_, response| { if response == gtk::ResponseType::Accept { + folder_chooser_native.file().unwrap(); let folder_chooser = folder_chooser_native.file().unwrap(); let folder_chooser_name = folder_chooser.basename().unwrap(); folder_chooser_label.set_label(&folder_chooser_name.to_string_lossy()); @@ -373,7 +375,7 @@ pub fn build_ui(application: &Application) { // Init record struct let ffmpeg_record_interface: Rc> = Rc::new(RefCell::new(Ffmpeg { - filename: (folder_chooser, filename_entry, format_chooser_combobox), + filename: (folder_chooser_native, filename_entry, format_chooser_combobox), record_video: video_switch, record_audio: audio_switch, audio_id: audio_source_combobox,