From b2efd6917d5172c1f7e3cf48a3e2d22296acee36 Mon Sep 17 00:00:00 2001 From: "Wyatt J. Miller" Date: Mon, 23 May 2022 22:26:23 -0400 Subject: [PATCH] added filters to file pickers --- src/boxes.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/boxes.rs b/src/boxes.rs index 900334c..62d183c 100644 --- a/src/boxes.rs +++ b/src/boxes.rs @@ -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(),