mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
rename wrapper mod to window
This commit is contained in:
parent
992ecfc0f6
commit
d5101a6465
26 changed files with 8 additions and 8 deletions
68
src/app/browser/window/tab/page/content.rs
Normal file
68
src/app/browser/window/tab/page/content.rs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
// @TODO mod image;
|
||||
mod text;
|
||||
|
||||
use text::Text;
|
||||
|
||||
use gtk::{
|
||||
gio::SimpleAction,
|
||||
glib::{GString, Uri},
|
||||
prelude::{BoxExt, WidgetExt},
|
||||
Box, Orientation,
|
||||
};
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub enum Mime {
|
||||
TextGemini,
|
||||
// TextPlain,
|
||||
}
|
||||
|
||||
pub struct ResetResult {
|
||||
pub title: Option<GString>,
|
||||
}
|
||||
|
||||
pub struct Content {
|
||||
// GTK
|
||||
widget: Box,
|
||||
// Actions
|
||||
action_page_open: Arc<SimpleAction>,
|
||||
}
|
||||
|
||||
impl Content {
|
||||
// Construct
|
||||
pub fn new(action_page_open: Arc<SimpleAction>) -> Self {
|
||||
Self {
|
||||
widget: Box::builder().orientation(Orientation::Vertical).build(),
|
||||
action_page_open,
|
||||
}
|
||||
}
|
||||
|
||||
// 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.action_page_open.clone());
|
||||
|
||||
self.widget.append(child.widget());
|
||||
|
||||
ResetResult {
|
||||
title: child.meta_title().clone(),
|
||||
}
|
||||
} /* @TODO
|
||||
Mime::TextPlain => {
|
||||
todo!()
|
||||
} */
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &Box {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue