January 2018
Beginner to intermediate
454 pages
10h 8m
English
For the open and save dialog, we'll use the same functions as in the previous chapter:
use std::path::PathBuf; use gtk::{FileChooserAction, FileChooserDialog, FileFilter}; use gtk_sys::{GTK_RESPONSE_ACCEPT, GTK_RESPONSE_CANCEL}; const RESPONSE_ACCEPT: i32 = GTK_RESPONSE_ACCEPT as i32; const RESPONSE_CANCEL: i32 = GTK_RESPONSE_CANCEL as i32; fn show_open_dialog(parent: &Window) -> Option<PathBuf> { let mut file = None; let dialog = FileChooserDialog::new(Some("Select an MP3 audio file"), Some(parent), FileChooserAction::Open); let mp3_filter = FileFilter::new(); mp3_filter.add_mime_type("audio/mp3"); mp3_filter.set_name("MP3 audio file"); dialog.add_filter(&mp3_filter); let m3u_filter = FileFilter::new(); m3u_filter.add_mime_type( ...
Read now
Unlock full access