refactor: make workspace.rs implements on EchidnaWindow

The code was moved from the EchidnaEditor struct, but we haven't updated
it to implement EchidnaWindow instead of EchidnaEditor.
merge-requests/12/head
Nefo Fortressia 2021-11-11 06:20:11 +07:00
parent e6d69db499
commit 966a909ab8
Signed by: fortressia
GPG Key ID: 6D7972CC76174995
1 changed files with 10 additions and 10 deletions

View File

@ -1,15 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public /* This Source Code Form is subject to the terms of the Mozilla Public
* 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 super::EchidnaWindow;
use super::imp::EchidnaEditor;
use gio::Cancellable; use gio::Cancellable;
use gio::{File, FileQueryInfoFlags, FileType, SimpleAction}; use gio::{File, FileQueryInfoFlags, FileType, SimpleAction};
use glib::clone; use glib::clone;
use glib::subclass::types::ObjectSubclassExt;
use glib::types::Type; use glib::types::Type;
use gtk::prelude::*; use gtk::prelude::*;
use gtk::{ApplicationWindow, FileChooserAction, FileChooserDialog, ResponseType, TreeStore}; use gtk::{
Application, ApplicationWindow, FileChooserAction, FileChooserDialog, ResponseType, TreeStore,
TreeView,
};
use relative_path::RelativePath; use relative_path::RelativePath;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::path::Path; use std::path::Path;
@ -28,7 +29,7 @@ trait WorkspaceImplementedEditor {
fn action_open_workspace( fn action_open_workspace(
&self, &self,
window: ApplicationWindow, window: ApplicationWindow,
app: super::EchidnaEditor, app: Application,
_action: &SimpleAction, _action: &SimpleAction,
_variant: Option<&glib::Variant>, _variant: Option<&glib::Variant>,
); );
@ -38,11 +39,11 @@ trait WorkspaceImplementedEditor {
fn open_folder(&self, file: File); fn open_folder(&self, file: File);
} }
impl WorkspaceImplementedEditor for EchidnaEditor { impl WorkspaceImplementedEditor for EchidnaWindow {
fn action_open_workspace( fn action_open_workspace(
&self, &self,
window: ApplicationWindow, window: ApplicationWindow,
app: super::EchidnaEditor, app: Application,
_action: &SimpleAction, _action: &SimpleAction,
_variant: Option<&glib::Variant>, _variant: Option<&glib::Variant>,
) { ) {
@ -56,14 +57,14 @@ impl WorkspaceImplementedEditor for EchidnaEditor {
], ],
); );
dialog.set_visible(true); dialog.set_visible(true);
dialog.connect_response(clone!(@weak window, @weak app => dialog.connect_response(clone!(@weak self as win =>
move |dialog, response| { move |dialog, response| {
if response == ResponseType::Accept { if response == ResponseType::Accept {
let file_option = dialog.file(); let file_option = dialog.file();
match file_option { match file_option {
Some(file) => { Some(file) => {
dialog.destroy(); dialog.destroy();
Self::from_instance(&app).open_workspace(file); win.open_workspace(file);
}, },
None => {} None => {}
} }
@ -125,7 +126,6 @@ impl WorkspaceImplementedEditor for EchidnaEditor {
self.open_folder(folder); self.open_folder(folder);
} }
} }
}
/** /**
* *