window: Port delete confirmation to AdwAlertDialog

This commit is contained in:
DaPigGuy 2024-06-11 23:32:45 -07:00
parent 7c8e9c1666
commit dfd74b060f
No known key found for this signature in database
GPG key ID: 1F20B872A4A3B681

View file

@ -609,9 +609,7 @@ impl LpWindow {
/// ///
/// Fallback for when trash not available or explicit call with shortcut /// Fallback for when trash not available or explicit call with shortcut
async fn delete_future(&self, path: &Path) { async fn delete_future(&self, path: &Path) {
let dialog = adw::MessageDialog::builder() let dialog = adw::AlertDialog::builder()
.modal(true)
.transient_for(self)
.heading(gettext("Permanently Delete Image?")) .heading(gettext("Permanently Delete Image?"))
.body(gettext_f( .body(gettext_f(
"After deleting the image “{}” it will be permanently lost.", "After deleting the image “{}” it will be permanently lost.",
@ -627,7 +625,7 @@ impl LpWindow {
]); ]);
dialog.set_response_appearance("delete", adw::ResponseAppearance::Destructive); dialog.set_response_appearance("delete", adw::ResponseAppearance::Destructive);
if "delete" == dialog.choose_future().await { if "delete" == dialog.choose_future(self).await {
let file = gio::File::for_path(path); let file = gio::File::for_path(path);
let result = file.delete_future(glib::Priority::default()).await; let result = file.delete_future(glib::Priority::default()).await;