editing: Correctly detect if trash is supported
Don't activate "Replace Original" action, if trashing of the original file is not supported. Closes #509
This commit is contained in:
parent
2c121bf19e
commit
246c4a6bcc
2 changed files with 7 additions and 2 deletions
1
news.d/49.1/fixed-editing-disable-trash-option
Normal file
1
news.d/49.1/fixed-editing-disable-trash-option
Normal file
|
|
@ -0,0 +1 @@
|
|||
editing: Don't enable option to trash and replace with trash is not supported.
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
use std::cell::{OnceCell, RefCell};
|
||||
use std::cell::{Cell, OnceCell, RefCell};
|
||||
use std::sync::Arc;
|
||||
|
||||
use adw::prelude::*;
|
||||
|
|
@ -56,6 +56,9 @@ mod imp {
|
|||
#[property(get, construct_only)]
|
||||
pub edit_crop: OnceCell<LpEditCrop>,
|
||||
|
||||
/// Whether the original file can be trashed
|
||||
pub(super) can_trash: Cell<bool>,
|
||||
|
||||
pub(super) operations: RefCell<Option<Arc<Operations>>>,
|
||||
save_cancellable: RefCell<Option<gio::Cancellable>>,
|
||||
}
|
||||
|
|
@ -107,6 +110,7 @@ mod imp {
|
|||
obj,
|
||||
async move {
|
||||
let can_trash = obj.original_image().can_trash().await;
|
||||
obj.imp().can_trash.replace(can_trash);
|
||||
obj.action_set_enabled("edit.save-overwrite", can_trash);
|
||||
}
|
||||
));
|
||||
|
|
@ -451,7 +455,7 @@ mod imp {
|
|||
let enabled = self.is_save_sensitive() && !force_disabled;
|
||||
|
||||
self.save.set_sensitive(enabled);
|
||||
obj.action_set_enabled("edit.save-overwrite", enabled);
|
||||
obj.action_set_enabled("edit.save-overwrite", enabled & self.can_trash.get());
|
||||
obj.action_set_enabled("edit.save-copy", enabled);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue