Save-Dialog: Added a Save Dialog for Ctrl+Q Unsaved Changes

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.

Fixes: #537
Part-of: <https://gitlab.gnome.org/GNOME/loupe/-/merge_requests/576>
This commit is contained in:
Abhinandan Thakur 2025-12-31 11:35:54 +05:30 • committed by Marge Bot
parent 1088a7128f
commit f2d4fa6e0d
3 changed files with 73 additions and 3 deletions

View file

@ -244,7 +244,7 @@ mod imp {
}
}
async fn save_overwrite(&self) {
pub(super) async fn save_overwrite(&self) {
let obj = self.obj();
self.save.popdown();
@ -434,7 +434,7 @@ mod imp {
}
}
fn is_save_sensitive(&self) -> bool {
pub(super) fn is_save_sensitive(&self) -> bool {
let obj = self.obj();
self.operations
@ -485,6 +485,20 @@ impl LpEditWindow {
imp.update_save_state(false);
}
pub fn has_unsaved_changes(&self) -> bool {
self.imp().is_save_sensitive()
}
pub fn save_as(&self) {
glib::spawn_future_local(glib::clone!(
#[weak(rename_to=win)]
self,
async move {
win.imp().save_overwrite().await;
}
));
}
pub fn add_operation(&self, operation: glycin::Operation) {
let imp = self.imp();