From dcf2481fcfd9311eeaf44def92f15e40b2d6f8ed Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Sun, 3 Jan 2021 04:20:15 +0100 Subject: [PATCH] [GTK3] Add filters to file open dialog --- gtk3/main.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/gtk3/main.c b/gtk3/main.c index 4be2ff3..78e98fa 100644 --- a/gtk3/main.c +++ b/gtk3/main.c @@ -1338,6 +1338,33 @@ static void activate_open(GSimpleAction *action, GVariant *parameter, gpointer a stop(); GtkFileChooserNative *native = gtk_file_chooser_native_new("Open File", GTK_WINDOW(gui_data.main_window), GTK_FILE_CHOOSER_ACTION_OPEN, "_Open", "_Cancel"); + + GtkFileFilter *filter = gtk_file_filter_new(); + gtk_file_filter_add_pattern(filter, "*.gb"); + gtk_file_filter_add_pattern(filter, "*.gbc"); + gtk_file_filter_add_pattern(filter, "*.isx"); + gtk_file_filter_add_mime_type(filter, "application/x-gameboy-rom"); + gtk_file_filter_add_mime_type(filter, "application/x-gameboy-color-rom"); + gtk_file_filter_set_name(filter, "All Supported Files (*.gb, *.gbc, *.isx)"); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(native), filter); + + filter = gtk_file_filter_new(); + gtk_file_filter_add_pattern(filter, "*.gb"); + gtk_file_filter_add_mime_type(filter, "application/x-gameboy-rom"); + gtk_file_filter_set_name(filter, "Game Boy (*.gb)"); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(native), filter); + + filter = gtk_file_filter_new(); + gtk_file_filter_add_pattern(filter, "*.gbc"); + gtk_file_filter_add_mime_type(filter, "application/x-gameboy-color-rom"); + gtk_file_filter_set_name(filter, "Game Boy Color (*.gbc)"); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(native), filter); + + filter = gtk_file_filter_new(); + gtk_file_filter_add_pattern(filter, "*"); + gtk_file_filter_set_name(filter, "All Files"); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(native), filter); + gint res = gtk_native_dialog_run(GTK_NATIVE_DIALOG(native)); if (res == GTK_RESPONSE_ACCEPT) {