separate page handler from loader, draft some Titan features

This commit is contained in:
yggverse 2025-01-19 12:52:53 +02:00
parent 123be8c97e
commit f73b5c7956
5 changed files with 343 additions and 310 deletions

View file

@ -1,20 +1,10 @@
use gtk::{
gio::{Cancellable, IOStream},
glib::{GString, Uri},
};
pub mod titan;
pub use titan::Titan;
use gtk::glib::{GString, Uri};
pub enum Input {
Response {
base: Uri,
title: GString,
},
Sensitive {
base: Uri,
title: GString,
},
Titan {
base: Uri,
cancellable: Cancellable,
stream: IOStream,
},
Response { base: Uri, title: GString },
Sensitive { base: Uri, title: GString },
Titan(Titan),
}

View file

@ -0,0 +1,6 @@
use gtk::gio::{Cancellable, IOStream};
pub struct Titan {
cancellable: Cancellable,
stream: IOStream,
}

View file

@ -3,15 +3,14 @@ mod sensitive;
mod titan;
mod widget;
use super::TabAction;
use gtk::glib::Uri;
use response::Response;
use sensitive::Sensitive;
use std::rc::Rc;
use titan::Titan;
use widget::Widget;
use crate::app::browser::window::tab::item::Action as TabAction;
use gtk::glib::Uri;
use std::rc::Rc;
pub struct Input {
pub widget: Rc<Widget>,
}
@ -66,8 +65,12 @@ impl Input {
));
}
pub fn set_new_titan(&self, callback: impl Fn(&[u8]) + 'static) {
pub fn set_new_titan(
&self,
titan: super::client::response::input::Titan,
callback: impl Fn(Result<super::client::Response, ()>) + 'static,
) {
self.widget
.update(Some(&Titan::build(callback).widget.g_box));
.update(Some(&Titan::build(titan, callback).widget.g_box));
}
}

View file

@ -5,11 +5,10 @@ mod widget;
use control::Control;
use form::Form;
use title::Title;
use widget::Widget;
use gtk::{gio::SimpleAction, glib::uuid_string_random};
use std::rc::Rc;
use title::Title;
use widget::Widget;
pub struct Titan {
// Components
@ -20,7 +19,10 @@ impl Titan {
// Constructors
/// Build new `Self`
pub fn build(on_sent: impl Fn(&[u8]) + 'static) -> Self {
pub fn build(
titan: super::super::client::response::input::Titan,
callback: impl Fn(Result<super::super::client::Response, ()>) + 'static,
) -> Self {
// Init local actions
let action_update = SimpleAction::new(&uuid_string_random(), None);
let action_send = SimpleAction::new(&uuid_string_random(), None);
@ -46,7 +48,7 @@ impl Titan {
action_send.connect_activate({
// @TODO let form = form.clone();
move |_, _| on_sent(&[]) // @TODO input data
move |_, _| callback(todo!()) // @TODO input data
});
// Return activated struct