return reference to counter Label

This commit is contained in:
yggverse 2025-01-22 07:55:31 +02:00
parent c72da12c26
commit 97af26c44e
3 changed files with 8 additions and 6 deletions

View file

@ -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));
}

View file

@ -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 }