diff --git a/src/components/editor/imp.rs b/src/components/editor/imp.rs index fc37cc2..5c95c86 100644 --- a/src/components/editor/imp.rs +++ b/src/components/editor/imp.rs @@ -2,36 +2,34 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - use gtk::prelude::*; - use gtk::subclass::prelude::*; - use gtk::CompositeTemplate; - - #[derive(Default, CompositeTemplate)] - #[template(file = "./editor.ui")] - pub struct EchidnaCoreEditor { - #[template_child] - pub minimap: TemplateChild, - #[template_child] - pub sourceview: TemplateChild - +use gtk::prelude::*; +use gtk::subclass::prelude::*; +use gtk::CompositeTemplate; + +#[derive(Default, CompositeTemplate)] +#[template(file = "./editor.ui")] +pub struct EchidnaCoreEditor { + #[template_child] + pub minimap: TemplateChild, + #[template_child] + pub sourceview: TemplateChild, } - - #[glib::object_subclass] - impl ObjectSubclass for EchidnaCoreEditor { - const NAME: &'static str = "EchidnaCoreEditor"; - type Type = super::EchidnaCoreEditor; - type ParentType = gtk::Box; - - fn class_init(class: &mut Self::Class) { - Self::bind_template(class); - } - - fn instance_init(obj: &glib::subclass::InitializingObject) { - obj.init_template(); - } - } - - impl ObjectImpl for EchidnaCoreEditor {} - impl WidgetImpl for EchidnaCoreEditor {} - impl BoxImpl for EchidnaCoreEditor {} - \ No newline at end of file + +#[glib::object_subclass] +impl ObjectSubclass for EchidnaCoreEditor { + const NAME: &'static str = "EchidnaCoreEditor"; + type Type = super::EchidnaCoreEditor; + type ParentType = gtk::Box; + + fn class_init(class: &mut Self::Class) { + Self::bind_template(class); + } + + fn instance_init(obj: &glib::subclass::InitializingObject) { + obj.init_template(); + } +} + +impl ObjectImpl for EchidnaCoreEditor {} +impl WidgetImpl for EchidnaCoreEditor {} +impl BoxImpl for EchidnaCoreEditor {} diff --git a/src/components/editor/mod.rs b/src/components/editor/mod.rs index 8b18912..e743455 100644 --- a/src/components/editor/mod.rs +++ b/src/components/editor/mod.rs @@ -13,19 +13,13 @@ glib::wrapper! { @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable; } - - impl EchidnaCoreEditor { - - pub fn new>(file: Option<&P>) -> Self { let this: Self = glib::Object::new(&[]).expect("Failed to create 'EchidnaCoreEditor' component."); let this_imp = this.to_imp(); // Without cloning it, for some reasons the Rust compiler complains about &this.to_imp().sourceview not being IsA - this_imp - .minimap - .set_view(&this_imp.sourceview.clone()); + this_imp.minimap.set_view(&this_imp.sourceview.clone()); if file.is_some() { let file = file.unwrap(); @@ -49,7 +43,6 @@ impl EchidnaCoreEditor { let language_manager = LanguageManager::new(); let language = language_manager.guess_language(Some(&info.name().to_str().expect("Could not open the file because its name is not supported by Unicode.")), None); - match language { Some(lang) => buffer.set_language(Some(&lang)), None => {} diff --git a/src/components/mod.rs b/src/components/mod.rs index 0317bce..6679c17 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -3,6 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ pub mod app; +pub mod editor; pub mod sidebar; pub mod window; -pub mod editor; \ No newline at end of file