From 2ef193d8d1317bf6354feadcb6f917e18088162f Mon Sep 17 00:00:00 2001 From: nyx Date: Tue, 15 Oct 2024 19:14:58 -0400 Subject: [PATCH] fix undo functionality (#35) --- src/gui.rs | 14 ++++++++++++++ src/main.rs | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/gui.rs b/src/gui.rs index 9ae78da..b8b08f8 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -385,6 +385,18 @@ impl ConfigGUI { self.config_widgets.clear(); self.content_box.set_visible(true); + while let Some(child) = self.stack.first_child() { + self.stack.remove(&child); + } + + while let Some(child) = self.content_box.first_child() { + self.content_box.remove(&child); + } + + self.sidebar = StackSidebar::new(); + self.sidebar.set_stack(&self.stack); + self.sidebar.set_width_request(200); + self.content_box.append(&self.sidebar); self.content_box.append(&self.stack); @@ -426,6 +438,8 @@ impl ConfigGUI { widget.load_config(config, category, self.changed_options.clone()); } } + + self.changed_options.borrow_mut().clear(); } pub fn get_changes(&self) -> Rc>> { diff --git a/src/main.rs b/src/main.rs index 10e52b0..3dd805c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -136,6 +136,8 @@ fn undo_changes(gui: Rc>) { let parsed_config = parse_config(&config_str); gui_ref.load_config(&parsed_config); + gui_ref.get_changes().borrow_mut().clear(); + if let Err(e) = fs::remove_file(&backup_path) { gui_ref.custom_error_popup( "Backup Deletion Failed",