Compare commits
No commits in common. "main" and "feat/save" have entirely different histories.
|
@ -1,15 +0,0 @@
|
|||
# Description
|
||||
|
||||
Please write down a clear and concise description of this Merge Request.
|
||||
|
||||
# Closes
|
||||
|
||||
Please write down the issues that this MR closes.
|
||||
|
||||
# Implementation Insight
|
||||
|
||||
Please write down how did you implement this in a clear and concise manner.
|
||||
|
||||
# TO-DOs
|
||||
|
||||
A list of TO-DOs of things you have did before the MR is undrafted.
|
|
@ -1,15 +1,3 @@
|
|||
---
|
||||
|
||||
name: Bug Report
|
||||
about: Report a bug affecting Echidna Code Editor
|
||||
title: bug:
|
||||
ref: main
|
||||
labels:
|
||||
|
||||
- bug
|
||||
- help needed
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
Please write a clear and concise description of the issue you are getting.
|
|
@ -1,15 +1,3 @@
|
|||
---
|
||||
|
||||
name: Feature Request
|
||||
about: Request a new feature or support that can be implemented into Echidna.
|
||||
title: "feat: "
|
||||
ref: main
|
||||
labels:
|
||||
|
||||
- enhancement
|
||||
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
Please write a clear and concise description of the issue you are getting.
|
|
@ -0,0 +1 @@
|
|||
"clippy::style" = "deny"
|
|
@ -15,11 +15,10 @@
|
|||
<object class="GtkSourceView" id="sourceview">
|
||||
<property name="vexpand">1</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="show-line-numbers">1</property>
|
||||
<property name="show-line-marks">1</property>
|
||||
<property name="buffer">
|
||||
<object class="GtkSourceBuffer"></object>
|
||||
</property>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -24,47 +24,47 @@ impl EchidnaCoreEditor {
|
|||
// Without cloning it, for some reasons the Rust compiler complains about &this.to_imp().sourceview not being IsA<sourceview::View>
|
||||
this_imp.minimap.set_view(&this_imp.sourceview.clone());
|
||||
|
||||
match file {
|
||||
Some(file) => {
|
||||
let file_location = file
|
||||
.location()
|
||||
.expect("file is required to have a location");
|
||||
if file.is_some() {
|
||||
let file = file.unwrap();
|
||||
let file_location = file
|
||||
.location()
|
||||
.expect("file is required to have a location");
|
||||
|
||||
this.set_property("file", &file)
|
||||
.expect("Could not set the 'file' property of EchidnaCoreEditor");
|
||||
this.set_property("file", &file)
|
||||
.expect("Could not set the 'file' property of EchidnaCoreEditor");
|
||||
|
||||
let cancellable = gio::Cancellable::new();
|
||||
let filepath = file_location.path().expect("No filepath");
|
||||
let info = file_location
|
||||
.query_info("*", gio::FileQueryInfoFlags::NONE, Some(&cancellable))
|
||||
.expect("Could not query the info for file");
|
||||
let cancellable = gio::Cancellable::new();
|
||||
let filepath = file_location.path().expect("No filepath");
|
||||
let info = file_location
|
||||
.query_info("*", gio::FileQueryInfoFlags::NONE, Some(&cancellable))
|
||||
.expect("Could not query the info for file");
|
||||
|
||||
let content_type = info
|
||||
.content_type()
|
||||
.expect(format!("It does not seem like {:?} has a type", filepath).as_str());
|
||||
{
|
||||
println!(
|
||||
"Opened {} and found its content type is {}.",
|
||||
"file",
|
||||
content_type.to_string()
|
||||
);
|
||||
let buffer = this_imp.sourceview.buffer().downcast::<Buffer>().expect("Cannot downcast the sourceview's buffer. Maybe the sourceview's buffer is not IsA<sourceview::Buffer>.");
|
||||
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 content_type = info
|
||||
.content_type()
|
||||
.expect(format!("It does not seem like {:?} has a type", filepath).as_str());
|
||||
{
|
||||
println!(
|
||||
"Opened {} and found its content type is {}.",
|
||||
"file",
|
||||
content_type.to_string()
|
||||
);
|
||||
let buffer = this_imp.sourceview.buffer().downcast::<Buffer>().expect("Cannot downcast the sourceview's buffer. Maybe the sourceview's buffer is not IsA<sourceview::Buffer>.");
|
||||
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 => {}
|
||||
}
|
||||
match language {
|
||||
Some(lang) => buffer.set_language(Some(&lang)),
|
||||
None => {}
|
||||
}
|
||||
|
||||
let file_loader: FileLoader = FileLoader::new(&buffer, &file);
|
||||
let file_loader: FileLoader = FileLoader::new(&buffer, &file);
|
||||
|
||||
file_loader.load_async(
|
||||
file_loader.load_async(
|
||||
glib::Priority::default(),
|
||||
Some(&cancellable),
|
||||
|_, _| {},
|
||||
|
@ -74,9 +74,7 @@ impl EchidnaCoreEditor {
|
|||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
this
|
||||
}
|
||||
|
@ -120,10 +118,10 @@ impl EchidnaCoreEditor {
|
|||
|_, _| {},
|
||||
|result| {
|
||||
if result.is_err() {
|
||||
panic!(
|
||||
panic!(format!(
|
||||
"Found an error while saving the file:\n{}",
|
||||
result.err().expect("No error")
|
||||
)
|
||||
))
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
|
@ -15,9 +15,3 @@ impl EchidnaSidebar {
|
|||
glib::Object::new(&[]).expect("Failed to create 'EchidnaSidebar' component.")
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for EchidnaSidebar {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,9 +36,9 @@ impl BuildableImpl for TabLabel {
|
|||
fn add_child(
|
||||
&self,
|
||||
buildable: &Self::Type,
|
||||
_builder: >k::Builder,
|
||||
builder: >k::Builder,
|
||||
child: &glib::Object,
|
||||
_type_: Option<&str>,
|
||||
type_: Option<&str>,
|
||||
) {
|
||||
buildable.prepend(child.downcast_ref::<gtk::Widget>().unwrap());
|
||||
}
|
||||
|
|
|
@ -17,9 +17,8 @@ impl TabLabel {
|
|||
pub fn new<U: IsA<gtk::Widget>>(tab_label: Option<&U>) -> Self {
|
||||
let this: Self = glib::Object::new(&[]).expect("Failed to create 'TabLabel' component.");
|
||||
|
||||
match tab_label {
|
||||
Some(tab_label) => this.prepend(tab_label),
|
||||
None => {}
|
||||
if tab_label.is_some() {
|
||||
this.prepend(tab_label.unwrap());
|
||||
}
|
||||
this
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -67,7 +66,7 @@ impl FileImplementedEditor for super::EchidnaWindow {
|
|||
notebook.prepend_closable_page(
|
||||
&editor_page,
|
||||
Some(&Label::new(Some(
|
||||
file_location
|
||||
&file_location
|
||||
.path()
|
||||
.expect("The file's path is missing")
|
||||
.file_name()
|
||||
|
@ -103,14 +102,6 @@ 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,16 +122,6 @@ 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);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use crate::components::tab_label::TabLabel;
|
||||
use glib::IsA;
|
||||
use gtk::{prelude::*, Widget};
|
||||
use gtk::{prelude::*, Box, Button, Widget};
|
||||
|
||||
pub trait ClosableTabImplementedNotebook {
|
||||
fn prepend_closable_page<T: IsA<Widget>, U: IsA<Widget>>(
|
||||
|
|
Loading…
Reference in New Issue