editing: Only enable editing action if available

This commit is contained in:
Sophie Herold 2024-12-21 01:16:24 +01:00
parent dfe71a61fc
commit bbf9534bdd
7 changed files with 52 additions and 12 deletions

View file

@ -18,6 +18,8 @@
use decoder::DecoderError;
use crate::widgets::LpEditWindow;
use super::*;
impl imp::LpImage {
@ -284,6 +286,25 @@ impl imp::LpImage {
}
}
}
async fn check_editable(&self) {
let obj = self.obj();
if let Some(mime_type) = dbg!(obj.metadata().mime_type()) {
if let Ok(supported_formats) = dbg!(glycin::config::Config::cached()
.await
.editor(&mime_type.as_str().into()))
{
if dbg!(LpEditWindow::REQUIRED_OPERATIONS
.iter()
.all(|x| supported_formats.operations.contains(x)))
{
self.editable.set(true);
obj.notify_editable();
}
}
};
}
}
impl LpImage {
@ -338,5 +359,7 @@ impl LpImage {
});
imp.decoder.replace(Some(Arc::new(decoder)));
imp.check_editable().await;
}
}