in native/desktop-linux-sample/src/sample_linux.rs [521:546]
fn on_data_transfer_received(content: &DataTransferContent, window_state: &mut WindowState) {
if let Some(mime_type) = content.mime_type.as_optional_cstr() {
let data = content.data.as_slice().unwrap();
if mime_type == URI_LIST_MIME_TYPE {
let list_str = str::from_utf8(data).unwrap();
assert!(list_str.ends_with("\r\n"), "{list_str} doesn't end with CRLF");
let list = {
let mut v = list_str.split("\r\n").collect::<Vec<_>>();
let last = v.pop();
assert_eq!(last, Some(""));
v
};
info!("Pasted file list: {list:?}");
for e in list {
assert!(e.starts_with("file:///"), "\"{e}\" doesn't start with \"file:///\"");
assert_eq!(e, e.trim_ascii_end());
}
} else if mime_type == TEXT_MIME_TYPE {
let data_str = str::from_utf8(data).unwrap();
window_state.text += data_str;
} else {
warn!("Mime type {mime_type:?} is not supported");
}
}
window_state.drag_and_drop_target = false;
}