From 507b7b24f9497e643c41f29bc245ff988fe03680 Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Tue, 14 Jan 2025 00:12:53 +0100 Subject: [PATCH] edit_window: Add "Done" menu replacing "Save" button --- src/widgets/edit_window.rs | 18 +++++----- src/widgets/edit_window.ui | 67 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 73 insertions(+), 12 deletions(-) diff --git a/src/widgets/edit_window.rs b/src/widgets/edit_window.rs index 9b58555..0238e75 100644 --- a/src/widgets/edit_window.rs +++ b/src/widgets/edit_window.rs @@ -40,8 +40,6 @@ mod imp { toolbar_view: TemplateChild, #[template_child] cancel: TemplateChild, - #[template_child] - save: TemplateChild, #[property(get, construct_only)] original_image: OnceCell, @@ -57,6 +55,14 @@ mod imp { fn class_init(klass: &mut Self::Class) { Self::bind_template(klass); + + klass.install_action("edit.save-copy", None, |obj, _, _| { + glib::spawn_future_local(glib::clone!( + #[weak] + obj, + async move { obj.imp().save_image().await } + )); + }); } fn instance_init(obj: &glib::subclass::InitializingObject) { @@ -81,14 +87,6 @@ mod imp { obj.window().show_image(); } )); - - self.save.connect_clicked(glib::clone!( - #[weak] - obj, - move |_| { - glib::spawn_future_local(async move { obj.imp().save_image().await }); - } - )); } } diff --git a/src/widgets/edit_window.ui b/src/widgets/edit_window.ui index 666ec1b..54ddf9d 100644 --- a/src/widgets/edit_window.ui +++ b/src/widgets/edit_window.ui @@ -16,9 +16,72 @@ - - _Save + + _Done true + + + + + + none + + + edit.save-copy + + + vertical + + + Save as Copy… + 0 + + + + + Keep original and create a new file + 0 + + + + + + + + + + + + vertical + + + Replace Original… + 0 + + + + + Original image will be moved to the trash + 0 + + + + + + + + + + +