refactor: rewrite codebase to Rust #8

Merged
fortressia merged 1 commits from ref/rust into main 2021-11-03 09:58:48 +00:00
fortressia commented 2021-10-22 03:45:53 +00:00 (Migrated from gitlab.com)

Closes #7. Partially implements #2.

Additionally, this adds a barebones editor and semi-working menubar.

Todo:

  • Complimentary menus (open GitHub GitLab repo, about dialog, etc)
  • Open file in a new editor. (done)
  • Save file in editor.
  • Implement barebones opening and saving file with GtkSourceView's native opening and saving functionality.
    • Open file
    • Saving file as
  • Close editor. Will be implemented later on.
Closes #7. Partially implements #2. Additionally, this adds a barebones editor and semi-working menubar. Todo: - [x] Complimentary menus (open ~~GitHub~~ GitLab repo, about dialog, etc) - ~~Open file in a new editor. (done)~~ - ~~Save file in editor.~~ - [x] Implement barebones opening and saving file with GtkSourceView's native opening and saving functionality. - [x] Open file - [x] Saving file as - ~~Close editor.~~ Will be implemented later on.
fortressia commented 2021-10-22 03:50:13 +00:00 (Migrated from gitlab.com)

I know you hate coding in Rust, vierofernando on GitHub. What about just reading Rust code?

Send code review plz.

I know you hate coding in Rust, [vierofernando on GitHub](https://github.com/vierofernando). What about just reading Rust code? Send code review plz.
fortressia commented 2021-10-26 02:05:10 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
fortressia commented 2021-10-26 02:17:58 +00:00 (Migrated from gitlab.com)

assigned to @FortressNordlys

assigned to @FortressNordlys
fortressia commented 2021-10-26 02:22:05 +00:00 (Migrated from gitlab.com)

marked the task Open file in a new editor. as completed

marked the task **Open file in a new editor.** as completed
fortressia commented 2021-10-26 02:32:13 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
fortressia commented 2021-10-26 02:33:15 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
VoltrexMaster commented 2021-10-26 03:00:58 +00:00 (Migrated from gitlab.com)
impl ObjectImpl for EchidnaEditor {}
```suggestion:-4+0 impl ObjectImpl for EchidnaEditor {} ```
VoltrexMaster commented 2021-10-26 03:00:59 +00:00 (Migrated from gitlab.com)
impl ApplicationImpl for EchidnaEditor {
    fn activate(&self, app: &Self::Type) {
        let window = EchidnaWindow::new(app);

        window.setup_menubar();
        window.set_application(Some(app));

        window.present();
    }
}
```suggestion:-13+0 impl ApplicationImpl for EchidnaEditor { fn activate(&self, app: &Self::Type) { let window = EchidnaWindow::new(app); window.setup_menubar(); window.set_application(Some(app)); window.present(); } } ```
VoltrexMaster commented 2021-10-26 03:00:59 +00:00 (Migrated from gitlab.com)
    pub struct EchidnaEditor(ObjectSubclass<imp::EchidnaEditor>)
        @extends gio::Application, gtk::Application,
        @implements gio::ActionGroup, gio::ActionMap;
```suggestion:-0+0 pub struct EchidnaEditor(ObjectSubclass<imp::EchidnaEditor>) @extends gio::Application, gtk::Application, @implements gio::ActionGroup, gio::ActionMap; ```
VoltrexMaster commented 2021-10-26 03:00:59 +00:00 (Migrated from gitlab.com)
use gtk::{ Application };
```suggestion:-2+0 use gtk::{ Application }; ```
VoltrexMaster commented 2021-10-26 03:00:59 +00:00 (Migrated from gitlab.com)
}

#[glib::object_subclass]
```suggestion:-5+0 } #[glib::object_subclass] ```
VoltrexMaster commented 2021-10-26 03:00:59 +00:00 (Migrated from gitlab.com)
    fn new() -> Self {
        Self {
            name: "Echidna Code Editor",
            app_id: "land.echidna.editor"
        }
    }
