added filters to file pickers

This commit is contained in:
Wyatt J. Miller 2022-05-23 22:26:23 -04:00
parent d3ee0bc068
commit b2efd6917d

View File

@ -1,6 +1,6 @@
use std::rc::Rc;
use gtk4::{prelude::*, Window};
use gtk4::{prelude::*, Window, FileFilter};
use gtk4::{
glib::*,
ApplicationWindow,
@ -73,6 +73,14 @@ impl RomBox {
// here's to set the dialog to be modal
dialog.set_modal(true);
// add a filter!
let rom_filter = FileFilter::new();
rom_filter.add_mime_type("application/vnd.nintendo.snes.rom");
rom_filter.set_name(Some("SNES ROMs"));
dialog.add_filter(&rom_filter);
// run the dialog
dialog.run_async(|d, r| {
match r {
ResponseType::Accept => d.close(),
@ -142,6 +150,14 @@ impl PatchBox {
// here's to set the dialog to be modal
dialog.set_modal(true);
let patch_filter = FileFilter::new();
patch_filter.add_mime_type("application/x-bps-patch");
patch_filter.add_mime_type("application/x-ips-patch");
patch_filter.set_name(Some("Patches"));
dialog.add_filter(&patch_filter);
// run the dialog
dialog.run_async(|d, r| {
match r {
ResponseType::Accept => d.close(),