diff --git a/src/components/window/file.rs b/src/components/window/file.rs index 4ff4404..71e655c 100644 --- a/src/components/window/file.rs +++ b/src/components/window/file.rs @@ -14,6 +14,7 @@ pub trait FileImplementedEditor { fn action_open_file(&self); fn open_file(notebook: >k::Notebook, file: gio::File); fn action_save_file_as(&self); + fn action_new_file(&self); fn action_save_file(&self); } @@ -102,6 +103,14 @@ impl FileImplementedEditor for super::EchidnaWindow { })); } + fn action_new_file(&self) { + let editor_page = EchidnaCoreEditor::new(None); + + self.to_imp() + .notebook + .prepend_closable_page(&editor_page, Some(>k::Label::new(Some(&"Untitled")))); + } + fn action_save_file(&self) { let page: EchidnaCoreEditor = self .get_current_tab() diff --git a/src/components/window/menubar.rs b/src/components/window/menubar.rs index da81ac0..ed080aa 100644 --- a/src/components/window/menubar.rs +++ b/src/components/window/menubar.rs @@ -122,6 +122,16 @@ impl MenubarImplementedEditor for EchidnaWindow { window.action_save_file_as(); })); } + { + let action_new_file = SimpleAction::new("new-file", None); + + self.add_action(&action_new_file); + + action_new_file.connect_activate(clone!(@weak self as window => + move |_action, _variant| { + window.action_new_file(); + })); + } { let action_save = SimpleAction::new("save", None);