style: format codebase with cargo fmt
parent
5e1de2ec96
commit
48f63a88ea
|
@ -2,36 +2,34 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use gtk::subclass::prelude::*;
|
use gtk::subclass::prelude::*;
|
||||||
use gtk::CompositeTemplate;
|
use gtk::CompositeTemplate;
|
||||||
|
|
||||||
#[derive(Default, CompositeTemplate)]
|
#[derive(Default, CompositeTemplate)]
|
||||||
#[template(file = "./editor.ui")]
|
#[template(file = "./editor.ui")]
|
||||||
pub struct EchidnaCoreEditor {
|
pub struct EchidnaCoreEditor {
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub minimap: TemplateChild<sourceview::Map>,
|
pub minimap: TemplateChild<sourceview::Map>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub sourceview: TemplateChild<sourceview::View>
|
pub sourceview: TemplateChild<sourceview::View>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[glib::object_subclass]
|
#[glib::object_subclass]
|
||||||
impl ObjectSubclass for EchidnaCoreEditor {
|
impl ObjectSubclass for EchidnaCoreEditor {
|
||||||
const NAME: &'static str = "EchidnaCoreEditor";
|
const NAME: &'static str = "EchidnaCoreEditor";
|
||||||
type Type = super::EchidnaCoreEditor;
|
type Type = super::EchidnaCoreEditor;
|
||||||
type ParentType = gtk::Box;
|
type ParentType = gtk::Box;
|
||||||
|
|
||||||
fn class_init(class: &mut Self::Class) {
|
fn class_init(class: &mut Self::Class) {
|
||||||
Self::bind_template(class);
|
Self::bind_template(class);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||||
obj.init_template();
|
obj.init_template();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ObjectImpl for EchidnaCoreEditor {}
|
impl ObjectImpl for EchidnaCoreEditor {}
|
||||||
impl WidgetImpl for EchidnaCoreEditor {}
|
impl WidgetImpl for EchidnaCoreEditor {}
|
||||||
impl BoxImpl for EchidnaCoreEditor {}
|
impl BoxImpl for EchidnaCoreEditor {}
|
||||||
|
|
||||||
|
|
|
@ -13,19 +13,13 @@ glib::wrapper! {
|
||||||
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
|
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
impl EchidnaCoreEditor {
|
impl EchidnaCoreEditor {
|
||||||
|
|
||||||
|
|
||||||
pub fn new<P: glib::IsA<sourceview::File>>(file: Option<&P>) -> Self {
|
pub fn new<P: glib::IsA<sourceview::File>>(file: Option<&P>) -> Self {
|
||||||
let this: Self =
|
let this: Self =
|
||||||
glib::Object::new(&[]).expect("Failed to create 'EchidnaCoreEditor' component.");
|
glib::Object::new(&[]).expect("Failed to create 'EchidnaCoreEditor' component.");
|
||||||
let this_imp = this.to_imp();
|
let this_imp = this.to_imp();
|
||||||
// Without cloning it, for some reasons the Rust compiler complains about &this.to_imp().sourceview not being IsA<sourceview::View>
|
// Without cloning it, for some reasons the Rust compiler complains about &this.to_imp().sourceview not being IsA<sourceview::View>
|
||||||
this_imp
|
this_imp.minimap.set_view(&this_imp.sourceview.clone());
|
||||||
.minimap
|
|
||||||
.set_view(&this_imp.sourceview.clone());
|
|
||||||
|
|
||||||
if file.is_some() {
|
if file.is_some() {
|
||||||
let file = file.unwrap();
|
let file = file.unwrap();
|
||||||
|
@ -49,7 +43,6 @@ impl EchidnaCoreEditor {
|
||||||
let language_manager = LanguageManager::new();
|
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);
|
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 {
|
match language {
|
||||||
Some(lang) => buffer.set_language(Some(&lang)),
|
Some(lang) => buffer.set_language(Some(&lang)),
|
||||||
None => {}
|
None => {}
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
pub mod app;
|
pub mod app;
|
||||||
|
pub mod editor;
|
||||||
pub mod sidebar;
|
pub mod sidebar;
|
||||||
pub mod window;
|
pub mod window;
|
||||||
pub mod editor;
|
|
Loading…
Reference in New Issue