gtk4/
file_chooser_dialog.rs
1use std::ptr;
4
5use glib::translate::*;
6use libc::c_char;
7
8use crate::{ffi, prelude::*, FileChooserAction, FileChooserDialog, ResponseType, Widget, Window};
9
10impl FileChooserDialog {
11 #[doc(alias = "gtk_file_chooser_dialog_new")]
31 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
32 #[allow(deprecated)]
33 pub fn new(
34 title: impl IntoOptionalGStr,
35 parent: Option<&impl IsA<Window>>,
36 action: FileChooserAction,
37 buttons: &[(&str, ResponseType)],
38 ) -> Self {
39 assert_initialized_main_thread!();
40 unsafe {
41 let dialog: Self = title.run_with_gstr(|title| {
42 Widget::from_glib_none(ffi::gtk_file_chooser_dialog_new(
43 title.to_glib_none().0,
44 parent.map(|p| p.as_ref()).to_glib_none().0,
45 action.into_glib(),
46 ptr::null::<c_char>(),
47 ))
48 .unsafe_cast()
49 });
50 dialog.add_buttons(buttons);
51 dialog
52 }
53 }
54}
55
56impl Default for FileChooserDialog {
57 fn default() -> Self {
58 glib::Object::new()
59 }
60}