feat: implement creating a new file
Merge branch 'feat/new-file' from https://gitea.treehouse.systems/fortressia/echidna.git See #20main
commit
4a152416ff
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue