Implement drag source on images
Using a 128x128 thumbnail.
This commit is contained in:
parent
fc6d3668c0
commit
13d7a21501
5 changed files with 135 additions and 0 deletions
|
|
@ -210,4 +210,22 @@ impl LpImage {
|
|||
let imp = self.imp();
|
||||
imp.texture.borrow().clone()
|
||||
}
|
||||
|
||||
pub fn content_provider(&self) -> anyhow::Result<gdk::ContentProvider> {
|
||||
let imp = self.imp();
|
||||
let mut contents = vec![];
|
||||
|
||||
if let Some(file) = imp.file.borrow().as_ref() {
|
||||
let content = gdk::ContentProvider::for_value(&file.to_value());
|
||||
contents.push(content);
|
||||
}
|
||||
|
||||
if let Some(texture) = imp.texture.borrow().as_ref() {
|
||||
let bytes = texture.save_to_png_bytes();
|
||||
let content = gdk::ContentProvider::for_bytes("image/png", &bytes);
|
||||
contents.push(content);
|
||||
}
|
||||
|
||||
Ok(gdk::ContentProvider::new_union(contents.as_slice()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue