From e4bb97140a71c03238d4ed5ca88ae46eb6601847 Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Fri, 17 Jan 2025 12:35:43 +0100 Subject: [PATCH] edit_window: Return to image view after saving --- src/widgets/edit_window.rs | 10 +++++++++- src/widgets/window.rs | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/widgets/edit_window.rs b/src/widgets/edit_window.rs index cd9b01b..9c0f5c0 100644 --- a/src/widgets/edit_window.rs +++ b/src/widgets/edit_window.rs @@ -127,7 +127,9 @@ mod imp { log::error!("{}", err); } Ok(new_file) => { - self.save(current_file, new_file).await; + if self.save(current_file, new_file.clone()).await { + obj.window().show_specific_image(new_file); + } } } } @@ -177,6 +179,8 @@ mod imp { ), ErrorType::General, ); + } else { + obj.window().show_specific_image(current_file); } } } @@ -184,6 +188,10 @@ mod imp { } } + #[must_use] + /// Saves image with operations applies + /// + /// Returns `true` if editing and saving was successful async fn save(&self, current_file: gio::File, new_file: gio::File) -> bool { let obj = self.obj(); let editor = glycin::Editor::new(current_file); diff --git a/src/widgets/window.rs b/src/widgets/window.rs index d329c9b..8e586ad 100644 --- a/src/widgets/window.rs +++ b/src/widgets/window.rs @@ -247,6 +247,11 @@ impl LpWindow { .set_visible_child(&*self.imp().image_window); } + pub fn show_specific_image(&self, file: gio::File) { + self.image_view().set_images_from_files(vec![file]); + self.show_image(); + } + pub fn show_edit(&self) { if let Some(image) = self.image_view().current_image() { let edit_child = &*self.imp().edit_window_child;