fix input redraw

This commit is contained in:
yggverse 2024-10-17 07:05:51 +03:00
parent ec86a9ecd0
commit b8b5eee4fe
3 changed files with 11 additions and 23 deletions

View File

@ -158,8 +158,8 @@ impl Page {
}
pub fn navigation_reload(&self) {
// Reset components
self.input.hide();
// Reset widgets
self.input.unset();
// Init globals
let request_text = self.navigation.request_text();
@ -284,8 +284,7 @@ impl Page {
let description = gformat!("{placeholder}");
// Make input form
input.use_response(action_page_open, uri, Some(&description), Some(1024));
input.show();
input.set_new_response(action_page_open, uri, Some(&description), Some(1024));
// Update meta
meta.borrow_mut().status = Some(status);

View File

@ -23,23 +23,19 @@ impl Input {
}
// Actions
pub fn show(&self) {
self.widget.show()
pub fn unset(&self) {
self.widget.update(None);
}
pub fn hide(&self) {
self.widget.hide()
}
// Variant switcher
pub fn use_response(
// Setters
pub fn set_new_response(
&self,
action_page_open: Arc<SimpleAction>,
base: Uri,
title: Option<&str>,
size_limit: Option<usize>,
) {
self.widget.set_child(Some(
self.widget.update(Some(
&Response::new_arc(action_page_open, base, title, size_limit).gobject(),
));
}

View File

@ -19,19 +19,12 @@ impl Widget {
}
// Actions
pub fn show(&self) {
self.gobject.set_visible(true)
}
pub fn hide(&self) {
self.gobject.set_visible(false)
}
pub fn set_child(&self, child: Option<&Box>) {
pub fn update(&self, child: Option<&Box>) {
if child.is_some() {
self.gobject.set_visible(true); // widget may be hidden, make it visible to child redraw
self.gobject.set_child(child);
} else {
self.hide()
self.gobject.set_visible(false)
}
}