editing: Only enable editing action if available
This commit is contained in:
parent
dfe71a61fc
commit
bbf9534bdd
7 changed files with 52 additions and 12 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
|
@ -695,9 +695,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gdk4"
|
name = "gdk4"
|
||||||
version = "0.9.4"
|
version = "0.9.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "75933c4a86e8a2428814d367e22c733304fdfabc87f415750fd2f55409b6ee48"
|
checksum = "d0196720118f880f71fe7da971eff58cc43a89c9cf73f46076b7cb1e60889b15"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cairo-rs",
|
"cairo-rs",
|
||||||
"gdk-pixbuf",
|
"gdk-pixbuf",
|
||||||
|
|
@ -898,7 +898,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glycin"
|
name = "glycin"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
source = "git+https://gitlab.gnome.org/GNOME/glycin.git?rev=f06d5f0bf0baf2de74f5eca47c9d5280d2a8911c#f06d5f0bf0baf2de74f5eca47c9d5280d2a8911c"
|
source = "git+https://gitlab.gnome.org/GNOME/glycin.git?rev=967abc701e9969936ecece4a9408663d0a67b1d5#967abc701e9969936ecece4a9408663d0a67b1d5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-fs",
|
"async-fs",
|
||||||
"async-io",
|
"async-io",
|
||||||
|
|
@ -929,7 +929,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glycin-utils"
|
name = "glycin-utils"
|
||||||
version = "3.0.0"
|
version = "3.0.0"
|
||||||
source = "git+https://gitlab.gnome.org/GNOME/glycin.git?rev=f06d5f0bf0baf2de74f5eca47c9d5280d2a8911c#f06d5f0bf0baf2de74f5eca47c9d5280d2a8911c"
|
source = "git+https://gitlab.gnome.org/GNOME/glycin.git?rev=967abc701e9969936ecece4a9408663d0a67b1d5#967abc701e9969936ecece4a9408663d0a67b1d5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"gufo-common",
|
"gufo-common",
|
||||||
|
|
@ -1012,9 +1012,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gtk4"
|
name = "gtk4"
|
||||||
version = "0.9.4"
|
version = "0.9.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9376d14d7e33486c54823a42bef296e882b9f25cb4c52b52f4d1d57bbadb5b6d"
|
checksum = "b697ff938136625f6acf75f01951220f47a45adcf0060ee55b4671cf734dac44"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cairo-rs",
|
"cairo-rs",
|
||||||
"field-offset",
|
"field-offset",
|
||||||
|
|
@ -1083,7 +1083,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gufo-common"
|
name = "gufo-common"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/gufo-rs/gufo.git#704168362f788ddf984920261a7171406bc7c1c0"
|
source = "git+https://github.com/gufo-rs/gufo.git#63033763825c4b68cd631aa7d0c9d4ff6680752e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"paste",
|
"paste",
|
||||||
|
|
@ -1094,7 +1094,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gufo-exif"
|
name = "gufo-exif"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/gufo-rs/gufo.git#704168362f788ddf984920261a7171406bc7c1c0"
|
source = "git+https://github.com/gufo-rs/gufo.git#63033763825c4b68cd631aa7d0c9d4ff6680752e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"gufo-common",
|
"gufo-common",
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ gettext-sys = { version = "0.22.5", features = ["gettext-system"] }
|
||||||
gio = { version = "0.20.0", features = ["v2_74"] }
|
gio = { version = "0.20.0", features = ["v2_74"] }
|
||||||
glycin = { version = "2.0.1", features = [
|
glycin = { version = "2.0.1", features = [
|
||||||
"gdk4",
|
"gdk4",
|
||||||
], git = "https://gitlab.gnome.org/GNOME/glycin.git", rev = "f06d5f0bf0baf2de74f5eca47c9d5280d2a8911c" }
|
], git = "https://gitlab.gnome.org/GNOME/glycin.git", rev = "967abc701e9969936ecece4a9408663d0a67b1d5" }
|
||||||
gtk = { package = "gtk4", version = "0.9.0", features = [
|
gtk = { package = "gtk4", version = "0.9.5", features = [
|
||||||
"v4_14",
|
"v4_14",
|
||||||
"xml_validation",
|
"xml_validation",
|
||||||
] }
|
] }
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@
|
||||||
{
|
{
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://gitlab.gnome.org/GNOME/glycin.git",
|
"url": "https://gitlab.gnome.org/GNOME/glycin.git",
|
||||||
"commit": "f06d5f0bf0baf2de74f5eca47c9d5280d2a8911c"
|
"commit": "967abc701e9969936ecece4a9408663d0a67b1d5"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,12 @@ glib::wrapper! {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LpEditWindow {
|
impl LpEditWindow {
|
||||||
|
pub const REQUIRED_OPERATIONS: &[glycin::OperationId] = &[
|
||||||
|
glycin::OperationId::Clip,
|
||||||
|
glycin::OperationId::MirrorHorizontally,
|
||||||
|
glycin::OperationId::Rotate,
|
||||||
|
];
|
||||||
|
|
||||||
pub fn new(image: LpImage) -> Self {
|
pub fn new(image: LpImage) -> Self {
|
||||||
glib::Object::builder()
|
glib::Object::builder()
|
||||||
.property("original_image", image)
|
.property("original_image", image)
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,9 @@ mod imp {
|
||||||
pub(super) fixed_background_color: RefCell<Option<gdk::RGBA>>,
|
pub(super) fixed_background_color: RefCell<Option<gdk::RGBA>>,
|
||||||
/// Animations disabled
|
/// Animations disabled
|
||||||
pub(super) still: Cell<bool>,
|
pub(super) still: Cell<bool>,
|
||||||
|
/// Editor can be used on image
|
||||||
|
#[property(get)]
|
||||||
|
pub(super) editable: Cell<bool>,
|
||||||
|
|
||||||
/// Track changes to this image
|
/// Track changes to this image
|
||||||
pub(super) file_monitor: RefCell<Option<gio::FileMonitor>>,
|
pub(super) file_monitor: RefCell<Option<gio::FileMonitor>>,
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
use decoder::DecoderError;
|
use decoder::DecoderError;
|
||||||
|
|
||||||
|
use crate::widgets::LpEditWindow;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
impl imp::LpImage {
|
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 {
|
impl LpImage {
|
||||||
|
|
@ -338,5 +359,7 @@ impl LpImage {
|
||||||
});
|
});
|
||||||
|
|
||||||
imp.decoder.replace(Some(Arc::new(decoder)));
|
imp.decoder.replace(Some(Arc::new(decoder)));
|
||||||
|
|
||||||
|
imp.check_editable().await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -767,6 +767,14 @@ impl LpImageWindow {
|
||||||
for action in ACTIONS_CURRENT {
|
for action in ACTIONS_CURRENT {
|
||||||
self.action_set_enabled(action, enabled_current);
|
self.action_set_enabled(action, enabled_current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Editing related actions
|
||||||
|
let enable_editing = self
|
||||||
|
.imp()
|
||||||
|
.image_view
|
||||||
|
.current_image()
|
||||||
|
.map_or(false, |x| x.editable());
|
||||||
|
self.action_set_enabled(&Action::Edit, enable_editing);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles change in image and availability of images
|
/// Handles change in image and availability of images
|
||||||
|
|
@ -783,7 +791,7 @@ impl LpImageWindow {
|
||||||
self.update_title();
|
self.update_title();
|
||||||
|
|
||||||
// Properties view
|
// Properties view
|
||||||
let current_image = current_page.as_ref().map(|x| x.image());
|
let current_image: Option<LpImage> = current_page.as_ref().map(|x| x.image());
|
||||||
imp.properties_view.set_image(current_image.as_ref());
|
imp.properties_view.set_image(current_image.as_ref());
|
||||||
|
|
||||||
let has_image = current_page.is_some();
|
let has_image = current_page.is_some();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue