Skip to content

Commit

Permalink
desktop: Improve filters in file pickers
Browse files Browse the repository at this point in the history
  • Loading branch information
kjarosh committed Aug 21, 2024
1 parent 3851015 commit 1cc460d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 5 additions & 2 deletions desktop/assets/texts/en-US/dialogs.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ dialog-ok = OK
dialog-cancel = Cancel
picker-title-open-file = Open a single file
picker-filter-flash-files = Flash Files
picker-filter-all-files = All Files
picker-filter-supported = All Supported Files
picker-filter-swf = SWF (*.swf)
picker-filter-spl = FutureSplash Animator (*.spl)
picker-filter-ruf = Ruffle Bundle (*.ruf)
picker-filter-all = All Files
10 changes: 7 additions & 3 deletions desktop/src/gui/picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ impl FilePicker {
}

pub async fn pick_file(&self, dir: Option<PathBuf>) -> Option<PathBuf> {
let locale = &self.data.locale;
let mut dialog = AsyncFileDialog::new()
.add_filter(
text(&self.data.locale, "picker-filter-flash-files"),
text(locale, "picker-filter-supported"),
&["swf", "spl", "ruf"],
)
.add_filter(text(&self.data.locale, "picker-filter-all-files"), &["*"])
.set_title(text(&self.data.locale, "picker-title-open-file"));
.add_filter(text(locale, "picker-filter-swf"), &["swf"])
.add_filter(text(locale, "picker-filter-spl"), &["spl"])
.add_filter(text(locale, "picker-filter-ruf"), &["ruf"])
.add_filter(text(locale, "picker-filter-all"), &["*"])
.set_title(text(locale, "picker-title-open-file"));

if let Some(dir) = dir {
dialog = dialog.set_directory(dir);
Expand Down

0 comments on commit 1cc460d

Please sign in to comment.