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