use parsed header as title on available

This commit is contained in:
yggverse 2024-09-27 21:20:23 +03:00
parent 8b521e459a
commit 841c4a4a99
3 changed files with 50 additions and 17 deletions

View file

@ -4,7 +4,7 @@ mod text;
use text::Text;
use gtk::{
glib::Uri,
glib::{GString, Uri},
prelude::{BoxExt, WidgetExt},
Box, Orientation,
};
@ -14,6 +14,10 @@ pub enum Mime {
TextPlain,
}
pub struct ResetResult {
pub title: Option<GString>,
}
pub struct Content {
widget: Box,
}
@ -27,16 +31,22 @@ impl Content {
}
// Actions
pub fn reset(&self, mime: Mime, base: &Uri, data: &str) {
pub fn reset(&self, mime: Mime, base: &Uri, data: &str) -> ResetResult {
// Cleanup
while let Some(child) = self.widget.last_child() {
self.widget.remove(&child)
}
// Compose
// Re-compose
match mime {
Mime::TextGemini => {
self.widget.append(Text::gemini(data, base).widget());
let child = Text::gemini(data, base);
self.widget.append(child.widget());
ResetResult {
title: child.meta_title().clone(),
}
}
Mime::TextPlain => {
todo!()