feat: implement creating a new file

Merge branch 'feat/new-file' from
https://gitea.treehouse.systems/fortressia/echidna.git

See #20
main
Nefo Fortressia 2021-12-28 08:59:21 +07:00
commit 4a152416ff
Signed by: fortressia
GPG Key ID: 6D7972CC76174995
2 changed files with 19 additions and 0 deletions

View File

@ -14,6 +14,7 @@ pub trait FileImplementedEditor {
fn action_open_file(&self);
fn open_file(notebook: &gtk::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(&gtk::Label::new(Some(&"Untitled"))));
}
fn action_save_file(&self) {
let page: EchidnaCoreEditor = self
.get_current_tab()

View File

@ -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);