mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
draft file type router
This commit is contained in:
parent
9e1fb9c5ca
commit
0574ab81fd
1 changed files with 47 additions and 10 deletions
|
|
@ -4,25 +4,62 @@ use std::rc::Rc;
|
||||||
|
|
||||||
/// Local files client driver
|
/// Local files client driver
|
||||||
pub struct File {
|
pub struct File {
|
||||||
// page: Rc<Page>,
|
page: Rc<Page>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl File {
|
impl File {
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
/// Create new `Self`
|
/// Create new `Self`
|
||||||
pub fn init(_page: &Rc<Page>) -> Self {
|
pub fn init(page: &Rc<Page>) -> Self {
|
||||||
Self { /*page: page.clone()*/ } // @TODO
|
Self { page: page.clone() } // @TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle(&self, uri: Uri, _feature: Rc<Feature>, cancellable: Cancellable) {
|
pub fn handle(&self, uri: Uri, _feature: Rc<Feature>, cancellable: Cancellable) {
|
||||||
use gtk::{gio::File, prelude::FileExtManual};
|
use gtk::{
|
||||||
|
gio::{File, FileQueryInfoFlags, FileType},
|
||||||
|
glib::Priority,
|
||||||
|
prelude::FileExtManual,
|
||||||
|
};
|
||||||
|
|
||||||
File::for_uri(&uri.to_string()).load_contents_async(Some(&cancellable), |result| {
|
// try handle as directory
|
||||||
match result {
|
File::for_uri(&uri.to_string()).enumerate_children_async(
|
||||||
Ok(_) => todo!(),
|
"standard::content-type",
|
||||||
Err(_) => todo!(),
|
FileQueryInfoFlags::NONE,
|
||||||
}
|
Priority::DEFAULT,
|
||||||
});
|
Some(&cancellable),
|
||||||
|
{
|
||||||
|
let cancellable = cancellable.clone();
|
||||||
|
let uri = uri.clone();
|
||||||
|
let _page = self.page.clone();
|
||||||
|
move |result| match result {
|
||||||
|
Ok(file_enumerator) => {
|
||||||
|
for entry in file_enumerator {
|
||||||
|
match entry {
|
||||||
|
Ok(file_info) => match file_info.file_type() {
|
||||||
|
FileType::Unknown => todo!(),
|
||||||
|
FileType::Regular => todo!(),
|
||||||
|
FileType::Directory => todo!(),
|
||||||
|
FileType::SymbolicLink => todo!(),
|
||||||
|
FileType::Special => todo!(),
|
||||||
|
FileType::Shortcut => todo!(),
|
||||||
|
FileType::Mountable => todo!(),
|
||||||
|
_ => todo!(),
|
||||||
|
},
|
||||||
|
Err(_) => todo!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// is not a directory, try handle as file
|
||||||
|
Err(_) => File::for_uri(&uri.to_string()).load_contents_async(
|
||||||
|
Some(&cancellable),
|
||||||
|
|result| match result {
|
||||||
|
Ok(_) => todo!(),
|
||||||
|
Err(_) => todo!(),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue