From e4e226fe81558499eab934aa1750fb24ea2efa6e Mon Sep 17 00:00:00 2001 From: Nefomemes Date: Fri, 22 Oct 2021 10:35:14 +0700 Subject: [PATCH] refactor: put all our own imp::EchidnaEditor methods into EchidnaEditorExt trait --- src/app/imp.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/imp.rs b/src/app/imp.rs index b1877a4..0edfecf 100644 --- a/src/app/imp.rs +++ b/src/app/imp.rs @@ -33,7 +33,10 @@ pub struct EchidnaEditor { pub app_id: &'static str } - +pub trait EchidnaEditorExt { + fn action_open_file(window: ApplicationWindow, app: super::EchidnaEditor, action: &SimpleAction, variant: Option<&glib::Variant>, notebook: gtk::Notebook); + fn open_file(notebook: >k::Notebook, file: gio::File); +} @@ -47,13 +50,13 @@ impl ObjectSubclass for EchidnaEditor { Self { name: "Echidna Code Editor", app_id: "land.echidna.editor" - } + } } } -impl EchidnaEditor { +impl EchidnaEditorExt for EchidnaEditor { /* Open a file and put it in an editor and the opened files bar. @@ -71,7 +74,7 @@ impl EchidnaEditor { Perhaps some of the last points should not be implemented in this function but rather in another function that keeps track of every files. */ - fn action_open_file(window: ApplicationWindow, app: &Self, action: &SimpleAction, variant: Option<&glib::Variant>){ + fn action_open_file(window: ApplicationWindow, app: super::EchidnaEditor, _action: &SimpleAction, variant: Option<&glib::Variant>, notebook: gtk::Notebook){ let dialog: FileChooserDialog = FileChooserDialog::new(Some("Open a file"), Some(&window), @@ -110,7 +113,7 @@ impl EchidnaEditor { } - fn open_file(file: gio::File){ + fn open_file(notebook: >k::Notebook, file: gio::File){ let cancellable = Cancellable::new(); let filepath = file.path(); let file_info_result = file.query_info(