image: Implement Copy to clipboard

This commit is contained in:
Maximiliano Sandoval R 2022-01-08 14:02:16 +01:00
parent 7b760f85f4
commit be09d49756
No known key found for this signature in database
GPG key ID: D64A8D747F6FE706
5 changed files with 36 additions and 0 deletions

View file

@ -342,6 +342,19 @@ impl LpImageView {
Ok(())
}
pub fn copy(&self) -> anyhow::Result<()> {
let clipboard = self.clipboard();
let imp = self.imp();
if let Some(texture) = imp.picture.texture() {
clipboard.set_texture(&texture);
} else {
anyhow::bail!("No Image displayed.");
}
Ok(())
}
pub fn uri(&self) -> Option<String> {
let imp = self.imp();
imp.uri.borrow().to_owned()