draft gemtext composer

This commit is contained in:
yggverse 2024-09-26 14:30:54 +03:00
parent 70f3b51591
commit 1cc3ddaf2e
5 changed files with 89 additions and 8 deletions

View file

@ -1,6 +1,18 @@
use gtk::{Box, Orientation};
// @TODO mod image;
mod text;
use text::Text;
use gtk::{prelude::BoxExt, Box, Orientation};
pub enum Mime {
Undefined,
TextGemini,
TextPlain,
}
pub struct Content {
mime: Mime,
widget: Box,
}
@ -8,10 +20,28 @@ impl Content {
// Construct
pub fn new() -> Self {
Self {
mime: Mime::Undefined,
widget: Box::builder().orientation(Orientation::Vertical).build(),
}
}
// Actions
pub fn reset(&self, mime: Mime, data: &str) {
//self.widget.remove(self.child.widget());
match mime {
Mime::TextGemini => {
let child = Text::gemini(data);
self.widget.append(child.widget());
}
Mime::TextPlain => {
todo!()
}
Mime::Undefined => {
todo!()
}
}
}
// Getters
pub fn widget(&self) -> &Box {
&self.widget