```suggestion:-5+0 fn new() -> Self { Self { name: "Echidna Code Editor", app_id: "land.echidna.editor" } } ```
VoltrexMaster commented 2021-10-26 03:00:59 +00:00 (Migrated from gitlab.com)
            ("flags", &gio::ApplicationFlags::empty())
        ]);

        match object {
            Ok(o) => o,
            Err(e) => panic!("Error in making EchidnaApplication {}", e)
```suggestion:-5+0 ("flags", &gio::ApplicationFlags::empty()) ]); match object { Ok(o) => o, Err(e) => panic!("Error in making EchidnaApplication {}", e) ```
VoltrexMaster commented 2021-10-26 03:00:59 +00:00 (Migrated from gitlab.com)
use glib::{ clone };
```suggestion:-2+0 use glib::{ clone }; ```
VoltrexMaster commented 2021-10-26 03:00:59 +00:00 (Migrated from gitlab.com)
use gio::{ Cancellable };
```suggestion:-3+0 use gio::{ Cancellable }; ```
VoltrexMaster commented 2021-10-26 03:00:59 +00:00 (Migrated from gitlab.com)
        fn action_open_file/*<P: IsA<gtk::Application>>*/(window: Self) {

            let dialog: FileChooserDialog = FileChooserDialog::new(Some("Open a file"), 
                Some(&window), FileChooserAction::Open,
                &[("Cancel", ResponseType::Cancel), ("Open", ResponseType::Accept)]);

            dialog.set_visible(true);
```suggestion:-9+0 fn action_open_file/*<P: IsA<gtk::Application>>*/(window: Self) { let dialog: FileChooserDialog = FileChooserDialog::new(Some("Open a file"), Some(&window), FileChooserAction::Open, &[("Cancel", ResponseType::Cancel), ("Open", ResponseType::Accept)]); dialog.set_visible(true); ```
VoltrexMaster commented 2021-10-26 03:01:00 +00:00 (Migrated from gitlab.com)
            dialog.connect_response(clone!(@weak window, => move |dialog, response| {
                if response == ResponseType::Accept {

                    let file_option = dialog.file();
           
                    match file_option {
                        Some(file) => {
                            dialog.destroy();

                            Self::open_file(
                                &super::imp::EchidnaWindow::from_instance(&window).notebook,
                                file);

                        },
                        None => {}
                    }                                                      
                } else if response == ResponseType::Cancel {
                    dialog.destroy();
                }
            }));
    }
```suggestion:-23+0 dialog.connect_response(clone!(@weak window, => move |dialog, response| { if response == ResponseType::Accept { let file_option = dialog.file(); match file_option { Some(file) => { dialog.destroy(); Self::open_file( &super::imp::EchidnaWindow::from_instance(&window).notebook, file); }, None => {} } } else if response == ResponseType::Cancel { dialog.destroy(); } })); } ```
fortressia commented 2021-10-26 07:56:25 +00:00 (Migrated from gitlab.com)

Honestly, why not just remove the bracket?

Honestly, why not just remove the bracket?
fortressia commented 2021-10-26 09:49:09 +00:00 (Migrated from gitlab.com)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/EchidnaHQ/Echidna/-/merge_requests/8/diffs?diff_id=267573986&start_sha=52d5b5e4868520b0b6cd2f7b00fcefa8bd328c17#684394d82509240b1c4638be83f46304ea27050b_42_32)
fortressia commented 2021-10-26 09:49:09 +00:00 (Migrated from gitlab.com)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/EchidnaHQ/Echidna/-/merge_requests/8/diffs?diff_id=267573986&start_sha=52d5b5e4868520b0b6cd2f7b00fcefa8bd328c17#684394d82509240b1c4638be83f46304ea27050b_12_10)
fortressia commented 2021-10-26 09:49:10 +00:00 (Migrated from gitlab.com)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/EchidnaHQ/Echidna/-/merge_requests/8/diffs?diff_id=267573986&start_sha=52d5b5e4868520b0b6cd2f7b00fcefa8bd328c17#af5f738c123f023da5f3aa5785d24eda45be6848_7_5)
fortressia commented 2021-10-26 09:49:10 +00:00 (Migrated from gitlab.com)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/EchidnaHQ/Echidna/-/merge_requests/8/diffs?diff_id=267573986&start_sha=52d5b5e4868520b0b6cd2f7b00fcefa8bd328c17#af5f738c123f023da5f3aa5785d24eda45be6848_17_5)
fortressia commented 2021-10-26 09:49:10 +00:00 (Migrated from gitlab.com)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/EchidnaHQ/Echidna/-/merge_requests/8/diffs?diff_id=267573986&start_sha=52d5b5e4868520b0b6cd2f7b00fcefa8bd328c17#af5f738c123f023da5f3aa5785d24eda45be6848_58_18)
fortressia commented 2021-10-26 09:49:10 +00:00 (Migrated from gitlab.com)

added 4 commits

  • 211f2330 - style(.ui): add missing license header to menu.ui
  • 4d238608 - chore(.ui): remove ui/window.ui
  • 8c05235e - refactor: simplify FileImplementedEditor::action_open_file()
  • 6c6afa74 - style: format source files with Rustfmt tooling

Compare with previous version

added 4 commits <ul><li>211f2330 - style(.ui): add missing license header to menu.ui</li><li>4d238608 - chore(.ui): remove ui/window.ui</li><li>8c05235e - refactor: simplify FileImplementedEditor::action_open_file()</li><li>6c6afa74 - style: format source files with Rustfmt tooling</li></ul> [Compare with previous version](/EchidnaHQ/Echidna/-/merge_requests/8/diffs?diff_id=267573986&start_sha=52d5b5e4868520b0b6cd2f7b00fcefa8bd328c17)
fortressia commented 2021-10-27 05:02:10 +00:00 (Migrated from gitlab.com)

Resolved by 6c6afa74.

Resolved by 6c6afa74.
fortressia commented 2021-10-27 05:02:33 +00:00 (Migrated from gitlab.com)

Resolved by 6c6afa74.

Resolved by 6c6afa74.
fortressia commented 2021-10-27 05:02:55 +00:00 (Migrated from gitlab.com)

Resolved by 6c6afa74.

Resolved by 6c6afa74.
fortressia commented 2021-10-27 05:03:03 +00:00 (Migrated from gitlab.com)

Resolved by 6c6afa74.

Resolved by 6c6afa74.
fortressia commented 2021-10-27 05:03:32 +00:00 (Migrated from gitlab.com)

Resolved by 6c6afa74. Using Rustfmt.

Resolved by 6c6afa74. Using Rustfmt.
fortressia commented 2021-10-27 05:09:42 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
fortressia commented 2021-10-27 06:39:42 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
fortressia commented 2021-10-28 10:09:26 +00:00 (Migrated from gitlab.com)

added 2 commits

  • fc275837 - fix: open_file listener passing window not as a ref
  • 0a137509 - chore: move to EchidnaHQ's own sourceview bindings

Compare with previous version

added 2 commits <ul><li>fc275837 - fix: open_file listener passing window not as a ref</li><li>0a137509 - chore: move to EchidnaHQ&#39;s own sourceview bindings</li></ul> [Compare with previous version](/EchidnaHQ/Echidna/-/merge_requests/8/diffs?diff_id=269153573&start_sha=6c6afa740ff70e3fcfca4a9958e09bfad8a81504)
fortressia commented 2021-10-28 10:20:42 +00:00 (Migrated from gitlab.com)

added 3 commits

  • ffdc612e - feat: implement barebone features for Sidebar widget
  • 6144feb8 - refactor: move editor code to a separate EchidnaCoreEditor widget
  • 6ad708cf - feat: use EchidnaSidebar in window ui file

Compare with previous version

added 3 commits <ul><li>ffdc612e - feat: implement barebone features for Sidebar widget</li><li>6144feb8 - refactor: move editor code to a separate EchidnaCoreEditor widget</li><li>6ad708cf - feat: use EchidnaSidebar in window ui file</li></ul> [Compare with previous version](/EchidnaHQ/Echidna/-/merge_requests/8/diffs?diff_id=269162789&start_sha=0a137509707dd80c80d17cf0569a0d5ddabf5722)
fortressia commented 2021-10-28 10:21:02 +00:00 (Migrated from gitlab.com)

marked the task Implement opening and saving file with GtkSourceView's native opening and saving functionality. as completed

marked the task **Implement opening and saving file with GtkSourceView's native opening and saving functionality.** as completed
fortressia commented 2021-10-28 10:21:05 +00:00 (Migrated from gitlab.com)

marked the task Implement opening and saving file with GtkSourceView's native opening and saving functionality. as incomplete

marked the task **Implement opening and saving file with GtkSourceView's native opening and saving functionality.** as incomplete
fortressia commented 2021-10-28 10:21:21 +00:00 (Migrated from gitlab.com)

marked this merge request as draft

marked this merge request as **draft**
fortressia commented 2021-10-28 10:22:32 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
fortressia commented 2021-10-28 10:24:33 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
fortressia commented 2021-10-28 10:25:12 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
fortressia commented 2021-10-30 04:39:04 +00:00 (Migrated from gitlab.com)

added 3 commits

  • 5e1de2ec - refactor: remove unused borrows in menubar.rs
  • 48f63a88 - style: format codebase with cargo fmt
  • 839b3d5b - feat: implement scrollbar for editor

Compare with previous version

added 3 commits <ul><li>5e1de2ec - refactor: remove unused borrows in menubar.rs</li><li>48f63a88 - style: format codebase with cargo fmt</li><li>839b3d5b - feat: implement scrollbar for editor</li></ul> [Compare with previous version](/EchidnaHQ/Echidna/-/merge_requests/8/diffs?diff_id=270336928&start_sha=6ad708cfc1a2537a3cad5d25e16d97c7acf606fd)
fortressia commented 2021-10-30 04:45:10 +00:00 (Migrated from gitlab.com)

changed this line in version 6 of the diff

changed this line in [version 6 of the diff](/EchidnaHQ/Echidna/-/merge_requests/8/diffs?diff_id=270337335&start_sha=839b3d5bb0b54fa4583c0f144bc256059d79c9be#ba04705a7ba98a014e5324909195165d4556a131_10_10)
fortressia commented 2021-10-30 04:45:10 +00:00 (Migrated from gitlab.com)

added 1 commit

  • 5945c06e - style: separate @extends and @implements into separate lines

Compare with previous version

added 1 commit <ul><li>5945c06e - style: separate @extends and @implements into separate lines</li></ul> [Compare with previous version](/EchidnaHQ/Echidna/-/merge_requests/8/diffs?diff_id=270337335&start_sha=839b3d5bb0b54fa4583c0f144bc256059d79c9be)
fortressia commented 2021-10-30 04:48:31 +00:00 (Migrated from gitlab.com)

By default, Rustfmt adds commas to the end. If we want to enforce no unnecessary commas, then we need to add a configuration that disables it.

By default, Rustfmt adds commas to the end. If we want to enforce no unnecessary commas, then we need to add a configuration that disables it.
fortressia commented 2021-10-30 04:50:25 +00:00 (Migrated from gitlab.com)

AAAGH, I forgot that @string mentions people.

Sorry if anyone got annoyed by the mention.

AAAGH, I forgot that `@string` mentions people. Sorry if anyone got annoyed by the mention.
fortressia commented 2021-10-30 05:13:54 +00:00 (Migrated from gitlab.com)

But eh, the Rust formatting convention uses trailing commas for matches and multi-line calls.

But eh, the Rust formatting convention uses trailing commas for [matches](https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/expressions.md#match) and [multi-line calls](https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/expressions.md#multi-line-calls).
fortressia commented 2021-10-30 05:14:27 +00:00 (Migrated from gitlab.com)

Resolving this. We should just follow the Rust formatting convention.

Resolving this. We should just follow the Rust formatting convention.
fortressia commented 2021-10-31 09:58:34 +00:00 (Migrated from gitlab.com)

added 3 commits

  • 12961576 - refactor: split action declarations into separate brackets
  • b54780e4 - feat: implement EchidnaWindow::to_imp()
  • 390485b3 - feat: implement win.save-file-as action

Compare with previous version

added 3 commits <ul><li>12961576 - refactor: split action declarations into separate brackets</li><li>b54780e4 - feat: implement EchidnaWindow::to_imp()</li><li>390485b3 - feat: implement win.save-file-as action</li></ul> [Compare with previous version](/EchidnaHQ/Echidna/-/merge_requests/8/diffs?diff_id=270468132&start_sha=5945c06ed87140ed8be887871a8d5f8c551e7067)
fortressia commented 2021-10-31 09:59:19 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
fortressia commented 2021-10-31 09:59:52 +00:00 (Migrated from gitlab.com)

added 1 commit

  • cc4811b0 - chore: add extensions to the barebone sidebar

Compare with previous version

added 1 commit <ul><li>cc4811b0 - chore: add extensions to the barebone sidebar</li></ul> [Compare with previous version](/EchidnaHQ/Echidna/-/merge_requests/8/diffs?diff_id=270468264&start_sha=390485b3b18e1cd361a3d330dc2a1023e4289181)
fortressia commented 2021-10-31 10:01:05 +00:00 (Migrated from gitlab.com)

added 1 commit

  • d68a8a89 - style: format files with Rustfmt

Compare with previous version

added 1 commit <ul><li>d68a8a89 - style: format files with Rustfmt</li></ul> [Compare with previous version](/EchidnaHQ/Echidna/-/merge_requests/8/diffs?diff_id=270468386&start_sha=cc4811b01b4aaa38abbe2311b73e2ad0e84b0325)
fortressia commented 2021-10-31 10:25:15 +00:00 (Migrated from gitlab.com)

Can't merge. The lines have changed so much.

Can't merge. The lines have changed so much.
fortressia commented 2021-10-31 10:25:19 +00:00 (Migrated from gitlab.com)

resolved all threads

resolved all threads
fortressia commented 2021-10-31 10:25:41 +00:00 (Migrated from gitlab.com)

marked this merge request as ready

marked this merge request as **ready**
fortressia commented 2021-10-31 10:26:09 +00:00 (Migrated from gitlab.com)

requested review from @VoltrexMaster

requested review from @VoltrexMaster
fortressia commented 2021-10-31 10:26:47 +00:00 (Migrated from gitlab.com)

@VoltrexMaster Hey, can you give me another review, please? And by review, not just some style changes.

Let's get this merged.

@VoltrexMaster Hey, can you give me another review, please? And by review, not just some style changes. Let's get this merged.
fortressia commented 2021-11-01 06:57:44 +00:00 (Migrated from gitlab.com)

added 2 commits

  • 9594ed65 - style: format files with Rustfmt
  • 1b9f20b6 - refactor: switch to .expect() from match

Compare with previous version

added 2 commits <ul><li>9594ed65 - style: format files with Rustfmt</li><li>1b9f20b6 - refactor: switch to .expect() from match</li></ul> [Compare with previous version](/EchidnaHQ/Echidna/-/merge_requests/8/diffs?diff_id=270648835&start_sha=d68a8a89946380eba5485b0afdcef50344391aac)
fortressia commented 2021-11-03 09:58:48 +00:00 (Migrated from gitlab.com)

mentioned in commit 70b8a456e5

mentioned in commit 70b8a456e5ba42feb6a81282964e1985e08c6b9f
fortressia commented 2021-11-10 12:22:13 +00:00 (Migrated from gitlab.com)

mentioned in issue #2

mentioned in issue #2
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: fortressia/echidna#8
There is no content yet.