Skip to content

Commit

Permalink
fix undo functionality (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
nnyyxxxx authored Oct 15, 2024
1 parent 9557206 commit 2ef193d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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<RefCell<HashMap<(String, String), String>>> {
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ fn undo_changes(gui: Rc<RefCell<gui::ConfigGUI>>) {
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",
Expand Down

0 comments on commit 2ef193d

Please sign in to comment.