1use crate::FileChooser;
4#[cfg(feature = "v3_22")]
5#[cfg_attr(docsrs, doc(cfg(feature = "v3_22")))]
6use glib::translate::*;
7use glib::IsA;
8
9mod sealed {
12 pub trait Sealed {}
13 impl<T: glib::IsA<crate::FileChooser>> Sealed for T {}
14}
15
16pub trait FileChooserExtManual: IsA<FileChooser> + sealed::Sealed + 'static {
17 #[cfg(feature = "v3_22")]
18 #[cfg_attr(docsrs, doc(cfg(feature = "v3_22")))]
19 #[doc(alias = "gtk_file_chooser_add_choice")]
20 fn add_choice(&self, id: &str, label: &str, options: &[(&str, &str)]) {
21 unsafe {
22 let stashes_ids = options
23 .iter()
24 .map(|o| o.0.to_glib_none())
25 .collect::<Vec<_>>();
26 let stashes_labels = options
27 .iter()
28 .map(|o| o.1.to_glib_none())
29 .collect::<Vec<_>>();
30 let (options_ids, options_labels) = (
31 stashes_ids
32 .iter()
33 .map(|o| o.0)
34 .collect::<Vec<*const libc::c_char>>()
35 .as_ptr(),
36 stashes_labels
37 .iter()
38 .map(|o| o.0)
39 .collect::<Vec<*const libc::c_char>>()
40 .as_ptr(),
41 );
42
43 ffi::gtk_file_chooser_add_choice(
44 self.as_ref().to_glib_none().0,
45 id.to_glib_none().0,
46 label.to_glib_none().0,
47 mut_override(options_ids),
48 mut_override(options_labels),
49 );
50 }
51 }
52}
53
54impl<O: IsA<FileChooser>> FileChooserExtManual for O {}