From e813cdeafa0043f4bf7db91971eb0af45236f0ef Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 7 Nov 2025 20:59:06 +0200 Subject: [PATCH] use shared input max height value --- src/app/browser/window/tab/item/page/input.rs | 13 +++++++++++-- .../browser/window/tab/item/page/input/response.rs | 4 +++- src/app/browser/window/tab/item/page/input/titan.rs | 12 +++++++++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/app/browser/window/tab/item/page/input.rs b/src/app/browser/window/tab/item/page/input.rs index eab68b34..f03994e1 100644 --- a/src/app/browser/window/tab/item/page/input.rs +++ b/src/app/browser/window/tab/item/page/input.rs @@ -61,7 +61,13 @@ impl Input { title: Option<&str>, size_limit: Option, ) { - self.update(Some(>k::Box::response(action, base, title, size_limit))); + self.update(Some(>k::Box::response( + action, + base, + title, + size_limit, + MAX_CONTENT_HEIGHT, + ))); } pub fn set_new_sensitive( @@ -75,6 +81,9 @@ impl Input { } pub fn set_new_titan(&self, on_send: impl Fn(titan::Header, Bytes, Box) + 'static) { - self.update(Some(>k::Box::titan(on_send))); + self.update(Some(>k::Box::titan(MAX_CONTENT_HEIGHT, on_send))); } } + +/// @TODO optional, maybe relative to the current window height in % +const MAX_CONTENT_HEIGHT: i32 = 280; diff --git a/src/app/browser/window/tab/item/page/input/response.rs b/src/app/browser/window/tab/item/page/input/response.rs index c2636b7c..32f6a365 100644 --- a/src/app/browser/window/tab/item/page/input/response.rs +++ b/src/app/browser/window/tab/item/page/input/response.rs @@ -23,6 +23,7 @@ pub trait Response { base: Uri, title: Option<&str>, size_limit: Option, + max_content_height: i32, ) -> Self; } @@ -35,6 +36,7 @@ impl Response for Box { base: Uri, title: Option<&str>, size_limit: Option, + max_content_height: i32, ) -> Self { // Init components let control = Rc::new(Control::build()); @@ -55,7 +57,7 @@ impl Response for Box { g_box.append( >k::ScrolledWindow::builder() .child(&text_view) - .max_content_height(320) + .max_content_height(max_content_height) .propagate_natural_height(true) .build(), ); 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 801c8ba4..62231c18 100644 --- a/src/app/browser/window/tab/item/page/input/titan.rs +++ b/src/app/browser/window/tab/item/page/input/titan.rs @@ -16,11 +16,17 @@ use tab::Tab; use text::Text; pub trait Titan { - fn titan(callback: impl Fn(Header, Bytes, Box) + 'static) -> Self; + fn titan( + max_content_height: i32, + callback: impl Fn(Header, Bytes, Box) + 'static, + ) -> Self; } impl Titan for gtk::Box { - fn titan(callback: impl Fn(Header, Bytes, Box) + 'static) -> Self { + fn titan( + max_content_height: i32, + callback: impl Fn(Header, Bytes, Box) + 'static, + ) -> Self { use gtk::{Label, glib::uuid_string_random, prelude::ButtonExt}; use std::rc::Rc; @@ -38,7 +44,7 @@ impl Titan for gtk::Box { notebook.append_page( >k::ScrolledWindow::builder() .child(&text.text_view) - .max_content_height(320) + .max_content_height(max_content_height) .propagate_natural_height(true) .build(), Some(&Label::tab("Text")),