gtk/
target_list.rs

1use glib::translate::*;
2use gtk_sys;
3use std::ptr;
4use TargetEntry;
5use TargetList;
6
7impl TargetList {
8    pub fn new(targets: &[TargetEntry]) -> Self {
9        skip_assert_initialized!();
10        let stashes: Vec<_> = targets.iter().map(|e| e.to_glib_none()).collect();
11        let t: Vec<_> = stashes.iter().map(|stash| unsafe { *stash.0 }).collect();
12        let t_ptr: *mut gtk_sys::GtkTargetEntry = if !t.is_empty() {
13            t.as_ptr() as *mut _
14        } else {
15            ptr::null_mut()
16        };
17        unsafe { from_glib_full(gtk_sys::gtk_target_list_new(t_ptr, t.len() as u32)) }
18    }
19}