From eb4e5c469a201a59b551760bf832120176aef1d7 Mon Sep 17 00:00:00 2001 From: Abhinandan Thakur Date: Thu, 19 Feb 2026 12:16:05 +0530 Subject: [PATCH] Changed the logic of app.quit accelerator, introduced a dialog in it. Also made functions such is_save_senstive() and save_overwrite() publicly accessible for logic building. Part-of: --- src/application.rs | 3 ++- src/widgets/edit_window.rs | 6 +++++- src/widgets/window.rs | 14 +++++++------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/application.rs b/src/application.rs index 255a0e6..6d1a0c6 100644 --- a/src/application.rs +++ b/src/application.rs @@ -169,7 +169,8 @@ impl LpApplication { app_clone.quit(); } "save" => { - edit_window_clone.save_as(); + edit_window_clone + .save_as_and_quit(app_clone.clone()); } _ => {} } diff --git a/src/widgets/edit_window.rs b/src/widgets/edit_window.rs index 3ee907f..395701d 100644 --- a/src/widgets/edit_window.rs +++ b/src/widgets/edit_window.rs @@ -25,6 +25,7 @@ use glycin::Operations; use super::LpImage; use super::edit::LpEditCrop; +use crate::LpApplication; use crate::deps::*; use crate::util::ErrorType; use crate::util::gettext::*; @@ -489,12 +490,15 @@ impl LpEditWindow { self.imp().is_save_sensitive() } - pub fn save_as(&self) { + pub fn save_as_and_quit(&self, app: LpApplication) { glib::spawn_future_local(glib::clone!( #[weak(rename_to=win)] self, + #[strong] + app, async move { win.imp().save_overwrite().await; + app.quit() } )); } diff --git a/src/widgets/window.rs b/src/widgets/window.rs index 902a794..fa835f9 100644 --- a/src/widgets/window.rs +++ b/src/widgets/window.rs @@ -168,6 +168,13 @@ impl LpWindow { self.set_fullscreened(fullscreen); } + pub fn edit_window(&self) -> Option { + self.imp() + .edit_window_child + .child() + .and_then(|w| w.downcast::().ok()) + } + pub fn resize_default(&self) { let imp = self.imp(); @@ -268,13 +275,6 @@ impl LpWindow { } } - pub fn edit_window(&self) -> Option { - self.imp() - .edit_window_child - .child() - .and_then(|w| w.downcast::().ok()) - } - pub fn image_view(&self) -> LpImageView { self.imp().image_window.image_view() }