gdk4/auto/
file_list.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9    /// An opaque type representing a list of files.
10    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
11    pub struct FileList(Boxed<ffi::GdkFileList>);
12
13    match fn {
14        copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::gdk_file_list_get_type(), ptr as *mut _) as *mut ffi::GdkFileList,
15        free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::gdk_file_list_get_type(), ptr as *mut _),
16        type_ => || ffi::gdk_file_list_get_type(),
17    }
18}
19
20impl FileList {
21    /// Creates a new [`FileList`][crate::FileList] for the given array of files.
22    ///
23    /// This function is meant to be used by language bindings.
24    /// ## `files`
25    /// the files to add to the list
26    ///
27    /// # Returns
28    ///
29    /// the newly create files list
30    #[cfg(feature = "v4_8")]
31    #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
32    #[doc(alias = "gdk_file_list_new_from_array")]
33    #[doc(alias = "new_from_array")]
34    pub fn from_array(files: &[gio::File]) -> FileList {
35        assert_initialized_main_thread!();
36        let n_files = files.len() as _;
37        unsafe {
38            from_glib_full(ffi::gdk_file_list_new_from_array(
39                files.to_glib_none().0,
40                n_files,
41            ))
42        }
43    }
44
45    /// Retrieves the list of files inside a [`FileList`][crate::FileList].
46    ///
47    /// This function is meant for language bindings.
48    ///
49    /// # Returns
50    ///
51    /// the files inside the list
52    #[doc(alias = "gdk_file_list_get_files")]
53    #[doc(alias = "get_files")]
54    pub fn files(&self) -> Vec<gio::File> {
55        unsafe {
56            FromGlibPtrContainer::from_glib_container(ffi::gdk_file_list_get_files(mut_override(
57                self.to_glib_none().0,
58            )))
59        }
60    }
61}