Skip to content

Commit

Permalink
GUI deletion of recipe.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joris Rehm committed Jun 6, 2017
1 parent 8eab57d commit 93dca91
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ impl Data {
self.book.recipes.insert(recipe.id, recipe.clone());
}

pub fn remove_recipe(&mut self, id : Id) {
self.book.recipes.remove(&id);
}

pub fn get_recipe(&self, id : Id) -> Option<&Recipe> {
self.book.recipes.get(&id)
}
Expand Down
13 changes: 13 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ fn show_recipe_content(data : &Rc<RefCell<Data>>, book_pane : &gtk::Paned, recip
show_recipe_edit(&data_clone, &book_pane_clone);
});

// Delete Button
let del_but = gtk::Button::new_with_label("Supprimer");
grid.add(&del_but);

let book_pane_clone = book_pane.clone();
let data_clone = data.clone();
del_but.connect_clicked(move |_| {
data_clone.borrow_mut().remove_recipe(recipe_id);
book_pane_clone.get_child2().unwrap().destroy();
book_pane_clone.add2(&gtk::Label::new("Recette suprimée"));
book_pane_clone.show_all();
});

// Ingredients list
grid.add(&gtk::Label::new("Ingrédients"));

Expand Down
11 changes: 7 additions & 4 deletions todo_and_done.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ Data model for grocery list.
Data model for planning with days, lunchs.

GUI edition of recipe: renaming of recipe. Update name in the left pane
recipes list.
recipes list. Same thing for recipe deletion.

Refactoring: think about a better gui architecture
Refactoring: think about a better gui architecture with object that contains
widget and related data clone.

Do a mockup with glade in order to do a more ergonomic et nicer gui layout.

GUI grocery section deletion.
GUI grocery section renaming.
Expand All @@ -42,13 +45,13 @@ GUI ingredient creation

Refactoring: separate GUI about recipe

GUI deletion of recipe.



DONE
=====

GUI deletion of recipe.

GUI creation of a new recipe.

GUI edition of recipe: renaming of recipe.
Expand Down

0 comments on commit 93dca91

Please sign in to comment.