image: Use FileList in ContentProvider
Makes dragging an image out of Loupe work in most cases. There seems to be an issue with dragging from flatpak to host. Removing the png from the provider seems to avoid gdk crashes but not 100% sure that was the cause.
This commit is contained in:
parent
b202c1d2d2
commit
d6ab100062
3 changed files with 6 additions and 18 deletions
|
|
@ -905,21 +905,9 @@ impl LpImage {
|
|||
}
|
||||
|
||||
/// Drag and drop content provider
|
||||
pub fn content_provider(&self) -> 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);
|
||||
}
|
||||
|
||||
gdk::ContentProvider::new_union(contents.as_slice())
|
||||
pub fn content_provider(&self) -> Option<gdk::ContentProvider> {
|
||||
let file = self.file()?;
|
||||
let list = gdk::FileList::from_array(&[file]);
|
||||
Some(gdk::ContentProvider::for_value(&list.to_value()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue