1 // Take a look at the license at the top of the repository in the LICENSE file.
2 
3 use crate::TargetEntry;
4 use crate::TargetList;
5 use glib::translate::*;
6 use std::ptr;
7 
8 impl TargetList {
9     #[doc(alias = "gtk_target_list_new")]
new(targets: &[TargetEntry]) -> Self10     pub fn new(targets: &[TargetEntry]) -> Self {
11         skip_assert_initialized!();
12         let stashes: Vec<_> = targets.iter().map(|e| e.to_glib_none()).collect();
13         let t: Vec<_> = stashes.iter().map(|stash| unsafe { *stash.0 }).collect();
14         let t_ptr: *mut ffi::GtkTargetEntry = if !t.is_empty() {
15             t.as_ptr() as *mut _
16         } else {
17             ptr::null_mut()
18         };
19         unsafe { from_glib_full(ffi::gtk_target_list_new(t_ptr, t.len() as u32)) }
20     }
21 }
22