mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
init local browser driver
This commit is contained in:
parent
b56de4b4b5
commit
9e1fb9c5ca
3 changed files with 33 additions and 0 deletions
|
|
@ -65,6 +65,7 @@ impl Client {
|
||||||
match result {
|
match result {
|
||||||
// route by scheme
|
// route by scheme
|
||||||
Ok(uri) => match uri.scheme().as_str() {
|
Ok(uri) => match uri.scheme().as_str() {
|
||||||
|
"file" => driver.file.handle(uri, feature, cancellable),
|
||||||
"gemini" | "titan" => driver.gemini.handle(uri, feature, cancellable),
|
"gemini" | "titan" => driver.gemini.handle(uri, feature, cancellable),
|
||||||
scheme => {
|
scheme => {
|
||||||
// no scheme match driver, complete with failure message
|
// no scheme match driver, complete with failure message
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
|
mod file;
|
||||||
mod gemini;
|
mod gemini;
|
||||||
|
|
||||||
use super::{Feature, Page};
|
use super::{Feature, Page};
|
||||||
|
use file::File;
|
||||||
use gemini::Gemini;
|
use gemini::Gemini;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
/// Different protocols implementation
|
/// Different protocols implementation
|
||||||
pub struct Driver {
|
pub struct Driver {
|
||||||
|
pub file: File,
|
||||||
pub gemini: Gemini,
|
pub gemini: Gemini,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -15,6 +18,7 @@ impl Driver {
|
||||||
/// Build new `Self`
|
/// Build new `Self`
|
||||||
pub fn build(page: &Rc<Page>) -> Self {
|
pub fn build(page: &Rc<Page>) -> Self {
|
||||||
Driver {
|
Driver {
|
||||||
|
file: File::init(page),
|
||||||
gemini: Gemini::init(page),
|
gemini: Gemini::init(page),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
28
src/app/browser/window/tab/item/client/driver/file.rs
Normal file
28
src/app/browser/window/tab/item/client/driver/file.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
use super::{Feature, Page};
|
||||||
|
use gtk::{gio::Cancellable, glib::Uri};
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
/// Local files client driver
|
||||||
|
pub struct File {
|
||||||
|
// page: Rc<Page>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl File {
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
/// Create new `Self`
|
||||||
|
pub fn init(_page: &Rc<Page>) -> Self {
|
||||||
|
Self { /*page: page.clone()*/ } // @TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn handle(&self, uri: Uri, _feature: Rc<Feature>, cancellable: Cancellable) {
|
||||||
|
use gtk::{gio::File, prelude::FileExtManual};
|
||||||
|
|
||||||
|
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