From 97af26c44e163a147e7191a03d63a214a5abccf0 Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 22 Jan 2025 07:55:31 +0200 Subject: [PATCH] return reference to counter `Label` --- src/app/browser/window/tab/item/client.rs | 2 +- src/app/browser/window/tab/item/page/input.rs | 4 ++-- src/app/browser/window/tab/item/page/input/titan.rs | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/app/browser/window/tab/item/client.rs b/src/app/browser/window/tab/item/client.rs index 55e8bb8d..0f417e0b 100644 --- a/src/app/browser/window/tab/item/client.rs +++ b/src/app/browser/window/tab/item/client.rs @@ -84,7 +84,7 @@ impl Client { // route by scheme Ok(uri) => match uri.scheme().as_str() { "gemini" => driver.gemini.handle(uri, feature, cancellable), - "titan" => subject.page.input.set_new_titan(|_data| todo!()), + "titan" => subject.page.input.set_new_titan(|_data, _label| todo!()), scheme => { // no scheme match driver, complete with failure message let status = subject.page.content.to_status_failure(); diff --git a/src/app/browser/window/tab/item/page/input.rs b/src/app/browser/window/tab/item/page/input.rs index b12a6d8c..40138682 100644 --- a/src/app/browser/window/tab/item/page/input.rs +++ b/src/app/browser/window/tab/item/page/input.rs @@ -4,7 +4,7 @@ mod titan; mod widget; use super::TabAction; -use gtk::glib::Uri; +use gtk::{glib::Uri, Label}; use response::Response; use sensitive::Sensitive; use std::rc::Rc; @@ -65,7 +65,7 @@ impl Input { )); } - pub fn set_new_titan(&self, on_send: impl Fn(&[u8]) + 'static) { + pub fn set_new_titan(&self, on_send: impl Fn(&[u8], &Label) + 'static) { self.widget .update(Some(&Titan::build(on_send).widget.g_box)); } diff --git a/src/app/browser/window/tab/item/page/input/titan.rs b/src/app/browser/window/tab/item/page/input/titan.rs index 5df9f53f..a9c758df 100644 --- a/src/app/browser/window/tab/item/page/input/titan.rs +++ b/src/app/browser/window/tab/item/page/input/titan.rs @@ -8,7 +8,7 @@ use form::Form; use title::Title; use widget::Widget; -use gtk::{gio::SimpleAction, glib::uuid_string_random}; +use gtk::{gio::SimpleAction, glib::uuid_string_random, Label}; use std::rc::Rc; pub struct Titan { @@ -20,7 +20,7 @@ impl Titan { // Constructors /// Build new `Self` - pub fn build(on_send: impl Fn(&[u8]) + 'static) -> Self { + pub fn build(on_send: impl Fn(&[u8], &Label) + 'static) -> Self { // Init local actions let action_update = SimpleAction::new(&uuid_string_random(), None); let action_send = SimpleAction::new(&uuid_string_random(), None); @@ -44,7 +44,9 @@ impl Titan { move |_, _| control.update(Some(form.widget.text().as_bytes().len())) }); - action_send.connect_activate(move |_, _| on_send(form.widget.text().as_bytes())); + action_send.connect_activate(move |_, _| { + on_send(form.widget.text().as_bytes(), &control.counter.label) + }); // Return activated struct Self { widget }