mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-05 11:05:27 +00:00
add text/plain content type support
This commit is contained in:
parent
63d2821c07
commit
f2da250376
6 changed files with 75 additions and 64 deletions
22
src/app/browser/window/tab/item/page/content/text/plain.rs
Normal file
22
src/app/browser/window/tab/item/page/content/text/plain.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
use gtk::{TextBuffer, TextView};
|
||||
|
||||
pub trait Plain {
|
||||
fn plain(data: &str) -> Self;
|
||||
}
|
||||
|
||||
impl Plain for TextView {
|
||||
fn plain(data: &str) -> Self {
|
||||
const MARGIN: i32 = 8;
|
||||
TextView::builder()
|
||||
.bottom_margin(MARGIN)
|
||||
.cursor_visible(false)
|
||||
.buffer(&TextBuffer::builder().text(data).build())
|
||||
.editable(false)
|
||||
.left_margin(MARGIN)
|
||||
.monospace(true)
|
||||
.right_margin(MARGIN)
|
||||
.top_margin(MARGIN)
|
||||
.vexpand(true)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
use gtk::{Align, Label};
|
||||
|
||||
pub struct Reader {
|
||||
widget: Label,
|
||||
}
|
||||
|
||||
impl Default for Reader {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Reader {
|
||||
// Construct
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
widget: Label::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Start)
|
||||
.margin_start(8)
|
||||
.margin_end(8)
|
||||
.wrap(true)
|
||||
.selectable(true)
|
||||
.use_markup(true)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &Label {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue