mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
use modern (2018) pattern for modules
This commit is contained in:
parent
1627902b8f
commit
cdc3fe3388
28 changed files with 0 additions and 0 deletions
61
src/browser/main/tab/page/content.rs
Normal file
61
src/browser/main/tab/page/content.rs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
// @TODO mod image;
|
||||
mod text;
|
||||
|
||||
use text::Text;
|
||||
|
||||
use gtk::{
|
||||
glib::{GString, Uri},
|
||||
prelude::{BoxExt, WidgetExt},
|
||||
Box, Orientation,
|
||||
};
|
||||
|
||||
pub enum Mime {
|
||||
TextGemini,
|
||||
TextPlain,
|
||||
}
|
||||
|
||||
pub struct ResetResult {
|
||||
pub title: Option<GString>,
|
||||
}
|
||||
|
||||
pub struct Content {
|
||||
widget: Box,
|
||||
}
|
||||
|
||||
impl Content {
|
||||
// Construct
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
widget: Box::builder().orientation(Orientation::Vertical).build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn reset(&self, mime: Mime, base: &Uri, data: &str) -> ResetResult {
|
||||
// Cleanup
|
||||
while let Some(child) = self.widget.last_child() {
|
||||
self.widget.remove(&child)
|
||||
}
|
||||
|
||||
// Re-compose
|
||||
match mime {
|
||||
Mime::TextGemini => {
|
||||
let child = Text::gemini(data, base);
|
||||
|
||||
self.widget.append(child.widget());
|
||||
|
||||
ResetResult {
|
||||
title: child.meta_title().clone(),
|
||||
}
|
||||
}
|
||||
Mime::TextPlain => {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &Box {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue