replace arguments with callback

This commit is contained in:
yggverse 2025-01-14 08:29:56 +02:00
parent 44be1a7dab
commit e0adc0661c
3 changed files with 7 additions and 17 deletions

View File

@ -237,7 +237,7 @@ impl Page {
let title = "Titan input";
// Toggle input form
self.input.set_new_titan(&self.tab_action, uri, Some(title));
// @TODO self.input.set_new_titan(|data|{});
// Update meta
self.meta.set_status(status).set_title(title);

View File

@ -66,8 +66,8 @@ impl Input {
));
}
pub fn set_new_titan(&self, action: &Rc<TabAction>, base: &Uri, title: Option<&str>) {
pub fn set_new_titan(&self, callback: impl Fn(&[u8]) + 'static) {
self.widget
.update(Some(&Titan::build(action, base, title).widget.g_box));
.update(Some(&Titan::build(callback).widget.g_box));
}
}

View File

@ -8,11 +8,7 @@ use form::Form;
use title::Title;
use widget::Widget;
use super::TabAction;
use gtk::{
gio::SimpleAction,
glib::{uuid_string_random, Uri},
};
use gtk::{gio::SimpleAction, glib::uuid_string_random};
use std::rc::Rc;
pub struct Titan {
@ -24,7 +20,7 @@ impl Titan {
// Constructors
/// Build new `Self`
pub fn build(_tab_action: &Rc<TabAction>, _base: &Uri, title: Option<&str>) -> Self {
pub fn build(callback: impl Fn(&[u8]) + 'static) -> Self {
// Init local actions
let action_update = SimpleAction::new(&uuid_string_random(), None);
let action_send = SimpleAction::new(&uuid_string_random(), None);
@ -32,7 +28,7 @@ impl Titan {
// Init components
let control = Rc::new(Control::build(action_send.clone()));
let form = Rc::new(Form::build(action_update.clone()));
let title = Rc::new(Title::build(title));
let title = Rc::new(Title::build(None)); // @TODO
// Init widget
let widget = Rc::new(Widget::build(
@ -50,13 +46,7 @@ impl Titan {
action_send.connect_activate({
// @TODO let form = form.clone();
move |_, _| {
todo!()
/* tab_action.load.activate(
Some(&),
true,
);*/
}
move |_, _| callback(&[]) // @TODO input data
});
// Return activated struct