[GTK3] Add filters to file open dialog

This commit is contained in:
Maximilian Mader 2021-01-03 04:20:15 +01:00
parent f45613f715
commit dcf2481fcf
Signed by: Max
GPG Key ID: F71D56A3151C4FB3

View File

@ -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) {