Skip to content

Commit

Permalink
GUI creation of a new recipe.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joris Rehm committed Jun 6, 2017
1 parent 5e5960a commit 8eab57d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
32 changes: 27 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,40 @@ fn main_gui(data : Rc<RefCell<Data>>) {
Inhibit(false)
});

setup(window.clone(), data.clone());
let notebook = gtk::Notebook::new();
window.add(&notebook);

setup(&notebook, &data);

window.show_all();
gtk::main();
}

fn setup(window : gtk::Window, data : Rc<RefCell<Data>>) {
fn setup(notebook : &gtk::Notebook, data : &Rc<RefCell<Data>>) {

let recipe_zone = gtk::Grid::new();
notebook.append_page(&recipe_zone, Some(&gtk::Label::new("Recettes")));
recipe_zone.set_orientation(gtk::Orientation::Vertical);

let new_but = gtk::Button::new_with_label("+");
recipe_zone.add(&new_but);

let notebook_clone = notebook.clone();
let data_clone = data.clone();
let recipe_zone_clone = recipe_zone.clone();
new_but.connect_clicked(move |_| {
data_clone.borrow_mut().add_recipe( & Recipe::new(
"recette",
"",
));
recipe_zone_clone.destroy();
setup(&notebook_clone, &data_clone);
});

let notebook = gtk::Notebook::new();
window.add(&notebook);

let book_pane = gtk::Paned::new(gtk::Orientation::Horizontal);
book_pane.set_wide_handle(true);
notebook.append_page(&book_pane, Some(&gtk::Label::new("Recettes")));
recipe_zone.add(&book_pane);

let recipies_list = gtk::ListBox::new();

Expand Down Expand Up @@ -79,6 +99,8 @@ fn setup(window : gtk::Window, data : Rc<RefCell<Data>>) {
});

}

recipe_zone.show_all();
}

fn show_recipe_content(data : &Rc<RefCell<Data>>, book_pane : &gtk::Paned, recipe_id : Id) {
Expand Down
7 changes: 6 additions & 1 deletion todo_and_done.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Data model for planning with days, lunchs.
GUI edition of recipe: renaming of recipe. Update name in the left pane
recipes list.

Refactoring: think about a better gui architecture

GUI grocery section deletion.
GUI grocery section renaming.
GUI grocery section creation.
Expand All @@ -38,14 +40,17 @@ GUI ingredient deletion
GUI ingredient renaming
GUI ingredient creation

Refactoring: separate GUI about recipe

GUI deletion of recipe.

GUI creation of a new recipe.


DONE
=====

GUI creation of a new recipe.

GUI edition of recipe: renaming of recipe.

GUI edition of recipe: ingredient removing.
Expand Down

0 comments on commit 8eab57d

Please sign in to comment.