mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
use parsed header as title on available
This commit is contained in:
parent
8b521e459a
commit
841c4a4a99
3 changed files with 50 additions and 17 deletions
|
|
@ -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!()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue